当前位置:网站首页>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包做的还是蛮准的,感兴趣的朋友可以去学习一下。
边栏推荐
- Mysql--索引原理+如何使用
- Pour vous amener dans le monde des bases de données natives du cloud
- Linear regression of introduction to deep learning (pytorch)
- Hou Jie -- STL source code analysis notes
- QT:QSS自定义 QSpinBox实例
- logstash备份跟踪上报的数据记录
- How to make a blood bar in the game
- 如何监测服务器主机的进出流量?
- MAUI Developer Day in GCR
- DAY 7 小练习
猜你喜欢
[roast & brain hole] Some Thoughts on the bullet screen interactive game of Wei Shu Wu Three Kingdoms when visiting station B
DAY 7 小练习
帶你走進雲原生數據庫界扛把子Amazon Aurora
QT:QSS自定义 QTreeView实例
Data captured
Softmax regression (pytorch)
Bidding website architecture project progress -- Network Security
The story of a 30-year-old tester struggling, even lying flat is extravagant
MySQL checks for automatic updates at 0:00 every day
Numpy quick start (II) -- Introduction to array (creation of array + basic operation of array)
随机推荐
QT:QSS自定义QMenu实例
Ind wks first week
QT:QSS自定义QGroupBox实例
Leetcode skimming ---283
MAUI Developer Day in GCR
如何在游戏中制作一个血条
Leetcode skimming ---374
Multilayer perceptron (pytorch)
Unity学习笔记:联网游戏Pixel Adventure 1学习过程&纠错心得
Detailed cross validation and grid search -- sklearn implementation
QT:QSS自定义QToolBar和QToolBox实例
Matrix calculation of Neural Network Introduction (pytoch)
conda9.0+py2.7+tensorflow1.8.0
Class-Variant Margin Normalized Softmax Loss for Deep Face Recognition
Leetcode skimming ---202
Wechat applet training 2
丢弃法Dropout(Pytorch)
QT:QSS自定义 QRadioButton实例
[combinatorial mathematics] pigeon's nest principle (simple form of pigeon's nest principle | simple form examples of pigeon's nest principle 1, 2, 3)
Uni app learning 1 bottom menu and parent-child components