You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
740 B
24 lines
740 B
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)
|
|
|
|
df = pd.DataFrame(ai_danmu_most_common, columns=['弹幕', '数量'])
|
|
|
|
# 保存为Excel文件
|
|
filename = 'ai_danmu_most_common.xlsx'
|
|
df.to_excel(filename, index=False)
|
|
|
|
if __name__ == '__main__':
|
|
GetAI() |