Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This problem requires you to prompt the user for a sentence and then construct two lists: one that contains each unique word, and one that

This problem requires you to prompt the user for a sentence and then construct two lists: one that contains each unique word, and one that contains the number of times that word occurred in the sentence. Create these as parallel lists where the indices match between the lists. The index for the word in the words list should match the index for that words count in the occurrences list. This problem will have you practice with strings, lists, and loops.
The input prompt should be as follows:
"Enter your sentence:
"
You will need to remove any punctuation from the sentence. As a simplification, you can assume that any punctuation will be at the beginning or end of a word, and you only need to worry about the characters .,,,!,?,(,) Extra spaces should also be removed.
You will also need to make sure that all of the words are converted to lower case for purposes of counting their frequency and the final list.
Hint: There is punctuation in the middle of the sentence such as commas. These will need to be removed. It can be useful to split up the string to then process each word in the sentence to remove punctuation.
For example, if the user entered the sentence "The cow jumped over the moon.", your program would create two lists to keep track of the words and the word occurrences. After calculating the word frequencies, print out the words as well as their frequencies in the following format:
Word.........Frequency
______________________
the..................2
cow..................1
jumped...............1
over.................1
moon.................1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago