Question: Write a function called generate_frequency_table(filename) which accepts the name of a text file and returns a dictionary containing the frequency of all the letters that


Write a function called generate_frequency_table(filename) which accepts the name of a text file and returns a dictionary containing the frequency of all the letters that appear in the file. For purposes of the frequency count, any non-letter characters are ignored, and the difference between upper and lower case letters is ignored (i.e., treat all letters as lower case). You may wish to break the task up further and use several smaller functions to achieve this task. For example, it might be convenient to have functions to perform each of the following tasks: . read and return the contents of a text file remove all non-letter characters from a given string perform a frequency count of letters in a given string Hint: The string class has an attribute called asci_letters which is a string containing all the letters. You can access that string using: import string letters -string.ascii_letters For example: Test Result data -generate_frequency_table('test 01.txt') print data'a': 2, 's': 1, 'm': 1, 'l': 3, 't': 2, 'e': 2, 'x": 1, 'f': 1,'ue i: 13) Tr data - generate_frequency_tableC'test_02.txt') print(data'a 4, 's': 3, 'm': 1, 'l': 5, 't': 5, 'e: 4, 'x': 1, 'f': 1, ' Tr ue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
