Is there any lib for python that will get me the synonyms of a word?

daniels picture daniels · Apr 15, 2010 · Viewed 8.9k times · Source

Is there any api/lib for python that will get me the synonyms of a word?

For example if i have the word "house" it will return "building, domicile, mansion, etc..."

Answer

Alex Martelli picture Alex Martelli · Apr 15, 2010

NLTK and Wordnet can help: e.g., per this article,

from nltk.corpus import wordnet

dog = wordnet.synset('dog.n.01')
print(dog.lemma_names())

prints:

['dog', 'domestic_dog', 'Canis_familiaris']