zoukankan      html  css  js  c++  java
  • 英文词频统计

    song='''
    You're the light, you're the night
    You're the color of my blood
    You're the cure, you're the pain
    You're the only thing I wanna touch
    Never knew that it could mean so much, so much
    
    You're the fear, I don't care
    Cause I've never been so high
    Follow me to the dark
    Let me take you past our satellites
    You can see the world you brought to life, to life
    
    So love me like you do, love me like you do
    Love me like you do, love me like you do
    Touch me like you do, touch me like you do
    What are you waiting for?
    
    Fading in, fading out
    On the edge of paradise
    Every inch of your skin is a holy grail I've got to find
    Only you can set my heart on fire, on fire
    Yeah, I'll let you set the pace
    Cause I'm not thinking straight
    My head spinning around I can't see clear no more
    What are you waiting for?
    
    Love me like you do, love me like you do
    Love me like you do, love me like you do
    Touch me like you do, touch me like you do
    What are you waiting for?
    
    Love me like you do, love me like you do
    Love me like you do, love me like you do
    Touch me like you do, touch me like you do'''
    
    symbol = list(''',.?!’:"“”-%$''')
    for i in symbol:
        song = song.replace(i, ' ')
    song = song.lower()
    split = song.split()
    word = {}
    for i in split:
        count = song.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
    '''
    
    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])
  • 相关阅读:
    js判断手机端Android手机还是iPhone手机
    网站中增加微信公众账号链接的方法
    人人网的账号登录及api操作
    腾讯微博的账号登录及api操作
    QQ的账号登录及api操作
    新浪微博的账号登录及api操作
    开心网的账号登录及api操作
    豆瓣的账号登录及api操作
    判断手机旋转代码 屏幕旋转的事件和样式
    jQuery实现长按按钮触发事件的方法
  • 原文地址:https://www.cnblogs.com/168-hui/p/8646081.html
Copyright © 2011-2022 走看看