综合练习:词频统计

Posted 091梁耀

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了综合练习:词频统计相关的知识,希望对你有一定的参考价值。

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


 

 

以上是关于综合练习:词频统计的主要内容,如果未能解决你的问题,请参考以下文章

综合练习:词频统计

综合练习:词频统计

综合练习:英文词频统计

综合练习:英文词频统计

综合练习:词频统计

综合练习:英文词频统计