samedi 28 avril 2018

Python: if elif loop [duplicate]

This question already has an answer here:

I am trying to do a sentiment analysis with twitter data. I know that the tokens in my POStagged_tweets_lines.json file are 90% neutral. My loop:

pos = "pos"
neg = "neg"
neu = "neu"
negative = 0
positive = 0
neutral = 0

if classification is neu:
    neutral += 1
elif classification is pos:
    positive += 1
elif classification is neg:
    negative += 1
print(negative, positive, neutral)

Should be counting the sentiments of the tweets in the json file. So, at the end I should be getting an output such as 5, 12, 100; but Instead I am getting 0 0 1 and I don't even know where is it coming from.

Aucun commentaire:

Enregistrer un commentaire