From d1d6817279301df00acd12752dd941658d144116 Mon Sep 17 00:00:00 2001 From: p2fx74kt6 <2671606322@qq.com> Date: Wed, 18 Sep 2024 20:55:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=9B=E9=80=89AI=E7=9B=B8=E5=85=B3=E4=B9=8B?= =?UTF-8?q?=E5=BC=B9=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Get_AI_Danmaku.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Get_AI_Danmaku.py diff --git a/Get_AI_Danmaku.py b/Get_AI_Danmaku.py new file mode 100644 index 0000000..14d2455 --- /dev/null +++ b/Get_AI_Danmaku.py @@ -0,0 +1,26 @@ +import re +import pandas as pd +from collections import Counter + +keywords = [ + r"\bAI\b", "人工智能", r"\bai\b", "大模型", "ai视频", "AI视频", "AI配音", "ai配音", "AI作图", "ai图片", "自动生成", "生成", "ai生成", "AI生成", "大数据", "深度学习" + ] + +with open("danmu.txt", 'r', encoding='utf-8') as f: + danmu_list = f.readlines() + +#筛选符合关键词的弹幕 +pattern = re.compile(r'|'.join(keywords)) +filtered_danmu = [danmu for danmu in danmu_list if pattern.search(danmu)] + +#统计数量 +danmu_counter = Counter(filtered_danmu) + +# 获取数量排名前8的弹幕 +top_danmu = danmu_counter.most_common(8) + +# 将结果写入Excel文档 +df = pd.DataFrame(top_danmu, columns=['弹幕内容', '数量']) +df.to_excel('top_AI_danmu.xlsx', index=False) + +print("处理完成,结果已写入文件。") \ No newline at end of file