Is there any way to detect if a given word is noun or not using nltk wordnet?Also i want to extract the particular word's meaning alone.How to do it?
To detect if a word is a noun or not try this.
from nltk.corpus import wordnet as wn
from nltk.corpus.reader import NOUN
#this gives a synsets list of empty length, since there is no noun corresponding to 'propose'
synsets = wn.synsets('propose', NOUN)
if synsets.length == 0 :
print ' We found a pure NOUN'
#this will give you a non empty synset list since 'iron' can be a NOUN too.
synsets = wn.synsets('iron',NOUN)
if synsets.length > 0 :
print 'Iron is also a noun other than verb'
In order to solve the second part - a word may have many meanings, you would want to define clearly what your meaning is - there are various relations between words such as hypernymy, holonymy, hyponymy, synonym etc.
Also finding a meaning that is closest in meaning to a given word, you may need to find the similarity between a word and each of it's synsets and pick up the one with the highest value. refer to LCH similarity and JCN similarity modules within Wordnet for more information on this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With