当前位置:网站首页>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包做的还是蛮准的,感兴趣的朋友可以去学习一下。
边栏推荐
- Multilayer perceptron (pytorch)
- Day 7 small exercise
- MySQL checks for automatic updates at 0:00 every day
- 7、 Data definition language of MySQL (2)
- Content type ‘application/x-www-form-urlencoded; charset=UTF-8‘ not supported
- logstash备份跟踪上报的数据记录
- QT:QSS自定义 QTabWidget 和 QTabBar实例
- C project - dormitory management system (1)
- 6、 Data definition language of MySQL (1)
- Leetcode skimming ---278
猜你喜欢

Numpy quick start (II) -- Introduction to array (creation of array + basic operation of array)

神经网络入门之预备知识(PyTorch)

Multi-Task Feature Learning for Knowledge Graph Enhanced Recommendation

UI interface design related knowledge (I)

丢弃法Dropout(Pytorch)

深度学习入门之线性回归(PyTorch)

Detailed cross validation and grid search -- sklearn implementation

Softmax regression (pytorch)
![[roast & brain hole] Some Thoughts on the bullet screen interactive game of Wei Shu Wu Three Kingdoms when visiting station B](/img/2a/c232b83e0acbb970884148bd2aadc1.png)
[roast & brain hole] Some Thoughts on the bullet screen interactive game of Wei Shu Wu Three Kingdoms when visiting station B

Unity learning notes: personal learning project "crazy genius Edgar" error correction document
随机推荐
Ind FHL first week
Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported
Mysql--索引原理+如何使用
面试官:Redis中列表的内部实现方式是什么?
Leetcode skimming ---278
Ind yff first week
QT:QSS自定义 QTreeView实例
How does MySQL find the latest data row that meets the conditions?
项目组织战略管理
MAUI Developer Day in GCR
Leetcode skimming ---283
Automatic derivation of introduction to deep learning (pytoch)
Numpy quick start (V) -- Linear Algebra
QT:QSS自定义 QSpinBox实例
Leetcode skimming ---374
A detailed explanation of vector derivative and matrix derivative
Ut2013 learning notes
Wechat applet training 2
Model selection for neural network introduction (pytorch)
Numpy realizes the classification of iris by perceptron