赞
踩
评论数据comments.xlsx
安装snownlp
python -m pip install snownlp -i https://pypi.tuna.tsinghua.edu.cn/simple/
from openpyxl import load_workbook
from snownlp import SnowNLP
wb1 = load_workbook("C:/Users/zhour/Documents/comments.xlsx")
ws1 = wb1.active
id=1
for row in ws1.iter_rows(min_row=1):
values = [cell.value for cell in row]
s = SnowNLP(values[0])
ws1["{}{}".format('B', id)]=s.sentiments
id+=1
wb1.save("C:/Users/zhour/Documents/commentsTag.xlsx")
标注后的数据集commentsTag.xlsx
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。