aws情感分析教程

7rfyedvj  于 2021-06-02  发布在  Hadoop
关注(0)|答案(0)|浏览(237)

我跟随aws情绪分析教程从这里开始。
我的问题是,分类器永远找不到负面的tweet。它总是只显示积极的和中立的,

kindle: positive     492
No match:              8

数据集是使用tweepy库获得的。我使用下面的python代码作为Map器,
Map程序代码:


# !/usr/bin/python

import cPickle as pickle
import nltk.classify.util
from nltk.classify import NaiveBayesClassifier
from nltk.tokenize import word_tokenize
import sys

sys.stderr.write("Started mapper.\n");

def word_feats(words):
    return dict([(word, True) for word in words])

def subj(subjLine):
    subjgen = subjLine.lower()
    # Replace term1 with your subject term
    subj1 = "kindle"
    if subjgen.find(subj1) != -1:
        subject = subj1
        return subject
    else:
        subject = "No match"
        return subject

def main(argv):
    classifier = pickle.load(open("classifier.p", "rb"))
    for line in sys.stdin:
        tolk_posset = word_tokenize(line.rstrip())
        d = word_feats(tolk_posset)
        subjectFull = subj(line)
        if subjectFull == "No match":
            print "LongValueSum:" + " " + subjectFull + ": " + "\t" + "1"
        else:
            print "LongValueSum:" + " " + subjectFull + ": " + classifier.classify(d) + "\t" + "1"

if __name__ == "__main__":
    main(sys.argv)

我可以读取数据集上的负面tweet,但教程中的这个示例没有检测到这一点。
如何在我的程序中查找和显示负面tweet呢?这是Map程序代码或分类器文件的问题吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题