python中利用jieba库统计词频,counts[word] = counts.get(word,0)+1的使用
import jieba txt = open("阿甘正传-网络版.txt","r",encoding ="utf-8").read()words = jieba.lcut(txt) #用jieba库对文本进行中文分词,输出可能的分词的精确模式counts ={} #新建一个空字典for word in words: if len(w...
原创
2019-03-18 21:33:31 ·
18665 阅读 ·
10 评论