【问题标题】:Why are the dependencies different from the online demo?为什么依赖与在线演示不同?
【发布时间】:2015-12-08 14:34:32
【问题描述】:

给出下面的句子:

我的狗也喜欢吃香肠。

online demo 产生以下关系:

nmod:poss(dog-2, My-1)
nsubj(likes-4, dog-2)
advmod(likes-4, also-3)
root(ROOT-0, likes-4)
xcomp(likes-4, eating-5)
dobj(eating-5, sausage-6)

但是,我的代码也使用了通用依赖项 (UD),但会产生不同的结果:

nmod:poss(dog-2, My-1)
nsubj(likes-4, dog-2)
advmod(likes-4, also-3)
root(ROOT-0, likes-4)
amod(sausage-6, eating-5)
dobj(likes-4, sausage-6)
punct(likes-4, .-7)

这是我的代码:

String sentence = "My dog also likes eating sausage.";
MaxentTagger tagger = new MaxentTagger("edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger");
DependencyParser parser = DependencyParser.loadFromModelFile("edu/stanford/nlp/models/parser/nndep/english_UD.gz");

DocumentPreprocessor preprocessor = new DocumentPreprocessor(new StringReader(sentence));
for (List<HasWord> s: preprocessor) {
    List<TaggedWord> taggedWords = tagger.tagSentence(s);
    GrammaticalStructure gs = parser.predict(taggedWords);
    for (TypedDependency d: gs.typedDependencies()) {
        System.out.println(d);
    }
}

使用typedDependenciesCCprocessedtypedDependenciesCollapsedtypedDependenciesCollapsedTree 将产生相同的结果。

如何获得与演示完全相同的关系?

【问题讨论】:

    标签: stanford-nlp


    【解决方案1】:

    在线演示正在使用选区解析器并将其转换为依赖项。您链接的代码使用神经网络依赖解析器。预计这些会有所不同。要获得演示的输出,您应该运行 Stanford Parser:http://nlp.stanford.edu/software/lex-parser.shtml。对于 CoreNLP,这意味着使用注释器 tokenize,ssplit,parse 运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-03
      • 2020-11-19
      • 2020-03-20
      • 2018-04-25
      • 1970-01-01
      • 2017-04-22
      • 1970-01-01
      相关资源
      最近更新 更多