Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In part 2 you are going to create word count statistics for a book. Your program will process all of the lines in a book

In part 2 you are going to create word count statistics for a book. Your program will process all of the lines in a book and provide a summary report about the different words in the book.

Clean the words before doing any processing on them:

  1. Remove leading and trailing whitespace on each word (use the strip() function),
  2. Remove the characters ,.!?'": (use the replace() function),
  3. Compare the words in a case-insensitive way (use the lower() function or the casefold() function)

Track the frequency of all the words in the books. Print out the following statistics:

  1. Total number of words in the book
  2. Number of unique words in the book (words that appear only once)
  3. Number of distinct words in the book (all words without duplication)
  4. Most used word out of all words in the book (the word that appears most frequently)

Sample output for frankenstein.txt:

What's the name of the book? frankenstein.txt Summarizing [frankenstein.txt] There are 76581 total words. There are 3961 unique words. There are 8187 distinct words. Most word used is [the] with 4241 uses Programmed by the Instructors Date: Tue Feb 5 11:33:05 2019 End of processing

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

D How will your group react to this revelation?

Answered: 1 week ago