• 文件方式实现完整的英文词频统计实例


    1.读入待分析的字符串

    2.分解提取单词 

    3.计数字典

    4.排除语法型词汇

    5.排序

    6.输出TOP(20)

    >>> fo=open('test.txt','w')
    >>> fo.write('''I'm a big big girl
      in a big big world
      It's not a big big thing if you leave me
      but I do do feel
      that I too too will miss you much
      miss you much...
      I can see the first leaf falling
      it's all yellow and nice
      It's so very cold outside
      like the way I'm feeling inside
      I'm a big big girl
      in a big big world
      It's not a big big thing if you leave me
      but I do do feel
      that I too too will miss you much
      miss you much...
      Outside it's now raining
      and tears are falling from my eyes
      why did it have to happen
      why did it all have to end
      I'm a big big girl
      in a big big world
      It's not a big big thing if you leave me
      but I do do feel
      that I too too will miss you much
      miss you much...
      I have your arms around me ooooh like fire
      but when I open my eyes
      you're gone...
      I'm a big big girl
      in a big big world
      It's not a big big thing if you leave me
      but I do do feel
      that I too too will miss you much
      miss you much...
      I'm a big big girl
      in a big big world
      It's not a big big thing if you leave me
      but I do feel I will miss you much
      miss you much...''')
    1107
    >>> fo.close()

     结果:

  • 相关阅读:
    [WC2011]最大XOR和路径 线性基
    线段树分裂合并
    [NOIp2016]天天爱跑步 线段树合并
    CF1111E Tree 树链剖分,DP
    [NOI2016]区间 线段树
    [IOI2018] werewolf 狼人 kruskal重构树,主席树
    [CQOI2012]组装 贪心
    [ONTAK2010]Peaks kruskal重构树,主席树
    [NOI2018]归程 kruskal重构树
    kruskal重构树
  • 原文地址:https://www.cnblogs.com/xiaojiaqi/p/7595164.html
Copyright © 2020-2023  润新知