import jieba
from collections import Counter
import re
with open('xiyouji.txt', 'r', encoding='utf-8') as f:
text = f.read()
words = jieba.lcut(text)
filtered_words = []
for word in words:
if len(word) > 1 and not re.match(r'[^\w\s]', word):
filtered_words.append(word)
word_counts = Counter(filtered_words)
top_20_words = word_counts.most_common(20)
for word, count in top_20_words:
print(f"{word}: {count}")
浙公网安备 33010602011771号