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

  • 相关阅读:
    使用Perl5获取有道词典释义
    Compress a Folder/Directory via Perl5
    为该目录以及子目录添加index.html
    学习Perl6: slice fastq file
    Javascript Regexp match and replace
    赋值运算符函数
    扑克牌顺子
    翻转单词顺序VS左旋转字符串
    和为S的两个数字VS和为S的连续正数序列
    数组中只出现一次的数字
  • 原文地址:https://www.cnblogs.com/SCJX/p/8653551.html
Copyright © 2011-2022 走看看