基本和增强的依赖性在斯坦福大学的依赖性中给出了不同的结果



我正在使用corenlp的依赖性解析作为我的项目。特定依赖性的基本和增强的依赖性是不同的结果。我使用以下代码获得增强的依赖项。

val lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
lp.setOptionFlags("-maxLength", "80")
val rawWords = edu.stanford.nlp.ling.Sentence.toCoreLabelList(tokens_arr:_*)
val parse = lp.apply(rawWords)
val tlp = new PennTreebankLanguagePack()
val gsf:GrammaticalStructureFactory = tlp.grammaticalStructureFactory()
val gs:GrammaticalStructure = gsf.newGrammaticalStructure(parse)
val tdl = gs.typedDependenciesCCprocessed()

在以下示例中,

Account name of ramkumar.

我使用简单的API获取基本依赖项。我之间的依赖性(帐户,名称)为(复合)。但是,当我使用上述代码获得增强的依赖关系时,我会得到(帐户,名称)为(dobj)之间的关系。

这是什么解决方案?这是一个错误还是我做错了什么?

当我运行此命令时:

java -Xmx8g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse -file example.txt -outputFormat json

在文件example.txt中的示例文本中,我将compound视为两种依赖类型的两个单词之间的关系。

我还尝试了simple API并获得了相同的结果。

您可以看到simple使用此代码产生的内容:

package edu.stanford.nlp.examples;
import edu.stanford.nlp.semgraph.SemanticGraphFactory;
import edu.stanford.nlp.simple.*;
import java.util.*;
public class SimpleDepParserExample {
  public static void main(String[] args) {
    Sentence sent = new Sentence("...example text...");
    Properties props = new Properties();
    // use sent.dependencyGraph() or sent.dependencyGraph(props, SemanticGraphFactory.Mode.ENHANCED) to see enhanced dependencies
    System.out.println(sent.dependencyGraph(props, SemanticGraphFactory.Mode.BASIC));
  }
}

我对斯坦福·科伦普(Stanford Corenlp)的Scala界面一无所知。我还应该指出,我的结果是使用GitHub的最新代码,尽管我认为Stanford Corenlp 3.8.0也会产生类似的结果。如果您使用的是旧版本的斯坦福·科伦普(Stanford Corenlp),这可能是错误的原因。

但是使用Java以各种方式运行此示例,我看不到您遇到的问题。

最新更新