• 综合练习:英文词频统计


    song = '''
        Take a deep breath in the mirror,
    he didn't like it when I wore high heels but I do.
    
    Turn the lock and put my headphones on,
    he always said he didn't get this song but I do. I do.
    
    Walked in expecting you'd be late
    but you got here early and you stand and wait I walk to you.
    
    You pulled my chair out and helped me in,
    and you don't know how nice that is but I do.
    
    And you throw your head back laughing like a little kid.
    I think it's strange that you think I'm funny cause he never did.
    I've been spending the last eight months
    thinking all love ever does is break, and burn, and end.
    But on a Wednesday, in a cafe...I watched it begin again.
     '''
    
    delet = list(''',.?!’:"“”-%$''')
    for i in delet:
        song = song.replace(i, ' ')
    song = song.lower().split()
    word = {}
    for i in song:
        count = song.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
    '''
    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])

    结果截图:

  • 相关阅读:
    ORACLE数据库备份与恢复详解
    Oracle块,区,段
    Oracle触发器
    SQL
    Oracle 用户管理权限
    Mybatis_One
    面向对象编程应用实例
    面向对象之方法2
    面向对象之方法1
    面向对象之结构体2
  • 原文地址:https://www.cnblogs.com/170he/p/8647457.html
Copyright © 2020-2023  润新知