Skip to content

Commit

Permalink
更新 delete_sensitive_comments.py
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyRespawnanchor authored Feb 9, 2025
1 parent df233d5 commit 66ee9c4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions delete_sensitive_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@

# 获取所有敏感词并合并
def fetch_and_merge_sensitive_words(urls):
words = set() # 使用集合去重
merged_text = "" # 存储所有敏感词的文本

for url in urls:
try:
response = requests.get(url)
response.raise_for_status() # 确保请求成功
merged_text += "\n" + response.text # 合并所有文件内容
except requests.RequestException as e:
print(f"Failed to fetch sensitive words from {url}: {e}")

# 解析敏感词列表(去掉逗号、去空行、去空格)
words = set(word.strip().rstrip(",") for word in merged_text.splitlines() if word.strip())

# 解析敏感词列表
for line in merged_text.splitlines(): # 按行拆分
clean_words = [word.strip().rstrip(",") for word in line.split() if word.strip()]
words.update(clean_words) # 加入集合去重

return list(words) # 转换回列表

# 加载所有敏感词
Expand Down

0 comments on commit 66ee9c4

Please sign in to comment.