参考资料:
词汇相似度计算
python WordNet的使用方法(整理版)
使用NLTK计算word的相似度
print('========================')
print('找出同义词集:')
print('>>>dog:')
print(wn.synsets('dog'))
print('>>>apple:')
print(wn.synsets('apple'))
print('>>>fly:')
print(wn.synsets('fly'))
print('========================')
def get_lemma_names(s1):
walk = wn.synsets(s1)
f = 0
for i in range(len(walk)):
lms = walk[i].lemma_names()
if len(lms) != 0:
print(walk[i], ": ")
print(lms)
f = 1
if f == 0:
print('None')
print('查看同义词集中的所有单词:')
print('>>>dog:'