zoukankan      html  css  js  c++  java
  • 统计英文歌词词频

    s1='''Hold on to love 
    that is what I do 
    now that I've found you 
    And from above  
    everything's stinking they're not around you 
    And in the night  
    I could be helpless  
    I could be lonely  
    sleeping without you  
    And in the day  
    everything's complex  
    There's nothing simple  
    when I'm not around you  
    But I miss you when you're gone  
    that is what I do  
    And it's going to carry on  
    that is what I do  
    Hold on to my hands 
    I feel I'm sinking  
    sinking without you  
    And to my mind  
    everything's stinking  
    stinking without you '''
    s1=s1.lower().replace("'s"," ").replace("i'm"," ").replace("and"," ").replace("to"," ").replace(" is"," ").replace("you"," ").replace("that"," ").replace(','," ").replace(" on"," ").replace("i "," ")
    print(s1)
    lyricsWordList=s1.split();
    lyricsWordSet=set(lyricsWordList)
    lyricsDict={}
    for word in lyricsWordSet:
        lyricsDict[word]=lyricsWordList.count(word)
    lyricsWordListSort=sorted(lyricsDict.items(),key=lambda d:d[1],reverse=True)
    for i in range(10):
        if i>len(lyricsWordListSort):
            break
        print(lyricsWordListSort[i])
    

      

  • 相关阅读:
    BZOJ 3218: a + b Problem
    P4542 [ZJOI2011]营救皮卡丘
    P4843 清理雪道
    P4553 80人环游世界
    P4126 [AHOI2009]最小割
    P2619 [国家集训队2]Tree I
    P2469 [SDOI2010]星际竞速
    P2050 [NOI2012]美食节
    易语言入门
    jdbc连接oracle语法
  • 原文地址:https://www.cnblogs.com/zd983886992/p/8645553.html
Copyright © 2011-2022 走看看