From 6034af79082b616b2aa54127ed67174c4eb431a1 Mon Sep 17 00:00:00 2001 From: piw4f8lbj <1836196924@qq.com> Date: Wed, 18 Sep 2024 18:02:09 +0800 Subject: [PATCH] ADD file via upload --- count.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 count.py diff --git a/count.py b/count.py new file mode 100644 index 0000000..fa99851 --- /dev/null +++ b/count.py @@ -0,0 +1,43 @@ +import os +import re +from collections import Counter +import pandas as pd + + + + + + + +def read_danmu_files(directory): + danmu_data = [] + for filename in os.listdir(directory): + if filename.endswith('paris_olympics_danmak.txt'): + with open(os.path.join(directory, filename), 'r', encoding='utf-8') as file: + danmu_data.extend(file.readlines()) + return danmu_data + +def count_danmu(): + danmu_data = read_danmu_files('./') # 当前目录下 + + ai_danmaku = [danmaku for danmaku in danmu_data if + re.search(r'(?