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

    str='''A famous man has once said that women hold half the sky. A wise writer has said
     that half the man is a woman. In fact, women are just like the deep-hidden treasure 
     which has not been explored completely. It is not deniable that with the economic globalization,
     knowledge economy and China’s entry into the WTO, women have stepped into a bigger arena. 
    Women have a better sense of interpersonal relationship, family and business success. 
    They have the desire to be admitted by the society. 
    But all these good wishes are not easy to accomplish.
    This paper gives some suggestions to women hoping to get success in career,
    family and interpersonal relationship through the analysis of the main characters Scarlet and Melanie in the famous 
    masterpiece Gone with the Wind. In terms of success in career, women can learn from Scarlet and cultivate the ability 
    of innovation, self-confidence and self-trust. As for success in family life, women can learn Melanie’s trust, 
    respect and love. To succeed in interpersonal relationship, women can follow Scarlet to use beauty properly to attract 
    others, and follow Melanie to use her internal beauty to win others’ respect and trust.'''
    #替换标点符号
    symbol=[".", ",", "’"]
    for i in range(len(symbol)):
        str = str.replace(symbol[i]," ")
    # 转换字符串大写字符为小写
    str=str.lower()
    # 将字符串分隔为单词列表
    str=str.split()
    # 创建空的字典
    d=dict(zip())
    # 用字典记录单词以及出现的频率
    for i in str:
        d[i]=str.count(i)
    # 排除语法型词汇,代词、冠词、连词
    pron = ["for", "to", "the", "and", "of", "in","that","have","has","a","can","not"]
    for i in pron:
        del d[i]
    d2=sorted(d.items(),key=lambda x:x[1],reverse=True)
    for i in range(10):
        print(d2[i])
    

      

  • 相关阅读:
    每日博客
    每日博客
    预开发软件书 新
    laravel的优点
    Laravel 自己创建ServiceProvider 与 yansongda/laravel-pay 支付服务
    laradock
    普通静态绑定与后期静态绑定
    phpstorm和xdebug的配置 变量的单步调试
    phpstorm 连接远程docker
    docker php-fpm安装xdebug 与phpstorm firefox联调
  • 原文地址:https://www.cnblogs.com/dengjinxiu/p/8647101.html
Copyright © 2011-2022 走看看