如何使用StanfordNLP Python包进行依赖解析?

问题描述 投票:2回答:1

我试图在here上使用新的基于NN的解析器来查找句子中的所有形容词短语(例如,good中的extremely goodThe weather is extremely good),但是,它缺乏文档,我无法使其工作。我目前的代码是

import stanfordnlp
nlp = stanfordnlp.Pipeline()
doc = nlp("The weather is extremely good")
doc.sentences[0].print_dependencies()

这给了我

('The', '2', 'det')
('weather', '5', 'nsubj')
('is', '5', 'cop')
('extremely', '5', 'advmod')
('good', '0', 'root')

但目前尚不清楚如何提取我需要的信息,因为这似乎不是树结构。有没有人有想法?

parsing nlp stanford-nlp
1个回答
0
投票

目前,没有Python支持选区解析,这是你想要的。这只是返回依赖关系解析(一种不同类型的解析)。

您可以使用stanfordnlp与Java服务器通信,并以这种方式获取选区解析。

这里有用于访问选区分析的示例代码:

https://stanfordnlp.github.io/stanfordnlp/corenlp_client.html

© www.soinside.com 2019 - 2024. All rights reserved.