首页 > 其他 > 详细

中文词频统计

时间:2017-09-29 15:46:10      阅读:270      评论:0      收藏:0      [点我收藏+]

import jieba
fo=open(‘text.txt‘,‘r‘,encoding=‘utf-8‘)
t=fo.read()
fo.close()

words=jieba.cut(t)
dic={}
for w in words:
if len(w)==1:
continue
else:
dic[w]=dic.get(w,0)+1
wc = list(dic.items())
wc.sort(key=lambda x:x[1],reverse = True)
for i in range(20):
print(wc[i])

技术分享

 

中文词频统计

原文:http://www.cnblogs.com/y550293904/p/7610952.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!