Keiku
4/28/2017 - 7:04 AM

Extract the synonyms by using wordnet.

Extract the synonyms by using wordnet.

from itertools import chain
from nltk.corpus import wordnet

synonyms = wordnet.synsets('change')
lemmas = set(chain.from_iterable([word.lemma_names() for word in synonyms]))
lemmas
# Out[31]:
# {'alter',
#  'alteration',
#  'change',
#  'commute',
#  'convert',
#  'deepen',
#  'exchange',
#  'interchange',
#  'modification',
#  'modify',
#  'shift',
#  'switch',
#  'transfer',
#  'variety',
#  'vary'}