我是靠谱客的博主 激动毛衣,这篇文章主要介绍python 文档英文词频统计,现在分享给大家,希望可以做个参考。

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 文档英文词频统计的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(142)

评论列表共有 0 条评论

立即
投稿
返回
顶部