Question: JAVA PROGRAMMING ASSIGNMENT In this project you will implement a bag of words (BoW). A BoW collects all words from input text files as a

JAVA PROGRAMMING ASSIGNMENT

In this project you will implement a bag of words (BoW). A BoW collects all words from input text files as a multi-set (meaning repeated words are maintained with multiplicity), and enables the calculation of certain statistics that help identify the importance of the words to a corpus (BoW). In this project you may represent it as a set (no repetition allowed) rather than a multi-set, while maintaining occurrence counts (frequencies). You should write a BoW class that is capable of doing the following:

1. (Required) Constructor: BoW(String text_file_name). This will create a BoW object initializing it with the words from the input text file.

2. (Required) Public Method 1: expand(String another_text_file_name). This will absorb into the BoW all words from the new text file.

3. (Required) Public Method 2: printTermFrequency(). This will print a list of all distinct words currently in the objects set, and their frequencies (number of occurrences).

4. (Bonus) Public Method 3: printInverseDocumentFrequency(). This will print a list of all distinct words currently in the objects set, and for each word, will print the ratio of the total number of documents (absorbed into the BoW so far) to the number of documents in which that word appears.

Sample Run

The text in bold preceded by > indicates sample user input. The rest is sample output from the program.

Please input a file name to initialize the BoW:

> file1.txt

Please select an operation from below:

1. Expand

2. Print term frequencies

3. Print inverse document frequencies

4. Exit

> 1

Please input a file name to expand the BoW:

> file2.txt

Done.

Please select an operation from below:

1. Expand

2. Print term frequencies

3. Print inverse document frequencies

4. Exit

> 2

Here are the term-frequencies so far:

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!