nltk查找两个同义词集之间的距离

nltk查找两个同义词集之间的距离

本文介绍了如何在Wordnet层次结构中使用python nltk查找两个同义词集之间的距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个同义词集synset(car.n.01')和synset('bank.n.01'),如果我想在wordnet层次结构中找到这两个同义词集之间的距离,该如何使用nltk?
我在互联网上进行搜索,但是我得到了类似lin,resnik,jcn等的相似算法,这些算法无法解决我的问题.
请帮我解决这个问题.

Suppose I have two synsets synset(car.n.01') and synset('bank.n.01') and If I want to find the distance between these two synset in wordnet hierarchy then How can I do it using nltk?
I searched on internet but I am getting similarity algorithms like lin,resnik,jcn etc which are not solution for my question.
Please help me to solve this problem.

推荐答案

来自

路径相似性,wup_similarity和lch_similarity ,所有这些都应该起作用,因为它们基于Wordnet层次结构中两个同义词集之间的距离.

Path similarity, wup_similarity and lch_similarity, all of these should work since they are based on the distance between two synsets in the Wordnet hierarchy.

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

dog.path_similarity(cat)

dog.lch_similarity(cat)

dog.wup_similarity(cat)


在同一链接中,(相关部分以粗体显示)


From the same link, (relevant portions in bold)

synset1.path_similarity(synset2):


synset1.lch_similarity(synset2),Leacock-Chodorow相似度:


synset1.wup_similarity(synset2),Wu-Palmer相似度:

这篇关于如何在Wordnet层次结构中使用python nltk查找两个同义词集之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 05:59