标签:ges int 分享 logs .so rds image 编码 range
中文分词
import jieba txt=open(‘11处特工皇妃.txt‘,‘r‘,encoding=‘utf-8‘).read() words=list(jieba.cut(txt)) exp={‘ ‘,‘,‘,‘。‘,‘”‘,‘“‘,‘:‘,‘\n‘,‘?‘,‘?‘,‘!‘,‘来‘,‘对‘,‘又‘,‘吗‘,‘很‘,‘一‘,‘下‘,‘会‘,‘道‘,‘要‘,‘而‘,‘还‘,‘将‘,‘被‘,‘去‘,‘说‘,‘那‘,‘这‘,‘的‘,‘你‘,‘我‘,‘他‘,‘啊‘,‘哦‘,‘了‘,‘在‘,‘是‘,‘她‘,‘着‘,‘就‘,‘也‘,‘都‘,‘人‘,‘不‘,‘上‘,‘和‘,‘有‘,‘却‘} keys=set(words) keys=keys-exp dic={} for w in keys: dic[w]=words.count(w) wc=list(dic.items()) wc.sort(key=lambda x:x[1],reverse=True) for i in range(20): print(wc[i])
标签:ges int 分享 logs .so rds image 编码 range
原文地址:http://www.cnblogs.com/JUNJUNER/p/7612725.html