I have a list of terms in a sentence with sentiwordnet parts-of-speech, which I am attempting to sum over to find the net sentiment:
from nltk.corpus import sentiwordnet as swn, wordnet
score = 0
for term in terms:
try:
term = swn.senti_synset(term)
except WordNetError:
pass
score += term.pos_score() - term.neg_score()
Prior to adding the exception, I was getting WordNetError due to a particular synset not being present in the dict. Having now added the exception, I am receiving this error:
NameError: name 'WordNetError' is not defined
How do I resolve this?
WordNetError
bywordnet.WordNetError
. And please, use a search engine next time, it's literally the first link. – Heinousnltk.corpus.reader.wordnet
. And yes, it can be considered rude to expect a little more research. – Heinous