From 7baa620aefb39d8c2a5b14ffb1fdd1e57bed311b Mon Sep 17 00:00:00 2001 From: phmycqkit <656078035@qq.com> Date: Wed, 18 Sep 2024 19:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1AI=E6=8A=80=E6=9C=AF=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E9=9D=A2=E7=9A=84=E6=AF=8F=E7=A7=8D=E5=BC=B9?= =?UTF-8?q?=E5=B9=95=E6=95=B0=E9=87=8F=EF=BC=8C=E5=B9=B6=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E6=8E=92=E5=90=8D=E5=89=8D8=E7=9A=84?= =?UTF-8?q?=E5=BC=B9=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GetAI.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 GetAI.py diff --git a/GetAI.py b/GetAI.py new file mode 100644 index 0000000..e94dcd4 --- /dev/null +++ b/GetAI.py @@ -0,0 +1,28 @@ +import pandas as pd +from collections import Counter + +def GetAI(): + # 读取弹幕文件 + with open('danmu.csv', 'r', encoding='utf-8-sig') as f: + danmus = f.readlines() + + # 筛选与AI技术应用相关的弹幕 + keywords = ['ai','Ai','AI'] + ai_danmu = [danmu for danmu in danmus if any(keyword in danmu for keyword in keywords)] + + # 统计弹幕数量 + ai_danmu_counter = Counter(ai_danmu) + ai_danmu_most_common = ai_danmu_counter.most_common(8) + ai_danmu_all = ai_danmu_counter.most_common(100) + + # 保存为Excel文件 + df = pd.DataFrame(ai_danmu_most_common, columns=['弹幕', '数量']) + filename = 'ai_danmu_most_common.xlsx' + df.to_excel(filename, index=False) + + df = pd.DataFrame(ai_danmu_all, columns=['弹幕', '数量']) + filename = 'ai_danmu.xlsx' + df.to_excel(filename, index=False) + +if __name__ == '__main__': + GetAI() \ No newline at end of file