Question: {:..> Word Frequencies 1. Use a text editor to create a text file. It should contain at least 4 sentences with around 25 or more

{:..> Word Frequencies

1. Use a text editor to create a text file. It should contain at least 4 sentences with around 25 or more words.

2. Write a Python program that

asks the user to provide the name of the text file NOTE the program should not produce errors if the file doesnt exist!reads from the text file

creates a dictionary that maps a string to the number of times each string occurs. oThe key will be a string, and the value will be the number of times each string occurs in the text. oThe report should be an ALPHABETIZED output table, listing the string and the number of occurrences. Produce an ALPHABETIZED report of strings and frequencies -- extract just the keys and sort them. Use the sorted keys to extract the counts from thedictionary.

NOTES:The input sequence can be words, numbers (this, 45yrs, ThIS, isnt, etc. are all valid strings). Discard all punctuation EXCEPT if it occurs in within the string. (create a function to do this).

Example: when? when (discard the ending question mark)

its its (no change here)

Ignore case apple is the same as Apple, APPLE, etc.

Put the strings into adictionary. The first time a string is seen, the frequency is 1. Each time the string is seen again, increment the frequency

.NOTE: you are REQUIRED to use the dictionary class for this assignment

.Make sure that your output (the table) is formatted : oUse format method to align the output into columns oProvide titles for each column. oMake sure each word does NOT contain punctuation oEach word should be displayed in lowercase.

Be sure to modularize your code, using functions appropriately. Your main program should be cleanand easy to read, calling the functions with meaningful names. Pass parameters do not use global variables.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!