zoukankan      html  css  js  c++  java
  • 综合练习:词频统计

    song = '''
    An empty street,An empty house,A hole inside my heart,I'm all alone,The rooms are getting smaller,I wonder how,I wonder why,I wonder where they are,The days we had,The songs we sang together,Oh yeah,And oh my love,I'm holding on forever,Reaching for a love that seems so far,So i say a little prayer,And hope my dreams will take me there,Where the skies are blue to see you once again, my love,Over seas and coast to coast,To find a place i love the most,Where the fields are green to see you once again, my love
    '''
    
    wordlist1 = song.replace('',' ').lower().split()
    wordlist2 = song.split()
    
    c = {}
    for i in wordlist2:
        count = wordlist1.count(i)
        c[i] = count
    
    word = '''
    i'm you and the an a my i are
    '''
    wordlist3 = word.split()
    for i in wordlist3:
        if i in c.keys():
            del (c[i])
    
    count = sorted(c.items(),key=lambda items: items[1], reverse=True)
    
    for i in range(20):
        print(count[i])


     
  • 相关阅读:
    Java基本数据类型的包装类
    Java数据类型基础
    Xscan安装
    Notepad++配置HexEditor插件
    [WP]XCTF-re2-cpp-is-awesome
    [WP]XCTF-tt3441810
    [WP]XCTF-re1-100
    [WP]XCTF-Mysterious
    [WP]xctf-parallel-comparator-200
    [WP]XCTF-elrond32
  • 原文地址:https://www.cnblogs.com/liangyao111/p/8650325.html
Copyright © 2011-2022 走看看