parent
ac2d3f53ff
commit
c26b35048d
@ -0,0 +1,39 @@
|
||||
from bilibili_spider import BilibiliDanmakuSpider
|
||||
from danmaku_analyzer import DanmakuAnalyzer
|
||||
from visualization import plot_views_distribution
|
||||
from wordcloud_generator import WordCloudGenerator # 导入新词云生成器
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 爬取弹幕
|
||||
spider = BilibiliDanmakuSpider()
|
||||
danmakus = spider.run()
|
||||
|
||||
if not danmakus:
|
||||
print("没有获取到任何弹幕数据,程序退出")
|
||||
exit()
|
||||
|
||||
# 分析弹幕
|
||||
analyzer = DanmakuAnalyzer(danmakus)
|
||||
all_counter, ai_counter = analyzer.count_danmakus()
|
||||
|
||||
# 输出排名前8的AI相关弹幕
|
||||
print("\nAI技术应用相关弹幕数量排名前8:")
|
||||
top8 = ai_counter.most_common(8)
|
||||
for i, (danmaku, count) in enumerate(top8, 1):
|
||||
print(f"{i}. {danmaku}: {count}次")
|
||||
|
||||
# 保存到Excel
|
||||
df = analyzer.save_to_excel(ai_counter)
|
||||
|
||||
# 生成词云 - 使用新的词云生成器
|
||||
wc_generator = WordCloudGenerator(analyzer.stopwords) # 传入停用词
|
||||
wc_generator.generate_from_texts(danmakus, filename="弹幕词云.png")
|
||||
|
||||
# 分析主流看法
|
||||
main_views = analyzer.get_main_views(ai_counter)
|
||||
print("\nB站用户对大语言模型技术的主流看法统计:")
|
||||
for view, count in main_views.items():
|
||||
print(f"{view}: {count}条相关弹幕")
|
||||
|
||||
# 可视化主流看法
|
||||
plot_views_distribution(main_views)
|
||||
Loading…
Reference in new issue