Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Python
Problem description
Frequency analysis of words is commonly used in several fields like cryptography. In this problem, you need to write a program to capture set of
words from the user and calculate the frequency of the most occuring words in the english language
https://en.wikipedia.org/wiki/Most common words in English 2 . Based on the test phrases that you used to test the program, it would be
interesting to see if you notice any deviations from the ranking.
Your program must do the following:-
1) While the user does not enter the word "quit" (the case doesn't matter)
Prompt user to enter a sentence
• Split the sentence into words based on space character (') separator.
2) Display the following information about the words present in the sentences/phrases entered by the user entered.
1) Total number of words
2) Frequency of top ten frequently used words, "the", "be", "to", "of", "and", "a","in"that","have","i"
© Jinu Kabala
O Sample test cases
You have to come up with your own test-cases, do not use the ones below. Also, your test cases must not overlap (they must test different aspects
of your program or requirement). These are meant to be sample test cases only.
Example 1:
The player is prompted to enter some text until the user enter "quit" (case-insensitive)
Player is prompted to enter a phrase/sentence
Enter some text:The Python interpreter is a computer program
Player did not enter quit, so player is prompted to enter a phrase/sentence
Enter some text:Code is a common word for the textual representation of a program
Player did not enter quit, so player is prompted to enter a phrase/sentence
Enter some text:Initially you may think of the interactive interpreter as a powerful calculator.
Player did not enter quit, so player is prompted to enter a phrase/sentence
Enter some text:A statement is a program instruction. A program mostly consists of a series of statement
s, and each statement usually appears on its own line.
Player did not enter quit, so player is prompted to enter a phrase/sentence
Enter some text:quiT
Player enters quit which signals the end of user text entry to the program.
The program displays the number of words and the frequency of top-10 most occurring words based on the texts you entered.
Your output should look like
Total number of words: 55
Word frequency of top ten words
the
3.
be
to
of
4
and
in
that
have
8.
Transcribed Image Text:Problem description Frequency analysis of words is commonly used in several fields like cryptography. In this problem, you need to write a program to capture set of words from the user and calculate the frequency of the most occuring words in the english language https://en.wikipedia.org/wiki/Most common words in English 2 . Based on the test phrases that you used to test the program, it would be interesting to see if you notice any deviations from the ranking. Your program must do the following:- 1) While the user does not enter the word "quit" (the case doesn't matter) Prompt user to enter a sentence • Split the sentence into words based on space character (') separator. 2) Display the following information about the words present in the sentences/phrases entered by the user entered. 1) Total number of words 2) Frequency of top ten frequently used words, "the", "be", "to", "of", "and", "a","in"that","have","i" © Jinu Kabala O Sample test cases You have to come up with your own test-cases, do not use the ones below. Also, your test cases must not overlap (they must test different aspects of your program or requirement). These are meant to be sample test cases only. Example 1: The player is prompted to enter some text until the user enter "quit" (case-insensitive) Player is prompted to enter a phrase/sentence Enter some text:The Python interpreter is a computer program Player did not enter quit, so player is prompted to enter a phrase/sentence Enter some text:Code is a common word for the textual representation of a program Player did not enter quit, so player is prompted to enter a phrase/sentence Enter some text:Initially you may think of the interactive interpreter as a powerful calculator. Player did not enter quit, so player is prompted to enter a phrase/sentence Enter some text:A statement is a program instruction. A program mostly consists of a series of statement s, and each statement usually appears on its own line. Player did not enter quit, so player is prompted to enter a phrase/sentence Enter some text:quiT Player enters quit which signals the end of user text entry to the program. The program displays the number of words and the frequency of top-10 most occurring words based on the texts you entered. Your output should look like Total number of words: 55 Word frequency of top ten words the 3. be to of 4 and in that have 8.
CODE: Loop to accept text from user
The loop exits when user enters quit. Check for case insensitivity.
CODE: Split the text entered by user
Split the text entered by user on a space character and add to a container object like list/dict
CODE: Output number of words
Make sure duplicates are also counted
CODE: Word counting
Using dict or lists keep track of number of occurrences of the top 10 words
CODE: Display the output in tabular format
Make sure advanced string formatting is used
CODE: Must be case insensitive
The and the are considered the same and must be captured in the count
CODE: Loop calls the word split and count
Integrate the loop with the word counting code
Transcribed Image Text:CODE: Loop to accept text from user The loop exits when user enters quit. Check for case insensitivity. CODE: Split the text entered by user Split the text entered by user on a space character and add to a container object like list/dict CODE: Output number of words Make sure duplicates are also counted CODE: Word counting Using dict or lists keep track of number of occurrences of the top 10 words CODE: Display the output in tabular format Make sure advanced string formatting is used CODE: Must be case insensitive The and the are considered the same and must be captured in the count CODE: Loop calls the word split and count Integrate the loop with the word counting code
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY