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])

  • 相关阅读:
    Python六大开源框架对比:Web2py略胜一筹
    软件设计之UML—UML的构成[上]
    Web程序员最常用的11款PHP框架
    PHP常见框架
    WinCE的开发流程
    Windows10如何卸载OneDrive
    Windows系统中环境变量不展开的问题
    线程局部存储空间
    ping pathping tcping psping tracert
    ubuntu ufw 配置
  • 原文地址:https://www.cnblogs.com/SCJX/p/8653551.html
Copyright © 2011-2022 走看看