python如何实现其他文本的统计_Python3.7 练习题(二) 使用Python进行文本词频统计...

# 使用Python进行词频统计

mytext= """Background

Industrial Light & Magic (ILM) was started in 1975 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 2. ILM has won numerous Academy Awards for Best Visual Effects, not to mention a string of Clio awards forits 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 softwarefor scanning, modeling, rendering, and compositing (the process of joining rendered and scanned images together). Some of these systems made significant advances in areas such asmorphing 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 thatis 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 allthis work, and keeping it working, requires a certain degree of technical wizardry, as well as a tool set that isup to the task of integrating diverse and frequently changing systems.

Enter Python

Backin 1996, in the 101Dalmation days, ILM was exclusively an SGI IRIX shop, and the production pipeline was controlled by Unix shell scripting.

At that time, ILM was producing15-30 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 instrl_list:if str incount_dict.keys():

count_dict[str]= count_dict[str] + 1

else:

count_dict[str]= 1count_list= sorted(count_dict.items(), key=lambda x: x[1], reverse=True)returncount_list

print(wordcount(mytext))

你可能感兴趣的:(python如何实现其他文本的统计_Python3.7 练习题(二) 使用Python进行文本词频统计...)