Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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..."

like image 712
daniels Avatar asked Apr 15 '10 13:04

daniels


2 Answers

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']
like image 189
Alex Martelli Avatar answered Oct 13 '22 01:10

Alex Martelli


Update: as @deweydb has pointed out, as of Feb 10th 2022, this solution no longer works.

You can also use PyDictionary

For example,

from PyDictionary import PyDictionary 
dictionary=PyDictionary() 
print (dictionary.synonym("good"))

The output is

[u'great', u'satisfying', u'exceptional', u'positive', u'acceptable']

This is actually fetching words from www.thesaurus.com and is a little slow. Multi-threading may help accelerate it.

like image 38
Zhu Li Avatar answered Oct 13 '22 02:10

Zhu Li