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

#coding=utf-8

song='''
Skies,where the blue birds fly,
Clouds where the people place their souls on to.
Brighter,the sunshines that go through my tears,
like searching for what heals my sorrows,
Cry,when the twilight's come,
Rise,when the people's prayer's melt in to.
one,to where we'd been together in the sphere.
I'm searching for where you are,my soul,
I don't know how to put my heart belongs to you;
I don't know how to love someone expect for you;
That is all my world to been had you in my life.
I'll call you all the time,
Skies,where the blue birds cry,
Clouds where the people forgot their souls on to,
Brighter,the sunshines that go through my tears,
like searching for what heals my sorrows,
I don't know what was right or wrong for all I've told you;
I don't know what was true or false that you've said to me;
But it's all my love to believe in you in my life.
I'll call you all the time.
'''
ellipsis_word={',','.',';',':','?','!','-'}   #将一些符号替换成空格
for i in ellipsis_word:
    song.replace(i,'')

Capital_word=song.lower().split()   #大小写替换,并分解

Words={}
for i in set(Capital_word):     #设置集合
    Words[i]=Capital_word.count(i)

delete_word={'a', 'too', 'in', 'of', 'will', 'the', 'and', 'are', 'with', 'to', 'said', 'as', 's'}
for i in delete_word:        #删除出现的语法过渡词
    if i in Words:
        Words.pop(i)         #移除列表元素

sort_word = sorted(Words.items(), key= lambda d:d[1], reverse = True)  # 排序
for i in range(10):
    print(sort_word[i])

截图:

原文地址:https://www.cnblogs.com/tiankongyiluozhiwu/p/8649770.html