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

  • 相关阅读:
    【VB编程】05.MsgBox与InputBox函数
    【VBA编程】04.使用自定义数据类型
    【VBA编程】03.判断输入年份是否是闰年
    ubuntu终端颜色设置
    常用命令
    adbd cannot run as root in production builds的解决方法
    camera table表编译
    [Linux]history 显示命令执行的时间
    ubuntu下动态链接库的编译和使用实例
    xxx is not in the sudoers file.This incident will be reported.的解决方法
  • 原文地址:https://www.cnblogs.com/SCJX/p/8653551.html
Copyright © 2011-2022 走看看