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

  • 相关阅读:
    md5
    表空间
    create_index
    非额度合同和额度合同
    如何在linux中查找python安装包的路径
    Golang中的SingleFlight与CyclicBarrier
    linux安装protoc
    protobuf 的优缺点
    Xshell 连接 VirtualBox
    限制 input 输入框只能输入纯数字
  • 原文地址:https://www.cnblogs.com/WaiD/p/8653932.html
Copyright © 2011-2022 走看看