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.
来自this
路径相似度、wup_相似度和lch_相似度,所有这些都应该有效,因为它们基于Wordnet层次结构中两个synset之间的距离。
来自同一链接(相关部分以粗体显示)
synset1.路径相似性(synset2):
synset1.lch_相似性(synset2),Leacock Chodorow相似性:
synset1.wup_相似性(synset2),Wu-Palmer相似性:
此外,您还可以查看chatterbot实现。
"chatterbot comparison class"
你会在那个文件中找到更多的距离处理
相关问题 更多 >
编程相关推荐