综合练习:英文词频统计
综合练习:英文词频统计
下载一首英文的歌词或文章
sing = ''' i'm just a little bit caught in the middle life is a maze and love is a riddle i don't know where to go can't do it alone i've tried but i don't know why slow it down make it stop or else my heart is going to pop cause its to much yea its alot to be something i'm not i'm a fool out of love cause i just can't get enough i'm just a little bit caught in the middle life is a maze and love is a riddle i don't know where to go can't do it alone i've tride but i don't know why i'm just a little girl lost in the moment i'm so scared but i don't show it i can't figure it out it's bringing me down i know i've got to let it go and just enjoy the show the sun is hot in the sky just like a giant spot light the people follow the signs and sicronise in time it's just no body knows they got to take it to the show i'm just a little bit caught in the middle life is a maze and love is a riddle i don't know where to go can't do it alone i've tried but i don't know why i'm just a little girl lost in the moment i'm so scared but i don't show it i can't figure it out it's bringing me down i know i've got to let it go and just enjoy the show just engoy the show i'm just a little bit caught in the middle life is a maze and love is a riddle i don't know where to go can't do it alone i've tride but i don't know why i'm just a little girl lost in the moment i'm so scared but i don't show it i can't figure it out it's bringing me down i know i've got to let it go and just enjoy the show just enjoy the show just enjoy the show i want my money back i want my money back i want my money back just enjoy the show i want my money back i want my money back i want my money back just enjoy the show '''
1.将所有,.?!’:等分隔符全部替换为空格
newSing = sing.replace("'"," ").replace("."," ").replace("?"," ").replace("\n"," ") print(newSing)
2.将所有小写转换为大写
newSmall = newSing.upper() print(newSmall)
3.生成单词列表
listWord = newSing.replace("\\"," ").split(" ") print(listWord)
4.生成词频统计
DicWord ={} for word in listWord:if word in DicWord.keys():DicWord[word] +=1else:DicWord[word] =1 print(DicWord)
5.排序
Dec = sorted(DicWord.keys()) print(Dec)
6.排除语法型词汇,代词、冠词、连词
vocalbuary = ["a","so","the","they","is","in","to","of","i"] for word in vocalbuary:del DicWord[word] print(DicWord)
7.输出词频最大TOP10
NewDicWord = sorted(DicWord.items(),key=lambda item:item[1],reverse=True) print(NewDicWord)for word in range(10):print(NewDicWord[word])
做了许多,很多都是查阅网上的一些资料,其实也是加深自己的一个基础牢固程度吧~
转载于:https://www.cnblogs.com/qazwsx833/p/8619743.html
综合练习:英文词频统计相关推荐
- Hadoop的改进实验(中文分词词频统计及英文词频统计)(1/4)
声明: 1)本文由我bitpeach原创撰写,转载时请注明出处,侵权必究. 2)本小实验工作环境为Windows系统下的百度云(联网),和Ubuntu系统的hadoop1-2-1(自己提前配好).如不 ...
- 字符串操作、文件操作,英文词频统计预处理
1.字符串操作: 解析身份证号:生日.性别.出生地等 凯撒密码编码与解码 网址观察与批量生成 (1)解析身份证: 编译结果: (2)凯撒密码编码与解码 编译结果: 2.英文词频统计预处理 下载一首英文 ...
- 【作业】组合数据类型练习,英文词频统计实例
1.列表实例:由字符串创建一个作业评分列表,做增删改查询统计遍历操作.例如,查询第一个3分的下标,统计1分的同学有多少个,3分的同学有多少个等. 1 score = list('012332211') ...
- 组合数据类型练习,英文词频统计实例9-21
1.列表实例:由字符串创建一个作业评分列表,做增删改查询统计遍历操作.例如,查询第一个3分的下标,统计1分的同学有多少个,3分的同学有多少个等. >>>score=list('212 ...
- 组合数据类型练习,英文词频统计实例上(2017.9.22)
字典实例:建立学生学号成绩字典,做增删改查遍历操作. sno=['33号','34号','35号','36号'] grade=[100,90,80,120] d={'33号':100,'34号':90 ...
- Hadoop的改进实验(中文分词词频统计及英文词频统计)(4/4)
声明: 1)本文由我bitpeach原创撰写,转载时请注明出处,侵权必究. 2)本小实验工作环境为Windows系统下的百度云(联网),和Ubuntu系统的hadoop1-2-1(自己提前配好).如不 ...
- 组合数据类型,英文词频统计
练习: 1.总结列表,元组,字典,集合的联系与区别. 列表 [,] 有序,可变,值可以重复 元组(,) 有序,不可修改,不可重复 集合可以用set()函数或者{}创建 用,分隔,不可有重复元素,是无序 ...
- 字符串、文件操作,英文词频统计预处理
作业要求来源:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE2/homework/2646 1.解析身份证号码 源代码 citizenID = input( ...
- 组合数据类型练习,英文词频统计实例上
1.name=['陈楠芸','陈文琪','刘书签','杨必须'] scores=[7,6,6,5] d={'陈楠芸':7,'陈文琪':6,'刘书签':6,'杨必须':5} print(d) #增加 d ...
最新文章
- spring 学习—spring的相关概念(01)
- auto-sklearn详解
- oracel 中序列
- java泛型 例子_关于 Java 泛型的一些有趣的例子
- 使用K-S检验一个数列是否服从正态分布、两个数列是否服从相同的分布(转载+自己笔记)
- HBase之Table.put客户端流程(续)
- php sphinx 查询,php-Sphinx RT索引和SphinxQL查询
- 服务器导流板的作用,前保险杠下导流板的作用是什么?
- Atiitt 使用java语言编写sql函数或存储过程
- 泛微OA设置系统默认水印
- Fall 2020 Berkeley cs61a hw04答案
- matlab声明全局变量 global
- 10个常见的python面试问题
- 一键修改手机DNS的bat文件
- 排列组合Cnm的求法
- 卧底“刷量”卖家,有关微信公众号“刷量”的五个劲爆事实
- uni-app从创建到运行到微信开发者工具
- 【英语词组】恋恋不忘Day 3-3
- Alphapose论文代码详解
- iOS开发技巧--iOS app 上架(2016年10月底)以及版本迭代上架
热门文章
- 小尺寸android 手机推荐,2021小屏手机不知道怎么买?三款小屏手机推荐
- 数据分析案例:全球星巴克数量统计
- 公众号1200篇文章分类和索引
- Unity Hub 自定义一个创建新项目模板(Template)
- 只有你的行动,才是这些问题的答案
- python储物柜难题_这些省空间的家具设计,让你的小家变大不再是难题|附收纳整理小技巧...
- 3D/VR游戏制作软件GameStudio简介
- java从零开始系统性学习完整超全资源+笔记(还在更新中)
- 哈尔滨理工大学软件与微电子学院程序设计竞赛(19级新生赛)——题解
- cbuilder6 不用客户端oracle直连,Client端不安裝Oracle而用PowerBuilder直連的方法-数据库专栏,ORACLE...