Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!