- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
实际上,我使用 Java 从西类牙语文本中提取三元组。我需要提取 NP-VP-NP
形式的三元组。我也在使用斯坦福解析器 CoreNLP v 3.7.0 和西类牙语模型 v 3.7.0。接下来我的问题是,有没有办法从西类牙语模型的句子中提取 NP 子树和 VP 子树?我意识到西类牙语解析器树形式与英语形式不同。
例如:
(ROOT (句子 (sn (spec (da0000 El)) (grup.nom (nc0s000 reino))) (grup.verb (vmm0000 canta) (sadv (spec (rg muy)) (grup.adv (rg bien))) (fp .)))
最佳答案
您应该使用主要发行版来确保您拥有一切并下载西类牙模型
(可在此处获取:http://stanfordnlp.github.io/CoreNLP/download.html)
package edu.stanford.nlp.examples;
import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.pipeline.*;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.trees.tregex.*;
import edu.stanford.nlp.util.*;
import java.util.*;
public class TregexExample {
public static void main(String[] args) {
// set up pipeline
Properties props = StringUtils.argsToProperties("-props", "StanfordCoreNLP-spanish.properties");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// Spanish example
Annotation spanishDoc = new Annotation("...insert Spanish text...");
pipeline.annotate(spanishDoc);
// get first sentence
CoreMap firstSentence = spanishDoc.get(CoreAnnotations.SentencesAnnotation.class).get(0);
Tree firstSentenceTree = firstSentence.get(TreeCoreAnnotations.TreeAnnotation.class);
// use Tregex to match
String nounPhrasePattern = "/grup\\.nom/";
TregexPattern nounPhraseTregexPattern = TregexPattern.compile(nounPhrasePattern);
TregexMatcher nounPhraseTregexMatcher = nounPhraseTregexPattern.matcher(firstSentenceTree);
while (nounPhraseTregexMatcher.find()) {
nounPhraseTregexMatcher.getMatch().pennPrint();
}
}
}
关于java - 如何使用西类牙语模型在斯坦福解析器中获取 NP 和 VP 子树,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43164239/
以下代码在gcc中没有问题。在 VS 2010 Express 中,它无法给出 ------ Build started: Project: helium, Configuration: Debug
我有一个我不明白的光线生成问题。我的光线方向计算错误。我将这段代码从 DirectX 11 移植到 Vulkan,在那里它运行良好,所以我很惊讶我无法让它运行: vec4 farPos = inver
我需要从依存分析树中提取形式为 NP-VP-NP 的三元组,作为 Stanford Parser 中词汇化分析的输出。 执行此操作的最佳方法是什么。例如如果解析树如下: (ROOT (S
我正在为我正在开发的项目制作序列图。没有什么太复杂,只是一些来回调用的生命线。 问题是,在近距离时,我的消息描述的白色背景框会盖住我的生命线框和虚线之类的东西。您可以在下图中看到问题,尽管我尝试将它们
实际上,我使用 Java 从西类牙语文本中提取三元组。我需要提取 NP-VP-NP 形式的三元组。我也在使用斯坦福解析器 CoreNLP v 3.7.0 和西类牙语模型 v 3.7.0。接下来我的问题
我想根据连词和逗号分割树。例如,当我有 VP 和 VP 或 NP 和 NP 或 VP, VP 或 NP,NP 时,我想分别提取每个 VP 或 NP。我有以下代码: List subtrees = c
#include #include #include int mms; int ps; int rp; struct node{ int *pf; int *vp; } *pt=NULL; vo
我有一个示例,其中斯坦福 NLP 为句子输出了一个奇怪的解析树: Clean my desk (ROOT (NP (NP (JJ Clean)) (NP (PRP$ my) (NN
我的 ERD 是 alt text http://files.getdropbox.com/u/175564/db/db-8.png 我现在使用 integer(2) 来表示数据类型是 boolean
我无法启动android模拟器,它总是退出并出现错误:WHPX: Unexpected VP exit code 5 . 我使用了 Android Studio 3.6.2 和最新的 AVD,并安装了
我想计算文本中 pp/np/vp 的数量,但我不知道如何在 openNLP chunker 中识别 PP-tags/NP-tags/VP-tags?我已经尝试过这段代码,但它不起作用。 Chunker
我需要表示这样的重载方法: +setAttribute(int) +setAttribute(float) +setAttribute(boolean) 在单个 Java 类中。 VP UML 不允许
我正在使用 Stanford CoreNLP,我知道它不支持句子分块。我正在寻找的是,给定一个输入句子,将类似这样的内容作为输出: [NP He ] [VP reckons ] [NP the cu
当我想创建散点图矩阵时,出现错误 Error in grid.Call.graphics(C_downviewport, name$name, strict) : Viewport 'plot_01.
输出中有 Give me 0 0 #include #define fsv(i , n) for(int i = 0 ; i > n ; vector > > vp(n); vector v
我正在使用 vimeo 播放器在我的页面上嵌入视频。 由于某些原因,视频的缩略图在 Safari 中有 vp-preview-invisible 类(这使得缩略图不可见),但在 Chrome 中没有这
我正在使用 vimeo 播放器在我的页面上嵌入视频。 由于某些原因,视频的缩略图在 Safari 中有 vp-preview-invisible 类(这使得缩略图不可见),但在 Chrome 中没有这
我是一名优秀的程序员,十分优秀!