def DoClassify(CurClassifier, topicResultsTxt, topicTweetsLDATxt):
counter = 0
topicSentiments = dict()
topicResult = open(topicResultsTxt, 'w')
with open(topicTweetsLDATxt) as topicFile:
for line in topicFile:
if counter != 100:
tSentiment = CurClassifier.classify(extract_features(line.split()))
if tSentiment in topicSentiments.keys():
topicSentiments[tSentiment] += 1
else:
topicSentiments[tSentiment] = 1
counter += 1
else:
majorSentiment = 'Dummy'
topicSentiments[majorSentiment] = 1
for sentiKey in topicSentiments.keys():
if topicSentiments[majorSentiment] < topicSentiments[sentiKey]:
majorSentiment = sentiKey
topicResult.write(majorSentiment +'\n')
topicSentiments.clear()
counter = 0
topicResult.close()
#Extracting the features of the tweet without term frequencies with the format as needed by the classifier
评论列表
文章目录