为什么从stanfordNLP中提供的api和GUI生成的解析树输出不同

为什么从stanfordNLP中提供的api和GUI生成的解析树输出不同,nlp,stanford-nlp,Nlp,Stanford Nlp,我正在使用“stanford-corenlp-full-2013-06-20”api生成解析树,如下所示 private String text= "Heart attack causes reduced lifespan average"; Annotation annotation = new Annotation(text); coreNLP.annotate(annotation); List<CoreMap> sentences = annotation.get(Sente

我正在使用“stanford-corenlp-full-2013-06-20”api生成解析树,如下所示

private String text= "Heart attack causes reduced lifespan average";
Annotation annotation = new Annotation(text);
coreNLP.annotate(annotation);
List<CoreMap> sentences = annotation.get(SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
    Tree tree = sentence.get(TreeAnnotation.class);
    tree.pennPrint();
}
(ROOT (**S** (NP (NNP Heart) (NN attack))
             (VP (VBZ causes)
                 (VP (VBN reduced) (NP (NN lifespan) (NN average))))))
但当我尝试使用“stanford-parser-full-2013-06-20”提供的GUI解析同一个句子时,它给出了一个不同的树(似乎是正确的树),如下所示

private String text= "Heart attack causes reduced lifespan average";
Annotation annotation = new Annotation(text);
coreNLP.annotate(annotation);
List<CoreMap> sentences = annotation.get(SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
    Tree tree = sentence.get(TreeAnnotation.class);
    tree.pennPrint();
}
(ROOT (**S** (NP (NNP Heart) (NN attack))
             (VP (VBZ causes)
                 (VP (VBN reduced) (NP (NN lifespan) (NN average))))))

有人能指出为什么它们都显示两个不同的输出,尽管它们都属于同一个版本。

斯坦福解析器将根据您要求它执行的注释任务的数量输出不同的结果()。获取解析器输出所需的全部工作是句子分割、标记化和解析任务。然而,如果您同时运行句子拆分、标记化、词性标记和解析任务,您将得到不同的结果

因此,CoreNLP注释在默认情况下也将添加词性标记,从而提供与仅解析任务不同的解析结果


根据我处理解析树和两种输出形式的经验,这两种方法都不是很好。

非常感谢。我将尝试从coreNLP获取链接中给出的相同解析树。实际上,我正试图从这里给出的解析树中提取三元组。如果你遇到这个从解析树中提取三元组的用例,那么如果你能分享这些细节,那将对我有很大帮助。我对“三元组”的概念听起来有点保留,但是如果你正在寻找它们,那么你可能想要的是它的输出。它应该能够为您提供主语、动词和谓词参数。