World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Download our e-book of Introduction To Python
4.5 (1,292 Ratings)
559 Learners
Neha Kumawat
2 years ago
from nltk.corpus import wordnet
#to install the missing module
import nltk
nltk.download('wordnet')
from nltk.corpus import wordnet as wn
lemma_words=wn.synset('pawl.n.01').lemma_names()
print(lemma_words)
[nltk_data] Downloading package wordnet to /root/nltk_data...
[nltk_data] Unzipping corpora/wordnet.zip.
['pawl', 'detent', 'click', 'dog']
from nltk.corpus import wordnet as wn
print("Synset Meaning: ",wn.synset('pawl.n.01').definition())
Synset Meaning: a hinged catch that fits into a notch of a ratchet to move a wheel forward or prevent it from moving backward
from nltk.corpus import wordnet as wn
res_exm = wn.synset('dog.n.03').examples()
print ('Synset example :',res_exm)
Synset example :['you lucky dog']
from nltk.corpus import wordnet as wn
# get all the antonyms
res_a = wn.lemma('horizontal.a.01.horizontal').antonyms()
print ("opposite Words: ",res_a)
opposite Words: [Lemma('inclined.a.02.inclined'), Lemma('vertical.a.01.vertical')]