# 使用Python进行词频统计

mytext = """Background
Industrial Light & Magic (ILM) was started in by filmmaker George Lucas, in order to create the special effects for the original Star Wars film. Since then, ILM has grown into a visual effects powerhouse that has contributed not just to the entire Star Wars series, but also to films as diverse as Forrest Gump, Jurassic Park, Who Framed Roger Rabbit, Raiders of the Lost Ark, and Terminator . ILM has won numerous Academy Awards for Best Visual Effects, not to mention a string of Clio awards for its work on television advertisements. While much of ILM's early work was done with miniature models and motion controlled cameras, ILM has long been on the bleeding edge of computer generated visual effects. Its computer graphics division dates back to 1979, and its first CG production was the 1982 Genesis sequence from Star Trek II: The Wrath of Khan. In the early days, ILM was involved with the creation of custom computer graphics hardware and software for scanning, modeling, rendering, and compositing (the process of joining rendered and scanned images together). Some of these systems made significant advances in areas such as morphing and simulating muscles and hair. Naturally, as time went by many of the early innovations at ILM made it into the commercial realm, but the company's position on the cutting edge of visual effects technology continues to rely on an ever-changing combination of custom in-house technologies and commercial products. Today, ILM runs a batch processing environment capable of modeling, rendering and compositing tens of thousands of motion picture frames per day. Thousands of machines running Linux, IRIX, Compaq Tru64, OS X, Solaris, and Windows join together to provide a production pipeline that is used by approximately eight hundred users daily, many of whom write or modify code that controls every step of the production process. In this context, hundreds of commercial and in-house software components are combined to create and process each frame of computer-generated or enhanced film. Making all this work, and keeping it working, requires a certain degree of technical wizardry, as well as a tool set that is up to the task of integrating diverse and frequently changing systems. Enter Python
Back in , in the Dalmation days, ILM was exclusively an SGI IRIX shop, and the production pipeline was controlled by Unix shell scripting.
At that time, ILM was producing - shots per show, typically only a small part of each feature length film to which they were contributing.""" def wordcount(str):
strl_list = str.replace('\n', '').lower().split(" ") count_dict = {}
for str in strl_list:
if str in count_dict.keys():
count_dict[str] = count_dict[str] +
else:
count_dict[str] =
count_list = sorted(count_dict.items(), key=lambda x: x[], reverse=True)
return count_list print(wordcount(mytext))

示例:

