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

  • 相关阅读:
    ASP.NET MVC学习系列(二)-WebAPI请求
    dynamic介绍
    C#中dynamic的正确用法 以及 typeof(DynamicSample).GetMethod("Add");
    json中jobject
    泛型类型参数及约束
    new 运算符
    内核知识第五讲.驱动框架编写,以及3环和0环通信.
    编写内核驱动加载工具
    内核知识第四讲,简单的认识内核函数.以及调试驱动技巧
    内核第三讲,进入ring0,以及编写第一个内核驱动程序.
  • 原文地址:https://www.cnblogs.com/WaiD/p/8653932.html
Copyright © 2011-2022 走看看