Word frequency statistics for Python speech

Source: Internet
Author: User

Demand:

1. Design a procedure for Word frequency statistics.

2. English-language punctuation marks are not counted.

3. Sort the statistical results by the frequency of the occurrences of the word from large to small.

Design:

1. Basic functions and usage will be prompted in the program.

2. The principle is to use the delimiter Word to deposit the list, and then read from the list into the dictionary, the key is the word, the value of the number of words stored.

Code:

1. The module required to import the program.

2. Define the ReadFile class and implement the ability to remove punctuation in the article.

3. Define a GETSTR class to define the resulting output format.

4. Construct the program main function.

Test Case:

Test case I chose Martin Luther King's speech.

Some test results:

I also read the requirements of teacher Yang to other students, such as trying to run a run of "war and Peace" This English book, probably because the loadline number is too large, there is no operating results.

The above is the display of my program, the shortcomings of the teacher to give comments, thank you for your teacher.

Word frequency statistics for Python speech

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.