采用nlp字典分析的方法

import pandas as pd
from snownlp import SnowNLP
from snownlp import sentiment
import matplotlib.pyplot as plt

df=pd.read_csv('D:\\毕设相关\\评论.csv',header=None,usecols=[7])

contents=df.values.tolist()
print(len(contents))
score=[]

for contents in contents:
try:
s=SnowNLP(contents[0])
score.append(s.sentiments)
except:
print("something is wrong")
score.append(0.5)
print(len(score))
data2=pd.DataFrame(score)
data2.to_csv('sentiment.csv',header=False,index=False,mode='a+')


最后得到的结果集

情感分析_结果集


 对比原评论

情感分析_结果集_02


 只能说还行好评超过0.5,差评低于0.5,判断不出来的就按中立值0.5算,不影响最后结果

大体上还可以