WordNet is a great reference when you want to find synonyms of a word. For more information, please see the website: http://wordnet.princeton.edu/
The following Python code is a simple example.
WordNet Interface: http://www.nltk.org/howto/wordnet.html
The following Python code is a simple example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Python 3 | |
#Find synonyms of a word | |
>>> from nltk.corpus import wordnet as wn | |
>>> syn = wn.synsets("car") | |
>>> syn | |
[Synset('car.n.01'), Synset('car.n.02'), Synset('car.n.03'), Synset('car.n.04'), Synset('cable_car.n.01')] | |
>>> syn[0].lemma_names() | |
['car', 'auto', 'automobile', 'machine', 'motorcar'] | |
#Note that synonyms are always in singular form. | |
#If you want to compare words, need to deal with the words that are in plural form. |
WordNet Interface: http://www.nltk.org/howto/wordnet.html
No comments:
Post a Comment