本文介绍了如何从nltk WordNet Python获取同义词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
WordNet很棒,但是我很难在nltk中获得同义词.如果您搜索类似于小"的单词,例如此处,它显示了全部的同义词.
WordNet is great, but I'm having a hard time getting synonyms in nltk. If you search similar to for the word 'small' like here, it shows all of the synonyms.
基本上,我只需要了解以下内容:wn.synsets('word')[i].option()
其中的选项可以是化名和反义词,但是获取同义词的选择是什么?
Basically I just need to know the following:wn.synsets('word')[i].option()
Where option can be hypernyms and antonyms, but what is the option for getting synonyms?
推荐答案
如果您想要同义词集中的同义词(也就是组成集合的引理),则可以使用lemma_names()
来获得它们:
If you want the synonyms in the synset (aka the lemmas that make up the set), you can get them with lemma_names()
:
>>> for ss in wn.synsets('small'):
>>> print(ss.name(), ss.lemma_names())
small.n.01 ['small']
small.n.02 ['small']
small.a.01 ['small', 'little']
minor.s.10 ['minor', 'modest', 'small', 'small-scale', 'pocket-size', 'pocket-sized']
little.s.03 ['little', 'small']
small.s.04 ['small']
humble.s.01 ['humble', 'low', 'lowly', 'modest', 'small']
...
这篇关于如何从nltk WordNet Python获取同义词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!