综合练习

  1. 词频统计预处理
  2. 下载一首英文的歌词或文章
  3. 将所有,.?!’:等分隔符全部替换为空格
  4. 将所有大写转换为小写
  5. 生成单词列表
  6. 生成词频统计
  7. 排序
  8. 排除语法型词汇,代词、冠词、连词
  9. 输出词频最大TOP10
  10.  text="No matter how many characters are available for your password you should be sure to use every one of them. The more characters available for your password and the more you use makes it that much harder to figure out the combination. Always make use of all characters available for a strong and secure password.Personal information such as names, birthdays, nicknames, pet's names, social security numbers, and the like should never, ever, ever be used because these are way too obvious and too easy to crack. The more you avoid using things like this as your passwords, the more secure your login areas will be."
    sym=[',','.','!','?','’',':','$','%']
    word= ['a','in','of','the','to','at','it','on','and','so','his','that',
            'not','was','my','were','we','he','an','as','is','for','mr','us']
    new_text=text
    for i in range(len(sym)):
    	new_text=new_text.replace(sym[i],'')
    new_text=new_text.lower()
    text_list=new_text.split()
    d=dict(zip())
    for i in text_list:
    	d[i]=new_text.count(i)
    
    	
    for i in word:
    	if(d.get(i)!=None):
    		d.pop(i)
    
    
    new_d=sorted(d.items(),key=lambda x:x[1],reverse=True)
    for i in range(10):
    	print(new_d[i])
    

 

转载于:https://www.cnblogs.com/shadows24/p/8646043.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值