Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions