首页 > 其他 > 详细

综合练习:英文词频统计

时间:2018-03-26 12:16:44      阅读:210      评论:0      收藏:0      [点我收藏+]
#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 twilights come,
Rise,when the peoples prayers melt in to.
one,to where wed been together in the sphere.
Im searching for where you are,my soul,
I dont know how to put my heart belongs to you;
I dont know how to love someone expect for you;
That is all my world to been had you in my life.
Ill 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 dont know what was right or wrong for all Ive told you;
I dont know what was true or false that youve said to me;
But its all my love to believe in you in my life.
Ill 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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!