zoukankan      html  css  js  c++  java
  • 综合练习:词频统计

    word='''
    Well I wonder could it be
      When I was dreaming about you baby
      You were dreaming of me
      Call me crazy
      Call me blind
      To still be suffering is stupid after all of this time
      Did I lose my love to someone better
      And does she love you like I do
      I do, you know I really really do
      Well hey
      So much I need to say
      Been lonely since the day
      The day you went away
      So sad but true
      For me there's only you
      Been crying since the day
      the day you went away
      I remember date and time
      September twenty second
      Sunday twenty five after nine
      In the doorway with your case
      No longer shouting at each other
      There were tears on our faces
      And we were letting go of something special
      Something we'll never have again
      I know, I guess I really really know
      Why do we never know what we've got till it's gone
      How could I carry on the day you went away
      Cause I've been missing you so much I have to say
      just one last dance
    '''
    symbol=[",",";",".","!","?","'",":","-"]
    words=['t','ve','s','ll']
    new_art=word
    for i in range(len(symbol)):
        new_art=new_art.replace(symbol[i],'')
    
    new_art=new_art.lower()
    art_list=new_art.split()
    
    dic = dict(zip())
    for i in art_list:
        dic[i] = new_art.count(i)
    
    for i in words:
        if(dic.get(i)!=None):
            dic.pop(i)
    
    new_dic = sorted(dic.items(),key=lambda x:x[1],reverse = True)
    for i in range(20):
        print(new_dic[i])

  • 相关阅读:
    C# 上传图片前判断上传图片的宽和高
    PHP调用WebService
    js判断输入字符串长度(汉字算两个字符,字母数字算一个)
    js 验证电话号 座机及手机号
    C# 微信扫码支付 回调页面
    复制文件夹及文件
    html失去获得焦点
    SQL 大数据查询如何进行优化?
    sql表内存占用情况,并进行缩放
    查询被锁的表
  • 原文地址:https://www.cnblogs.com/li123/p/8649557.html
Copyright © 2011-2022 走看看