How to get synonyms from nltk WordNet Python

后端 未结 6 1290
礼貌的吻别
礼貌的吻别 2020-11-30 04:10

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.

Ba

6条回答
  •  [愿得一人]
    2020-11-30 04:27

    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']    
    ...
    

提交回复
热议问题