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



    运行结果:

    
    
  • 相关阅读:
    生活娱乐 工业机器人代替工人装配鼠标键盘
    生活娱乐 工商银行如何查询开户行
    生活娱乐 格力空气能热水器怎么样
    生活娱乐 岛城将开首家机器人餐厅
    生活娱乐 毕业生论文查重技巧
    Windows 老是弹出要自动拨号连接怎么办
    Office 针式打印机如何调节边距
    Office 如何打印彩色照片能取得较好的效果
    西游释厄传如何设置简化出招表
    [ES2019] Use JavaScript ES2019 flatMap to Map and Filter an Array
  • 原文地址:https://www.cnblogs.com/hhmk/p/8637938.html
Copyright © 2011-2022 走看看