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

    song = '''
    I don't like your little games
    Don't like your tilted stage
    The role you made me play of the fool
    No I don't like you
    I don't like your perfect crime
    How you laugh when you lie
    You said the gun was mine
    Isn't cool
    No I don't like you ooh
    But I got smarter I got harder in the nick of time
    Honey I rose up from the dead I do it all the time
    I got a list of names and yours is in red underlined
    I check it once then I check it twice ooh
    Ooh look what you made me do
    Look what you made me do
    Look what you just made me do
    Look what you just made me
    Ooh look what you made me do
    Look what you made me do
    Look what you just made me do
    Look what you just made me do
    I don't like your kingdom keys
    They once belonged to me
    You asked me for a place to sleep
    Locked me out and threw a feast what
    The world moves on another day another drama drama
    But not for me not for me all I think about is karma
    And then the world moves on but one thing's for sure
    Maybe I got mine but you'll all get yours
    But I got smarter I got harder in the nick of time
    Honey I rose up from the dead I do it all the time
    I've got a list of names and yours is in red underlined
    I check it once then I check it twice ooh
    Ooh look what you made me do
    Look what you made me do
    Look what you just made me do
    Look what you just made me
    Ooh look what you made me do
    Look what you made me do
    Look what you just made me do
    Look what you just made me do
    I don't trust nobody and nobody trusts me
    I'll be the actress starring in your bad dreams
    I don't trust nobody and nobody trusts me
    I'll be the actress starring in your bad dreams
    I don't trust nobody and nobody trusts me
    I'll be the actress starring in your bad dreams
    I don't trust nobody and nobody trusts me
    I'll be the actress starring in your bad dreams
    Look what you made me do
    Look what you made me do
    Look what you made me do
    I'm sorry the old Taylor can't come to the phone right now
    Why
    Oh 'cause she's dead ohh
    Ooh look what you made me do
    Look what you made me do
    Look what you just made me do
    Look what you just made me
    Ooh look what you made me do
    Look what you made me do
    Look what you just made me do
    Look what you just made me do
    Ooh look what you made me do
    Look what you made me do
    Look what you just made me do
    Look what you just made me
    Ooh look what you made me do
    Look what you made me do
    Look what you just made me do
    Look what you just made me do
    '''
    
    wordlist1 = song.replace('',' ').lower().split()
    wordlist2 = song.split()
    
    c = {}
    for i in wordlist2:
        count = wordlist1.count(i)
        c[i] = count
    
    word = '''
    i'm you and the an a my i are
    '''
    wordlist3 = word.split()
    for i in wordlist3:
        if i in c.keys():
            del (c[i])
    
    count = sorted(c.items(),key=lambda items: items[1], reverse=True)
    
    for i in range(20):
        print(count[i])

  • 相关阅读:
    BZOJ 2260: 商店购物
    BZOJ 4349: 最小树形图
    BZOJ 1115: [POI2009]石子游戏Kam
    BZOJ 1413: [ZJOI2009]取石子游戏
    BZOJ 2275: [Coci2010]HRPA
    BZOJ 4730: Alice和Bob又在玩游戏
    BZOJ 1455: 罗马游戏
    BZOJ 3509: [CodeChef] COUNTARI
    BZOJ 1513: [POI2006]Tet-Tetris 3D
    #大数加减乘除#校赛D题solve
  • 原文地址:https://www.cnblogs.com/SCJX/p/8653551.html
Copyright © 2011-2022 走看看