E:\Python37\python.exe E:/PythonTest/Test/Test002.py
[('of', ), ('the', ), ('and', ), ('to', ), ('ilm', ), ('was', ), ('a', ), ('in', ), ('as', ), ('that', ), ('by', ), ('for', ), ('has', ), ('visual', ), ('on', ), ('production', ), ('effects', ), ('star', ), ('its', ), ('early', ), ('computer', ), ('commercial', ), ('create', ), ('wars', ), ('into', ), ('not', ), ('but', ), ('diverse', ), ('awards', ), ('work', ), ('with', ), ('motion', ), ('controlled', ), ('edge', ), ('graphics', ), ('days,', ), ('custom', ), ('software', ), ('modeling,', ), ('compositing', ), ('process', ), ('made', ), ('many', ), ('at', ), ('it', ), ('an', ), ('in-house', ), ('thousands', ), ('per', ), ('pipeline', ), ('is', ), ('or', ), ('this', ), ('each', ), ('background', ), ('industrial', ), ('light', ), ('&', ), ('magic', ), ('(ilm)', ), ('started', ), ('', ), ('filmmaker', ), ('george', ), ('lucas,', ), ('order', ), ('special', ), ('original', ), ('film.', ), ('since', ), ('then,', ), ('grown', ), ('powerhouse', ), ('contributed', ), ('just', ), ('entire', ), ('series,', ), ('also', ), ('films', ), ('forrest', ), ('gump,', ), ('jurassic', ), ('park,', ), ('who', ), ('framed', ), ('roger', ), ('rabbit,', ), ('raiders', ), ('lost', ), ('ark,', ), ('terminator', ), ('2.', ), ('won', ), ('numerous', ), ('academy', ), ('best', ), ('effects,', ), ('mention', ), ('string', ), ('clio', ), ('television', ), ('advertisements.while', ), ('much', ), ("ilm's", ), ('done', ), ('miniature', ), ('models', ), ('cameras,', ), ('long', ), ('been', ), ('bleeding', ), ('generated', ), ('effects.', ), ('division', ), ('dates', ), ('back', ), ('1979,', ), ('first', ), ('cg', ), ('', ), ('genesis', ), ('sequence', ), ('from', ), ('trek', ), ('ii:', ), ('wrath', ), ('khan.in', ), ('involved', ), ('creation', ), ('hardware', ), ('scanning,', ), ('rendering,', ), ('(the', ), ('joining', ), ('rendered', ), ('scanned', ), ('images', ), ('together).', ), ('some', ), ('these', ), ('systems', ), ('significant', ), ('advances', ), ('areas', ), ('such', ), ('morphing', ), ('simulating', ), ('muscles', ), ('hair.naturally,', ), ('time', ), ('went', ), ('innovations', ), ('realm,', ), ("company's", ), ('position', ), ('cutting', ), ('technology', ), ('continues', ), ('rely', ), ('ever-changing', ), ('combination', ), ('technologies', ), ('products.today,', ), ('runs', ), ('batch', ), ('processing', ), ('environment', ), ('capable', ), ('rendering', ), ('tens', ), ('picture', ), ('frames', ), ('day.', ), ('machines', ), ('running', ), ('linux,', ), ('irix,', ), ('compaq', ), ('tru64,', ), ('os', ), ('x,', ), ('solaris,', ), ('windows', ), ('join', ), ('together', ), ('provide', ), ('used', ), ('approximately', ), ('eight', ), ('hundred', ), ('users', ), ('daily,', ), ('whom', ), ('write', ), ('modify', ), ('code', ), ('controls', ), ('every', ), ('step', ), ('process.', ), ('context,', ), ('hundreds', ), ('components', ), ('are', ), ('combined', ), ('frame', ), ('computer-generated', ), ('enhanced', ), ('film.making', ), ('all', ), ('work,', ), ('keeping', ), ('working,', ), ('requires', ), ('certain', ), ('degree', ), ('technical', ), ('wizardry,', ), ('well', ), ('tool', ), ('set', ), ('up', ), ('task', ), ('integrating', ), ('frequently', ), ('changing', ), ('systems.enter', ), ('pythonback', ), ('1996,', ), ('', ), ('dalmation', ), ('exclusively', ), ('sgi', ), ('irix', ), ('shop,', ), ('unix', ), ('shell', ), ('scripting.', ), ('time,', ), ('producing', ), ('15-30', ), ('shots', ), ('show,', ), ('typically', ), ('only', ), ('small', ), ('part', ), ('feature', ), ('length', ), ('film', ), ('which', ), ('they', ), ('were', ), ('contributing.', )] Process finished with exit code

