WordNet is a word reference of English, like a conventional thesaurus NLTK incorporates the English WordNet. We can utilize it as a source of perspective for getting the significance of words, utilization model and definition. An assortment of comparable words is called lemmas. The words in WordNet are coordinated and hubs and edges where the hubs address the word text and the edges address the relations between the words. underneath we will perceive how we can utilize the WordNet module.
All Lemmas
from nltk.corpus import wordnet as wn
res=wn.synset('locomotive.n.01').lemma_names()
print res
At the point when we run the above program, we get the accompanying yield −
[u'locomotive', u'engine', u'locomotive_engine', u'railway_locomotive']
Word Definition
The word reference meaning of a word can be gotten by utilizing the definition work. It portrays the significance of the word as we can discover in an ordinary word reference.
from nltk.corpus import wordnet as wn
resdef = wn.synset('ocean.n.01').definition()
print resdef
At the point when we run the above program, we get the accompanying yield − an enormous waterway establishing a key piece of the hydrosphere
Read Our Latest Blog: Python Numbers
Use Examples
We can get the model sentences showing some use instances of the words utilizing the exmaples() work.
from nltk.corpus import wordnet as wn
res_exm = wn.synset('good.n.01').examples()
print res_exm
At the point when we run the above program, we get the accompanying yield −
['for your own great', "what's the benefit of worrying?"]
Inverse Words
Get All the contrary words by utilizing the antonym work.
from nltk.corpus import wordnet as wn
# get every one of the antonyms
res_a = wn.lemma('horizontal.a.01.horizontal').antonyms()
print res_a
At the point when we run the above program we get the accompanying yield −
[Lemma('inclined.a.02.inclined'), Lemma('vertical.a.01.vertical')]
Read Full Article Here: Python - WordNet Interface
Comments
Post a Comment