综合练习:英文词频统计

词频统计预处理
下载一首英文的歌词或文章
将所有,.?!’:等分隔符全部替换为空格
将所有大写转换为小写
生成单词列表
生成词频统计
排序
排除语法型词汇,代词、冠词、连词
输出词频最大TOP10

 

article = '''The capital has opened 33 roads of a total length of 105 kilometers for autonomous1 car testing outside the Fifth Ring Road and away from densely-populated areas on the outskirts2.

According to regulations for managing road testing for self-driving vehicles,autonomous vehicles are eligible3 for public road testing only after they have completed 5,000 kilometers of daily driving in designated closed test fields and passed assessments4.

The test vehicles must be equipped with monitoring devices that can monitor driving behavior,collect vehicle location information and monitor whether a vehicle is in self-driving mode.

Test drivers must have received no less than 50 hours of self-driving training.

Beijing has built its first closed test fields in Haidian District, covering about 13 hectares.

The licenses6 for road testing are valid7 for 30 days and license5 holders8 can apply for renewal9 after self-driving cars pass assessments.

Baidu is developing high-resolution maps for self-driving cars. The first will be based on the 33 roads.'''




sign = ['.',',']
for i in sign:
    article = article.replace(i, '')

article = article.lower()

article = article.split()

dic = dict(zip())

for i in article:
    dic[i] = article.count(i)

delwords = ["the", "has", "of", "a", "for", "and","away","from","on","to","are","only","have","in","after"]

for i in delwords:
    del dic[i]

newarticle = sorted(dic.items(),key=lambda s:s[1],reverse=True)

for i in range(10):
    print(newarticle[i])

运行结果截图:

 

转载于:https://www.cnblogs.com/xuyizhu/p/8618512.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值