开发者

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

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

开发者_高级运维

Closed last year.

The community reviewed whether to reopen this question 10 months ago and left it closed:

Not suitable for this site We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Improve this question

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