Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a program that will find out how many uniquewords appear in the text of a book, and for each word, find out howmany times

Develop a program that will find out how many uniquewords appear in the text of a book, and for each word, find out howmany times it is used. The words will be located in a textfile. The user will specify the name of the text file, or youmay allow the name to be a command-line argument. If the file failsto open, enter into dialog with the user to get the name of a filethat can be opened. Ignore all punctuation in thetext file not associated with a word. That is, ignore periods,commas, semicolons, colons, various parentheses, and exclamationpoints, as well as punctuation I haven't thought to mention. Do keep the apostrophe in can't. Treat words with apostrophes asdifferent unique words so that "street" is different from"street's"; also, treat plurals as different from their singularsand the various forms of verbs as different — this is a hashtable exercise, not a natural language parsing exercise.You may also treat numbers as words.

  1. Total number of collisions on insertions. A collision occurs when a word hashes to a location alreadyoccupied by another word. Hint: this means that theHashTable object requires a field to accumulate the totalcollisions when a word has not yet been entered into thetable.
  2. Average number of collisions per wordplacement. This is just the total number of collisionsdivided by the words placed into the hash table. Hint:this means that the HashTable object also requires a field toaccumulate the total words in the table.
Once the hash table is built, generate an outputfile whose name is based on the input file name followed by .csv(ex: War_Peace.txt.csv). Write to that file each word in the hashtable along with its number of occurrences. Use "csv" format inbuilding the file (surround the word with double quotes, followedby a comma and the number of occurrences).

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

Understanding Business Ethics

Authors: Peter A. Stanwick, Sarah D. Stanwick

3rd Edition

1506303234, 9781506303239

More Books

Students also viewed these Databases questions