import re, collections
#找到所有的单词
def words(text): return re.findall('[a-z]+', text.lower())
def train(features):
model = collections.defaultdict(lambda: 1)
for f in features:
model[f] += 1
return model
NWORDS = train(words(open('big.txt').read()))
python 文档英文词频统计
最新推荐文章于 2024-02-28 10:26:42 发布