Lexicon dictionary for synonym words

别说谁变了你拦得住时间么 提交于 2019-12-04 09:10:12
alvas

Although WordNet is a good resource to start for finding synonym, one must note its limitations, here's an example with python API in NLTK library:

Firstly, words have multiple meanings (i.e. senses):

>>> from nltk.corpus import wordnet as wn
>>> wn.synsets('nice')
[Synset('nice.n.01'), Synset('nice.a.01'), Synset('decent.s.01'), Synset('nice.s.03'), Synset('dainty.s.04'), Synset('courteous.s.01')]

And to access the correct sense of a word, you will need to know the correct sense of a word given a context.

>>> wn.synset('nice.a.01').definition()
u'pleasant or pleasing or agreeable in nature or appearance'

You can try Word Sense Disambiguation software but they are not perfect (see Anyone know of some good Word Sense Disambiguation software?). Even if you know the sense of the word, the entries of wordnet are limited. You cannot expect much:

>>> wn.synset('nice.a.01').lemma_names()
[u'nice']
>>> wn.synset('nice.a.01').similar_tos()
[Synset('good.s.06'), Synset('pleasant.s.02')]
>>> [i.lemma_names() for i in wn.synset('nice.a.01').similar_tos()]
[[u'good'], [u'pleasant']]

"WordNet® is a large lexical database of English. Nouns, verbs, adjectives and adverbs are grouped into sets of cognitive synonyms (synsets), each expressing a distinct concept.": http://wordnet.princeton.edu/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!