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

Stanford nlp 为什么在构建依赖项解析树时,StanfordCoreNlp管道的属性设置很重要?,stanford-nlp,Stanford Nlp,我一直在使用StanfordCorenlp,我发现用以下代码构建依赖项解析树 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"); Stanf

我一直在使用StanfordCorenlp,我发现用以下代码构建依赖项解析树

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 ));
}
然而,这个代码

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 ));
}
那为什么我不能用这两种方法得到相同的结果呢?是否可以将后面的代码更改为与第一个代码等效,因为加载选区解析器也会使解析速度变慢?您建议如何设置属性以获得最准确的依赖项解析树?

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

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 ));
}
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)