编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

B 站鬼畜区热门评论情感分析(b站鬼畜区热度)

wxchong 2024-09-12 21:57:30 开源技术 9 ℃ 0 评论
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的评论最正面

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表