Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help!!! Task 2: a) Write a function that accepts a file name, counts the frequencies of all the words, and returns the result as a
Help!!!
Task 2: a) Write a function that accepts a file name, counts the frequencies of all the words, and returns the result as a dictionary with words as keys and frequencies as values. b) Use the provided text file (alice.txt) as your input file to your function in step a), and Obtain the word frequencies in the book Alice in Wonderland by Lewis Carrol. Write the following information to an output file ('most_frequent_alice.txt'): i. Total number of unique words in the book ii. Top 20 most used words and their frequencies Tips: For small paragraph and/or a single string, it is okay to process the whole paragraph/string at once. However, for larger documents, it is better to process each line at a time. Convert everything to lower case, as such, Cat' and cat will be considered as same word. Remove punctuations and special symbols from your text. Use the following code to achieve that: # replace each punctuation character with a space for ch in '!"#$%& () *+,-./:;?Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started