使用斯坦福依赖解析器进行依赖解析

我试图从句子中提取主要动词,并参考了这个问题,我期望的输出格式如下

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], ")")

Related Posts

Keras Dense层输入未被展平

这是我的测试代码: from keras import…

无法将分类变量输入随机森林

我有10个分类变量和3个数值变量。我在分割后直接将它们…

如何在Keras中对每个输出应用Sigmoid函数?

这是我代码的一部分。 model = Sequenti…

如何选择类概率的最佳阈值?

我的神经网络输出是一个用于多标签分类的预测类概率表: …

在Keras中使用深度学习得到不同的结果

我按照一个教程使用Keras中的深度神经网络进行文本分…

‘MatMul’操作的输入’b’类型为float32,与参数’a’的类型float64不匹配

我写了一个简单的TensorFlow代码,但不断遇到T…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注