• 英语词频统计


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



    运行结果:

    
    
  • 相关阅读:
    Linux入门实践笔记(二)——Jar包的运行与关闭
    SpringCloud从入门到进阶(二)——注册中心Eureka的伪分布式部署
    Linux入门实践笔记(一)——安装JDK与运行jar包
    探究ConcurrentHashMap中键值对在Segment[]的下标如何确定
    探究HashMap线性不安全(三)——死循环的产生
    jmeter集成测试报告
    jmeter+ant+jenkins持续集成设置
    jmeter-环境配置与安装
    MySql 基本语法_数据表操作
    MySql 基本语法_数据库操作
  • 原文地址:https://www.cnblogs.com/hhmk/p/8637938.html
Copyright © 2020-2023  润新知