zoukankan      html  css  js  c++  java
  • 英语词频统计

    music="""
    Why don't I like the girl I see
    The one who's standing right in front of me
    Why don't I think before I speak
    I should have listened to that voice inside me
    I must be stupid, must be crazy, must be out of my mind
    To say the kind of things I said last night
    Mirror mirror hanging on the wall
    You don't have to tell me who's the biggest fool of all
    Mirror mirror I wish you could lie to me
    And bring my baby back, bring my baby back to me
    (Mirror mirror lie to me
    Show me what I wanna see
    Mirror mirror lie to me
    Show me what I wanna see)
    Why did I let you walk away
    When all I had to do was say I'm sorry
    I let my pride get in the way
    And in the heat of the moment I was to blame
    I must be stupid, must be crazy, must be out of my mind
    Now in the cold light of the day I realize
    Mirror mirror hanging on the wall
    You don't have to tell me who's the biggest fool of all
    Mirror mirror I wish you could lie to me
    And bring my baby back, bring my baby back to me
    If only wishes could be dreams
    And know my dreams could come true
    There would be two us standing here in front of you
    If you could show me that someone that I used to be
    Bring back my baby, my baby to me
    Mirror mirror hanging on the wall
    You don't have to tell me who's the biggest fool of all
    Mirror mirror I wish you could lie to me
    And bring my baby back, bring my baby back to me
    Mirror mirror hanging on the wall
    You don't have to tell me who's the biggest fool of all
    Mirror mirror I wish you could lie to me
    And bring my baby back, bring my baby back to me
    (Mirror mirror lie to me
    Show me what I wanna see
    Mirror mirror lie to me)
    To me...
    (Mirror mirror lie to me
    Show me what I wanna see
    Mirror mirror lie to me
    """

    symbol = list(''',.?!’:"“”-%$''')
    for i in symbol:
    music = music.replace(i, ' ')
    music = music.lower()
    split = music.split()
    word = {}
    for i in split:
    count = music.count(i)
    word[i] = count
    words = '''
    a an the in on to at and of is was are were i he she you your they us their our it or for be too do no
    that s so as but it's don't
    '''
    prep = words.split()
    for i in prep:
    if i in word.keys():
    del(word[i])
    word = sorted(word.items(), key=lambda item: item[1], reverse=True)
    for i in range(10):
    print(word[i])



    运行结果:

    
    
  • 相关阅读:
    闽江学院2015-2016学年下学期《软件测试》课程-第五次博客作业
    在Swift中应用Grand Central Dispatch(下)
    在Swift中应用Grand Central Dispatch(上)转载自的goldenfiredo001的博客
    Asp.net mvc 框架揭秘之Asp.net +Mvc简介
    JavaScript数组
    网页校验
    删除弹出提示框_MVC
    业务体会
    判断数组值是否有重复
    sql
  • 原文地址:https://www.cnblogs.com/hhmk/p/8637938.html
Copyright © 2011-2022 走看看