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

      

  • 相关阅读:
    【opencv.js】将图片转换为灰度图
    【快速创建】第一个 opencv.js 项目
    【踩坑无数】Anaconda(2020.02) + Tensorflow2.1 + python3.7 (CPU版本)的安装
    Thread的join方法
    常用语句
    获取当前托管线程的唯一标识符
    修改文件或文件夹的权限,为指定用户、用户组添加完全控制权限(转载)
    C#中Monitor和Lock以及区别(转载)
    LIBRA查询
    Select()和SelectMany()的区别
  • 原文地址:https://www.cnblogs.com/dengjinxiu/p/8647101.html
Copyright © 2011-2022 走看看