문제

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

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top