You are to implement a TextAnalyzer class that count the frequency of words in a paragraph of text. Internally, the TextAnalyzer will use a Tokenizer, HashMap and

Priority Queue for implementation of its functionality.

The TextAnalyzer class provides a constructor which takes in a file name and reads the text from that file. The constructor will read the text from the file and

tokenizes it.

The class uses a HashMap to count the frequency of each word encountered (note that each word is treated as unique regardless of the underlying stem – that is run,

runs, and running are all treated as unique words).

The use a PriorityQueue to sort the words – either by the frequency of word occurrence or by the lexicographic ordering of the words.

Two functions – FreqSort() and LexiSort() respectively print out the word frequencies sorted by the frequency of word occurrence, and by the lexicographic order.

Shown below is the main program illustrating the manner in which your class will be instantiated and the functions will be called.

Sample input and output, as well as are provided.

public static void main(String[] args) {
TextAnalyzer txtA = new TextAnalyzer(args[0]);
System.out.println (“Number of words found = ” + txtA.wordCount()); System.out.println (“Word and frequencies sorted by word frequencies”); txtA.FreqSort();
System.out.println (“Word and frequencies sorted lexicographically by words”); txtA.LexiSort();


Submission: 2 files:

Java Class File: TextAnalyzer.Java which will implements the functionality needed by the Main.Java program above (and provided to you).

Report (DOC or PDF file) discussing –

Time and Space Complexity of building Hash Table in terms of the number of words in the

text file (n)

Time and Space Complexity of FreqSort() and LexiSort() functions

find the cost of your paper