使用 Stanford Dependency Parser 进行依赖解析
Dependency Parsing using Stanford Dependency Parser
我正在尝试提取句子中的主要动词并且我遵循了这个 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)))
我想我做错了什么,我怎样才能达到预期的输出
是的,通过 找到了如何做到这一点,但它不显示根属性,这是现在唯一的问题
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], ")")
我正在尝试提取句子中的主要动词并且我遵循了这个 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)))
我想我做错了什么,我怎样才能达到预期的输出
是的,通过
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], ")")