AffAnalys.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Data-Mining-From-Twitter 作者: N1h1l1sT 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号