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

      

  • 相关阅读:
    Mark
    个人作业——软件工程实践总结作业
    个人作业——软件产品案例分析
    个人技术博客(α)
    软件工程实践_结对Task2_ student_department_matching
    软件工程实践_Task2_sudoku
    软件工程实践_Task1
    面向对象程序设计_Task7_Summary
    面向对象程序设计__Task6_Calculator1.6.2
    C++课堂作业_02_PAT1025.反转链表
  • 原文地址:https://www.cnblogs.com/dengjinxiu/p/8647101.html
Copyright © 2011-2022 走看看