当前位置:网站首页>snownlp情感分析
snownlp情感分析
2022-07-03 09:38:00 【白炎灵】
之前写过一篇博客,豆瓣短评分析,当时是拿分类问题来做的,预测的是用户给电影打的星级,其实也可以用snownlp对短评做情感分析。
情感分析就是用一些方法和技术来识别和提取原素材中的情感色彩,本篇博文主要就是介绍如何用snownlp做情感分析。
data的部分截图如下:
from snownlp import SnowNLP
import matplotlib.pyplot as plt
import numpy as np
#snownlp中sentiments表示的是这句话代表正向情感的概率。
sentimentslist = []
for i in data["short"]:
s = SnowNLP(i)
sentimentslist.append(s.sentiments)
plt.hist(sentimentslist, bins = np.arange(0, 1, 0.01), facecolor = 'g')
plt.xlabel('Sentiments Probability')
plt.ylabel('Quantity')
plt.title('Analysis of Sentiments')
plt.show()
下图是各情感分数段出现频率柱状图:
我们可以挑一些短评看下其分数:


感觉snownlp包做的还是蛮准的,感兴趣的朋友可以去学习一下。
边栏推荐
- If you always feel that you need to persist in learning English
- Content type ‘application/x-www-form-urlencoded; charset=UTF-8‘ not supported
- 8、 Transaction control language of MySQL
- extern关键字
- Bid -- service commitment -- self summary
- Unity learning notes: personal learning project "crazy genius Edgar" error correction document
- 2021-09-22
- QT:QSS自定义 QSpinBox实例
- Praise syllogism
- Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported
猜你喜欢
随机推荐
深度学习入门之线性回归(PyTorch)
Flink--自定义函数
Traversal of map set
Strategic management of project organization
EFFICIENT PROBABILISTIC LOGIC REASONING WITH GRAPH NEURAL NETWORKS
QT:QSS自定义QGroupBox实例
.Net Core-做一个微信公众号的排队系统
QT:QSS自定义QLineEdit实例
Pytoch has been installed, but vs code still displays no module named 'torch‘
Leaders always entrust the work to flattering employees
Entropy method to calculate weight
Wechat applet training 2
Mysql5.7 installation and configuration tutorial (Graphic ultra detailed version)
7、 Data definition language of MySQL (2)
Ut2014 supplementary learning notes
Leetcode skimming ---263
神经网络入门之预备知识(PyTorch)
MAUI Developer Day in GCR
Unity group engineering practice project "the strongest takeaway" planning case & error correction document
小文件专项









