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

    lyric = '''
    Oh Whoa
    Oh Whoa
    Oh Whoa
    You know you love me, I know you care
    Just shout whenever, and I'll be there
    You are my love, you are my heart
    And we will never, ever , ever be apart
    Are we an item? Girl, quit playing
    "Were just friends," what are you saying
    Said "there's another," and looked right in my eyes
    My first love broke my heart for the first time
    And I was like baby, baby, baby, oh
    Like baby, baby, baby, oh
    Like baby, baby, baby, oh
    I thought you'd always be mine, mine
    Baby, baby, baby, oh
    Like baby, baby, baby, no
    Like baby, baby, baby, oh
    I thought you'd always be mine, mine
    For you, I would have done whatever
    And I just can't believe we aren't together
    And I want to play it cool, but I'm losing you
    I'll buy you anything, I'll buy you diamond ring
    And I'm in pieces, baby fix me
    And just shake me till you wake me from this bad dream
    I'm going down, down, down, down
    And I just can't believe my first love won't be around
    And I'm like baby, baby, baby, oh
    Like baby, baby, baby, no
    Like baby, baby, baby, oh
    I thought you'd always be mine, mine
    Baby, baby, baby, oh
    Like baby, baby, baby, no
    Like baby, baby, baby, oh
    I thought you'd always be mine, mine
    When I was 13, I had my first love
    There was nobody that compared to my baby
    And nobody came between us who could ever come above
    She had me going crazy, oh I was starstruck
    She woke me up daily, don't need no Starbucks
    She made my heart pound
    I skip a beat when I see her in the street
    And at school on the playground
    But I really want to see her on the weekend
    She knows she got me dazing 'cause she was so amazing
    And now my heart is breaking but I just keep on saying
    Baby, baby, baby, oh
    Like baby, baby, baby, no
    Like baby, baby, baby, oh
    I thought you'd always be mine, mine
    Baby, baby, baby, oh
    Like baby, baby, baby, no
    Like baby, baby, baby, oh
    I thought you'd always be mine, mine
    I'm all gone
    (Yeah, yeah, yeah)
    (Yeah, yeah, yeah)
    Now I'm all gone
    (Yeah, yeah, yeah)
    (Yeah, yeah, yeah)
    Now I'm all gone
    (Yeah, yeah, yeah)
    (Yeah, yeah, yeah)
    Now I'm all gone, gone, gone, gone
    I'm gone
    '''
    
    wordlist1 = lyric.replace('',' ').lower().split()
    wordlist2 = lyric.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])

  • 相关阅读:
    javascript Date类的扩展
    软件工程师好了歌 (转)
    您可能不知道的.Net2.0小技巧
    您未必知道的Js技巧
    复活吧,架构师!
    技巧系列文章
    不要使用paddingtop控制内容开始的位置
    JQuery Offset实验与应用(转载)
    2008最佳Windows应用程序
    精选15个国外CSS框架
  • 原文地址:https://www.cnblogs.com/sunset-Panda/p/8653628.html
Copyright © 2011-2022 走看看