首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在构建依赖解析树时,StanfordCoreNlp管道的属性设置很重要?

为什么在构建依赖解析树时,StanfordCoreNlp管道的属性设置很重要?
EN

Stack Overflow用户
提问于 2016-09-28 07:05:55
回答 1查看 157关注 0票数 1

我一直在尝试使用Stanford-CoreNLP,我发现使用以下代码构建依赖关系解析树

代码语言:javascript
复制
String text = "Are depparse and parse equivalent properties for building dependency parse tree?"
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, parse, lemma, ner");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation document = new Annotation(text);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
    SemanticGraph graph = sentence.get(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class);
    System.out.println(graph.toString(SemanticGraph.OutputFormat.LIST ));
}

正在输出

代码语言:javascript
复制
root(ROOT-0, tree-11)
cop(tree-11, Are-1)
amod(properties-6, depparse-2)
cc(depparse-2, and-3)
conj(depparse-2, parse-4)
compound(properties-6, equivalent-5)
nsubj(tree-11, properties-6)
case(dependency-9, for-7)
compound(dependency-9, building-8)
nmod(properties-6, dependency-9)
amod(tree-11, parse-10)
punct(tree-11, ?-12)

然而,这段代码

代码语言:javascript
复制
String text = "Are depparse and parse equivalent properties for building dependency parse tree?"
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, lemma, ner, depparse");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation document = new Annotation(text);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
    SemanticGraph graph = sentence.get(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class);
    System.out.println(graph.toString(SemanticGraph.OutputFormat.LIST ));
}

输出

代码语言:javascript
复制
root(ROOT-0, properties-6)
cop(properties-6, Are-1)
compound(properties-6, depparse-2)
cc(depparse-2, and-3)
conj(depparse-2, parse-4)
amod(properties-6, equivalent-5)
case(tree-11, for-7)
amod(tree-11, building-8)
compound(tree-11, dependency-9)
amod(tree-11, parse-10)
nmod(properties-6, tree-11)
punct(properties-6, ?-12)

那么为什么我不能用这两种方法得到相同的输出呢?是否有可能将后面的代码更改为与第一个代码等效,因为加载成分解析器也会使解析变得如此缓慢?您建议如何设置属性以获得最准确的依赖关系解析树?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-28 07:16:15

构成解析器(parse注释器)和依赖关系解析器(depparse注释器)实际上是完全不同的模型和代码路径。在一种情况下,我们预测一个选民树,并将其转换为依赖图。在另一种情况下,我们直接运行依赖关系解析器。一般来说,depparse应该更快(O(n) vs O(n^3)),并且在生成依赖树方面更准确,但不会生成选民树。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39735651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档