嗨,我正试图用情感分类器package.The对某些文本文件进行分类,下面的程序对一个句子很好,即,
from senti_classifier import senti_classifier
sentences = ['i love u']
pos_score, neg_score = senti_classifier.polarity_scores(sentences)
print pos_score, neg_score但是,如果使用xls文件对每条记录进行分类,其结果是正数和负数都是0.0。请帮帮我。
import openpyxl
from senti_classifier import senti_classifier
wb = openpyxl.load_workbook('sentiment2.xlsx')
sheet = wb.active
sheet.columns[0]
for cellObj in sheet.columns[0]:
sentences = cellObj.value
print(sentences)
pos_score, neg_score = senti_classifier.polarity_scores(sentences)
print pos_score, neg_score发布于 2016-07-06 00:42:26
function需要一个字符串列表作为参数,但是您要传递一个字符串。把它写在清单上:
pos_score, neg_score = senti_classifier.polarity_scores([sentences])https://stackoverflow.com/questions/38214855
复制相似问题