我正在尝试使用此处基于 NN 的新解析器来查找句子中的所有形容词短语(例如,good
和extremely good
在The 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')
但是不清楚如何提取我需要的信息,因为这似乎不是树形结构。有人有想法吗?
目前,Python不支持您想要的选区解析。 这只是返回依赖项解析(不同类型的解析)。
您可以使用stanfordnlp
与 Java 服务器通信,并以这种方式获取选区解析。
这里有用于访问选区解析的示例代码:
https://stanfordnlp.github.io/stanfordnlp/corenlp_client.html
输出中指定的每个单词的数字索引表示调控器单词(该单词的头部)的索引。
例如,单词"Whether"
是单词"Good"
的子项(索引为 5,因为"Good"
是实际句子中的第五个单词),因此它采用其州长(头部)索引,此处为 5 ("Good"
)。
您可以从<http://corenlp.run/>
获取依赖结构表示,并根据我的描述将其与表示进行比较,以便更好地澄清。