当前位置:网站首页>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包做的还是蛮准的,感兴趣的朋友可以去学习一下。
边栏推荐
- QT:QSS自定义 QProgressBar实例
- Uni app learning 1 bottom menu and parent-child components
- Leetcode刷题---75
- QT:QSS自定义 QSlider实例
- Ut2013 learning notes
- Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported
- Buy health products for parents
- Ut2017 learning notes
- C语言项目:学生成绩系统
- [combinatorial mathematics] pigeon nest principle (simple form examples of pigeon nest Principle 4 and 5)
猜你喜欢
随机推荐
Ut2015 learning notes
Ind yff first week
Leetcode skimming ---1
多层感知机(PyTorch)
QT:QSS自定义QMenu实例
[untitled] numpy learning
MySql 怎么查出符合条件的最新的数据行?
conda9.0+py2.7+tensorflow1.8.0
QT:QSS自定义QToolButton实例
Chiyou (), a specific mythical image, is also gradually abstracted as a dramatic character type "Jing". "Jing", born in Dan Dynasty and ugly at the end, is the earliest "profession" in Chinese drama
Multilayer perceptron (pytorch)
面试官:Redis中列表的内部实现方式是什么?
Wechat applet training 2
Content type ‘application/x-www-form-urlencoded; charset=UTF-8‘ not supported
Buy health products for parents
Leetcode skimming ---10
如何在游戏中制作一个血条
帶你走進雲原生數據庫界扛把子Amazon Aurora
Numpy quick start (I) -- pre knowledge (create array + constant + data type)
logstash备份跟踪上报的数据记录









![[untitled]](/img/2b/177970366174e50e75b5c820c95d08.jpg)