我正在尝试使用Twitter数据进行情绪分析。 我知道我的POStagged_tweets_lines.json文件中的标记是90%中立的。 我的循环:
with open('POStagged_tweets_lines.json', 'r') as f:
for line in f:
blob = TextBlob(line, classifier=classifier)
#blob = TextBlob('POStagged_tweets.json',
classification = blob.classify()
#print(classification)
pos = "pos"
neg = "neg"
neu = "neu"
negative = 0
positive = 0
neutral = 0
if classification == neu:
neutral += 1
elif classification == pos:
positive += 1
elif classification == neg:
negative += 1
print(negative, positive, neutral)
应该计算json文件中推文的情绪。所以,最后我应该得到一个输出,如5, 12, 100
;但相反,我得到0 0 1
,我甚至不知道它来自哪里。