Reputation: 281
An increment could not be made on the corresponding values of the dictionary elements
sentiment_words = {}
for word in TotalVector:
if not word in sentiment_words:
sentiment_words[word]=(0,0,0)
#sentiment_word(positive,negative,neutral)
if ispositive(word):
sentiment_words[word][0] += 1
elif isnegative(word):
sentiment_words[word][1] += 1
elif isneutral(word):
sentiment_words[word][2] += 1
print sentiment_words
Upvotes: 0
Views: 2083
Reputation: 44444
Python tuples
are immutable. Use list
instead. Like:
sentiment_words[word]=[0,0,0]
And then convert to tuples:
sentiment_words = tuple(sentiment_words)
Upvotes: 6