博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
中文词频统计
阅读量:4544 次
发布时间:2019-06-08

本文共 426 字,大约阅读时间需要 1 分钟。

import jiebafo = open('dopo.txt','r',encoding='utf-8').read()words = list(jieba.cut(fo))#取exp={
',','。','!','?','?'}#列出没用的字段keys=set(words)-exp #从获取的文字中删去无用的字段dic={} #创建字典for w in keys: if len(w)>1: dic[w]=words.count[w]wc = list(dic.items()) #字典元组的列表wc.sort(key= lambda x:x[1],reverse=True) #列表排序for i in range(20): #输出top20元组 print(wc[i])

转载于:https://www.cnblogs.com/blackboardf/p/7610342.html

你可能感兴趣的文章
E20170624-ts
查看>>
linux shell实现随机数多种方法(date,random,uuid)
查看>>
页面上有tab,如何点击加载更多?
查看>>
bash shell笔记1 脚本基础知识
查看>>
html dl dt dd标签元素语法结构与使用
查看>>
OC单元测试框架-----Google开源单元测试框架Google Test(gtest)
查看>>
QLineEdit IP地址校验
查看>>
Using Bing Search Service over SOAP Protocol in an ASP.NET Web Application
查看>>
2016年秋季-《UML大战需求分析》-个人阅读计划
查看>>
cocos2d-x多线程解析域名
查看>>
LeetCode:Verify Preorder Serialization of a Binary Tree
查看>>
4_something
查看>>
ACM数论之旅12---康托展开((*゚▽゚*)装甲展开,主推进器启动,倒计时3,2,1......)...
查看>>
使用WebHelper调用Asp.net WebAPI
查看>>
磁盘创建
查看>>
linux发行版
查看>>
如何求解灰度共生矩阵
查看>>
Vue Router的官方示例改造
查看>>
算法第5章上机实践报告
查看>>
css 断行省略号,隐藏,fixed定位
查看>>