Question: Help with Python 3 dictionaries The txt files are at http://www.cse.msu.edu/~cse231/Online/Labs/Lab09/ Thank you! Execute the program (which currently uses document1.txt as the data file) and

Help with Python 3 dictionaries

Help with Python 3 dictionaries The txt files are at http://www.cse.msu.edu/~cse231/Online/Labs/Lab09/ Thank

you! Execute the program (which currently uses "document1.txt" as the data file)

and inspect the output a. Replace each of the lines labeled "YOUR

COMMENT' with meaningful comments to describe the work being done in the

The txt files are at http://www.cse.msu.edu/~cse231/Online/Labs/Lab09/

Thank you!

Execute the program (which currently uses "document1.txt" as the data file) and inspect the output a. Replace each of the lines labeled "YOUR COMMENT' with meaningful comments to describe the work being done in the next block of statements. Use more than one comment line, if necessary b. Add doc strings to each function to describe the work being done in the function c. The program currently processes the empty string as a word. Revise the program to exclude empty strings from the collection of words d. The program currently processes words such as "The" and "the" as different words. Revise the program to ignore case when processing words. e. The program currently always uses "document 1.txt" as the input file. Revise the program to prompt the user for the name of the input file. f. Revise the program to display the collection of words sorted by greatest frequency of occurrence to least frequency, and sorted alphabetically for words with the same frequency count. Since the sorted function and the sort method are stable sorts, you can first sort the words alphabetically, and then sort them by frequency (with reverse True (You do the two sorts in that order because you do the primary key last, frequency is the primary key in this case.) By default sorting is done on the first item in a list on tuple. To sort on other items use itemgetter from the operator module. See documentation here, focus on the students tuple example https //docs thon.org/3/howto/sorting.html g. Test the revised program. There are two sample documents available: "document1.txt" The Declaration of Independence) and "document2.txt" The Gettysburg Address)

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!