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



    运行结果:

    
    
  • 相关阅读:
    安装tensorflow-gpu
    Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
    js,jq获取父,兄弟,子节点整理
    dos 命令
    用JavaScript实现自动点击由confirm弹出的对话框中的“确定”按钮
    解决UnicodeEncodeError: 'gbk' codec can't encode character u'u25aa' in position 344 : illegal multiby
    JS中的document.title可以获取当前网页的标题
    python中的3目运算(3元表达式)
    ajax 怎么重新加载页面
    python win32api 如何用代码模拟点击网页confirm框的确定按钮
  • 原文地址:https://www.cnblogs.com/hhmk/p/8637938.html
Copyright © 2011-2022 走看看