machine-learning - 使用斯坦福依赖解析器进行依赖解析
问题描述
我试图在一个句子中提取主要动词,我跟着这个问题,我期待这种格式的输出
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], ")")
推荐阅读
- ruby - 在 cron 中运行 bundle exec rake 找不到特定版本的 rake
- c++ - c++ 赋值运算符助手
- ios - 将字符串保存在一个地方的最佳实践
- typescript - 量角器打字稿从元素列表中找到第一个元素
- api - 只需传递 forUsername 参数,所有详细信息将从 youtube api 获得
- rxjs - 角度和 RxJS/switchMap
- cmd - 在 PowerShell 中使用 forfiles 将文件移动到名称中包含多个单词的文件夹时遇到问题
- google-cloud-platform - 无法从 GCP 控制台加载计算引擎
- javascript - HighCharts Orgcharts 可滚动容器
- python - 获取表格行文本 python selenium