Python3.7 练习题(二) 使用Python进行文本词频统计的更多相关文章

  1. 用Python实现一个词频统计(词云+图)

    第一步:首先需要安装工具python 第二步:在电脑cmd后台下载安装如下工具: (有一些是安装好python电脑自带有哦) 有一些会出现一种情况就是安装不了词云展示库 有下面解决方法,需看请复制链接 ...

  2. Python字典使用--词频统计的GUI实现

    字典是针对非序列集合而提供的一种数据类型,字典中的数据是无序排列的. 字典的操作 为字典增加一项 dict[key] = value students = {"Z004":&quo ...

  3. 利用python实现简单词频统计、构建词云

    1.利用jieba分词,排除停用词stopword之后,对文章中的词进行词频统计,并用matplotlib进行直方图展示 # coding: utf-8 import codecs import ma ...

  4. Python3.7 练习题(-) 如何使用Python生成200个优惠卷(激活码)

    # 如何使用Python生成200个优惠卷(激活码) import random import string # string.ascii_letters 26个大小写 # -9数字 # 获得激活码中 ...

  5. python3笔记(二)Python语言基础

    缩进 要求严格的代码缩进是python语法的一大特色,就像C语言家族(C.C++.Java等等)中的花括号一样重要,在大多数场合还非常有必要.在很多代码规范里面也都有要求代码书写按照一定的规则进行换行 ...

  6. Python3入门(二)——Python开发工具Pycharm安装与配置

    一.概述 与IDEA同一家——Jetbrains出品的IDE,强大之处不再赘述 二.安装 点击下载一个合适的版本 参考网友的激活方式激活:https://blog.csdn.net/u01404481 ...

  7. 零基础学python-3.7 还有一个程序 python读写文本

    今天我们引入另外一个程序,文件的读写 我们先把简单的程序代码贴上.然后通过我们多次的改进.希望最后可以变成一个简单的文本编辑器 以下是我们最简单的代码: 'crudfile--读写文件' def re ...

  8. python3笔记十二:python数据类型-Dictionary字典

    一:学习内容 字典概念 字典创建 字典访问 字典添加 字典删除 字典遍历 字典与列表比较 二:字典概念 1.使用键值对(key-value)存储,具有极快的查找速度 2.注意:字典是无序的 3.特性: ...

  9. jieba和文本词频统计

    ---恢复内容开始--- 一.结巴中文分词涉及到的算法包括: (1) 基于Trie树结构实现高效的词图扫描,生成句子中汉字所有可能成词情况所构成的有向无环图(DAG): (2) 采用了动态规划查找最大 ...

随机推荐

  1. npm run build 打包后,如何运行在本地查看效果(Nginx服务)

    这段时间,研究了一下vue 打包的很慢的问题.但是当我 npm run build 打包后,在本地查看效果的时候,活生生被我老大鄙视了,因为我打开了XAMPP.他说:你怎么不用Nginx啊?用这个一堆 ...

  2. 正向代理 vs 反向代理

    正向代理: 内网客户端访问外网服务器的中介 反向代理: 外网客户端访问内网服务器的中介 正向代理: 代理访问外部资源 正向代理的用途: 1. 访问原来无法访问的资源 , 如googl 2. 可以做缓存 ...

  3. redis安装,windows,linux版本并部署服务

    一.使用场景         项目中采用数据库访问量过大或访问过于频繁,将会对数据库带来很大的压力.redis数据库是以非关系数据库的出现,后来redis的迭代版本支持了缓存数据.登录session状 ...

  4. Java编程思想--控制执行流程

    java控制流程设计的关键字包括if-else,while,do-while,for,return,break,continue以及switch.(go-to) 1.while在迭代之前计算一次布尔表 ...

  5. Tomcat启动后,访问页面报404错误解决方法

    Tomcat正常启动后,出现如下情况 提供一个参考解决方法: 1.双击servers 2.把Server Locations设置为User Tomcat installation 保存后再次访问页面就 ...

  6. C# 应用程序单例(禁止多开) 获取.net版本号 以及 管理员权限

    Mutex不仅提供跨线程的服务,还提供跨进程的服务.当在构造函数中为Mutex指定名称时,则会创建一个命名了的Mutex.其他线程创建Mutex时,如果指定的名称相同,则返回同一个互斥体,不论该线程位 ...

  7. mysql 关于数据库和数据表的基本操作

    -- 备注: -- .每一条mysql语句后面都需要加上半角分号 -- .可以用``符号(1键旁边的那个键)将字段名称引用起来,如`Name` -- .mysql在windows下不区分大小写,在li ...

  8. Django知识总结(三)

    拾伍 ● Ajax技术 一 ● Ajax定义 Ajax: 异步的 JavaScript 和 XML (Asynchronous+Javascript+XML) 通过Ajax, 我们可以在不重新加载整个 ...

  9. 6 python高级数据处理和可视化

    6.2. pyplot作图 1.折线图和散点图 t = np.arange(0,4,0.1) plt.plot(t,t,'o',t,t+2,t,t**2,'o') plt.show() 2.柱线图 p ...

  10. 第七次作业——numpy统计分布显示

    用np.random.normal()产生一个正态分布的随机数组,并显示出来. np.random.randn()产生一个正态分布的随机数组,并显示出来. 显示鸢尾花花瓣长度的正态分布图,曲线图,散点 ...