使用Python工具库SnowNLP对评论数据进行情感标注
评论数据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
原文地址:https://blog.csdn.net/zhourongxiang1/article/details/137852680
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!