Python 情感分类
Python sentiment classification
您好,我正在尝试使用情感分类器 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
senti_classifier.polarity_scores()
function 需要一个 字符串列表 作为参数,但您传递的是单个字符串。放入列表:
pos_score, neg_score = senti_classifier.polarity_scores([sentences])
您好,我正在尝试使用情感分类器 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
senti_classifier.polarity_scores()
function 需要一个 字符串列表 作为参数,但您传递的是单个字符串。放入列表:
pos_score, neg_score = senti_classifier.polarity_scores([sentences])