I have a simple python program.
from nltk.tokenize import word_tokenize
negation ='no','not','never'.split(',')
list2 = 'miss,loss,gone,give up,lost'.split(',')
sentence = 'loss money'
if any(word in list2 for word in word_tokenize(sentence)) and (any(word in
list2 for word in word_tokenize(sentence))[-1:])not in negation :
print 'sad'
else:
print 'not sad'
This make error which is
TypeError: 'bool' object has no attribute '__getitem__'
What I need here, I want to check if any word in the sentence is in the list2. If yes, then want to check its before index value is in the negation list or not. if yes it should be "not sad".
For an example "I miss him" should sad, "I not miss him" should be not sad.
Can anyone help me !