网站首页 > 开源技术 正文
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from snownlp import SnowNLP
df = pd.read_excel('newpl.xlsx')
df.head()
def getsentiments(data):
s = SnowNLP(data['content'])
return s.sentiments
df['semiscore']=df.apply(lambda x:getsentiments(x),axis=1)
df['semilabel'] = df['semiscore'].apply(lambda x: 1 if x>0.5 else -1)
df
plt.hist(df['semiscore'], bins = np.arange(0, 1.01, 0.01),label='semisocre', color="#ff9999")
plt.xlabel('semiscore')
plt.ylabel('number')
plt.title('The semi-score of comment')
plt.show()
plt.savefig('1.png')
非常直观,热门视频里,绝大多数都是正面评论
gr=df['semiscore'].groupby(df['avid']).mean()
res = gr.plot.bar()
上图是前10热门视频的情感分析均值,可见视频id为74910831的评论最正面
- 上一篇: 淘宝上“飞机杯”的销量究竟有多大?
- 下一篇: 基于 Python 的网易民谣歌词数据分析
猜你喜欢
- 2024-09-12 《小美好》短评文本情感分析+生成词云
- 2024-09-12 怎么自学python,大概要多久?(自学python怎么样)
- 2024-09-12 推荐 4 个 Python 新手实战项目(python入门教程推荐)
- 2024-09-12 基于 Python 的网易民谣歌词数据分析
- 2024-09-12 淘宝上“飞机杯”的销量究竟有多大?
- 2024-09-12 教你对抓取的文本进行分词、词频统计、词云可视化和情感分析
- 2024-09-12 20行代码教会Python分析商品评价(python爬取商品评论)
- 2024-09-12 AC娘是宇宙的主宰——坛友ac娘表情使用情况分析以及些许干货
- 2024-09-12 新手怎么自学python,大概要多久?
- 2024-09-12 盘点一个英文文本中统计关键词的方法
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)