如何在wordnet层次结构中使用python nltk查找两个synset之间的距离?

2024-10-01 22:40:51 发布

您现在位置:Python中文网/ 问答频道 /正文

假设我有两个synset synset(car.n.01')和synset('bank.n.01'),如果我想在wordnet层次结构中找到这两个synset之间的距离,那么如何使用nltk呢?
我在网上搜索,但我得到了类似的算法,如lin、resnik、jcn等,这些算法不是我问题的解决方案。
请帮我解决这个问题。


Tags: 算法距离层次结构解决方案carwordnetbanklin
2条回答

来自this

路径相似度、wup_相似度和lch_相似度,所有这些都应该有效,因为它们基于Wordnet层次结构中两个synset之间的距离。

dog = wn.synset('dog.n.01')
cat = wn.synset('cat.n.01')

dog.path_similarity(cat)

dog.lch_similarity(cat)

dog.wup_similarity(cat)


来自同一链接(相关部分以粗体显示)

synset1.路径相似性(synset2):

Return a score denoting how similar two word senses are, based on the shortest path that connects the senses in the is-a (hypernym/hypnoym) taxonomy. The score is in the range 0 to 1, except in those cases where a path cannot be found (will only be true for verbs as there are many distinct verb taxonomies), in which case -1 is returned. A score of 1 represents identity i.e. comparing a sense with itself will return 1.


synset1.lch_相似性(synset2),Leacock Chodorow相似性:

Return a score denoting how similar two word senses are, based on the shortest path that connects the senses (as above) and the maximum depth of the taxonomy in which the senses occur. The relationship is given as -log(p/2d) where p is the shortest path length and d the taxonomy depth.


synset1.wup_相似性(synset2),Wu-Palmer相似性:

Return a score denoting how similar two word senses are, based on the depth of the two senses in the taxonomy and that of their Least Common Subsumer (most specific ancestor node). Note that at this time the scores given do not always agree with those given by Pedersen's Perl implementation of Wordnet Similarity.

此外,您还可以查看chatterbot实现。

"chatterbot comparison class"

你会在那个文件中找到更多的距离处理

相关问题 更多 >

    热门问题