[英]Are there any Python NLP tools to figure out how many ways a sentence can be parsed?
I want to be able to measure ambiguity of a sentence, and my current my idea to do so is by measuring how many ways a sentence can be parsed. 我希望能够衡量一个句子的歧义性,而我目前的想法是通过衡量一个句子可以解析的方式。 For example, the sentence "Fruit flies like a banana" can have to interpretations.
例如,句子“水果像香蕉一样飞”可能需要解释。
So far I have tried using the Stanford Parser, but it only interpreted each sentence in one way. 到目前为止,我已经尝试使用Stanford Parser,但它仅以一种方式解释了每个句子。 My other idea was to measure how many different parts of speech each word in a sentence could mean, but each POS tagger I found only marked each word with 1 tag even when it could be multiple.
我的另一个想法是测量一个句子中每个单词可能意味着多少个不同的词性,但是我发现每个POS标记器仅用1个标记来标记每个单词,即使它可能是多个。
Are there are tools to do either? 有没有可以做的工具?
From the Stanford Parser FAQ page , hope it helps: 希望在Stanford Parser FAQ页面上有所帮助:
Can I obtain multiple parse trees for a single input sentence?
我可以为单个输入语句获取多个分析树吗?
Yes, for the PCFG parser (only).
是的,对于PCFG解析器(仅)。 With a PCFG parser, you can give the option
-printPCFGkBest n
and it will print then
highest-scoring parses for a sentence.使用PCFG解析器,您可以给
-printPCFGkBest n
选项,它将为句子打印n
个得分最高的解析器。 They can be printed either as phrase structure trees or as typed dependencies in the usual way via the-outputFormat
option, and each receives a score (log probability).它们可以通过
-outputFormat
选项以通常的方式打印为短语结构树或类型化的依存关系,并且每一个都获得一个分数(对数概率)。 Thek
best parses are extracted efficiently using the algorithm of Huang and Chiang (2005).使用Huang和Chiang(2005)的算法可以有效地提取
k
最佳解析。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.