【问题标题】:Dependency Parsing using Stanford Dependency Parser使用斯坦福依赖解析器进行依赖解析
【发布时间】:2018-08-10 12:09:28
【问题描述】:

我正在尝试提取句子中的主要动词,我遵循了这个question,我期待这种格式的输出

nsubj(swim-4, Parrots-1)
aux(swim-4, do-2)
neg(swim-4, not-3)
root(ROOT-0, swim-4)

但我以这种方式得到输出

[<DependencyGraph with 94 nodes>]

我关注了

  dependencyParser = stanford.StanfordDependencyParser(model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
  print (list(dependencyParser.raw_parse(noiseLessInput)))

我认为我做错了什么,我怎样才能获得所需的输出

【问题讨论】:

    标签: machine-learning nlp stanford-nlp dependency-parsing


    【解决方案1】:

    是的,通过this question找到了如何做到这一点,但它没有显示root属性,这是现在唯一的问题

      dependencyParser = stanford.StanfordDependencyParser(model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
    result = dependencyParser.raw_parse(noiseLessInput)
    dep = result.__next__()
    for triple in dep.triples():
     print(triple[1], "(", triple[0][0], ", ", triple[2][0], ")")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多