Skip to content

Instantly share code, notes, and snippets.

@Keiku
Created April 28, 2017 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Keiku/ab4efb1863fcce3cb3ac34842d8da545 to your computer and use it in GitHub Desktop.
Save Keiku/ab4efb1863fcce3cb3ac34842d8da545 to your computer and use it in GitHub Desktop.
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'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment