当前位置:网站首页>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包做的还是蛮准的,感兴趣的朋友可以去学习一下。
边栏推荐
- Automatic derivation of introduction to deep learning (pytoch)
- Leetcode skimming ---374
- QT:QSS自定义 QSplitter实例
- 分组函数之rollup、cube函数、grouping sets函数
- Numpy quick start (V) -- Linear Algebra
- Iterator iterator enhances for loop
- Leetcode skimming ---217
- Model selection for neural network introduction (pytorch)
- 7、 Data definition language of MySQL (2)
- Softmax regression (pytorch)
猜你喜欢
Pytoch has been installed, but vs code still displays no module named 'torch‘
安装yolov3(Anaconda)
QT:QSS自定义QTableView实例
QT:QSS自定义 QTreeView实例
Hou Jie -- STL source code analysis notes
神经网络入门之模型选择(PyTorch)
7、 Data definition language of MySQL (2)
Unity group engineering practice project "the strongest takeaway" planning case & error correction document
Ut2014 supplementary learning notes
QT:QSS自定义 QTabWidget 和 QTabBar实例
随机推荐
QT:QSS自定义QMenu实例
丢弃法Dropout(Pytorch)
Ut2017 learning notes
Flink chain conditional source code analysis
QT:QSS自定义 QTabWidget 和 QTabBar实例
UI interface design related knowledge (I)
Wechat applet training 2
MySQL -- index principle + how to use
Bidding website architecture project progress -- Network Security
How does MySQL find the latest data row that meets the conditions?
[untitled]
Leetcode skimming ---75
[combinatorial mathematics] pigeon nest principle (simple form examples of pigeon nest Principle 4 and 5)
QT:QSS自定义QHeaderView实例
Leetcode skimming ---35
Flink--自定义函数
Numpy quick start (I) -- pre knowledge (create array + constant + data type)
QT:QSS自定义 QProgressBar实例
Softmax 回归(PyTorch)
Mysql5.7 installation and configuration tutorial (Graphic ultra detailed version)