首页 > 其他 > 详细

中文词频统计

时间:2018-03-27 23:24:34      阅读:224      评论:0      收藏:0      [点我收藏+]
#coding=utf--8
import jieba
exclude={,,,,\u3000,\n,","",,?}
txt=open(doupo.txt,r).read()
wordList=list(jieba.cut(txt))
wordSet=set(wordList)-exclude
wordDict={}
for w in wordSet:
    wordDict[w]=wordList.count(w)
dictList=list(wordDict.items())
dictList.sort(key=lambda x:x[1],reverse=True)
for i in range(20):
    print (dictList[i])

 

中文词频统计

原文:https://www.cnblogs.com/swxvico/p/8660858.html

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