In this program, you are going to implement a program that analyzes text files to generate some useful statistics. I will provide plain text versions of several books and articles (e.g. Alice in Wonderland, The Gettysburg Address, etc.) for you to analyze using your program.
For this project you are going to modify two classes.
The ProcessStatistics class will serve as the driver class with a main method which processes one or more files to determine some interesting statistics about them. The ProcessStatistics driver class should meet the following criteria,
Command-line validation. The names of the files to process will be given as command line arguments. Your driver class must,
Process command-line arguments. If valid filenames are given on the command line, your program will,
TextStatistics is a class that reads a given text file, parses it, and stores the generated statistics. The TextStatistics class should do the following,
Include instance variables. Include a reference to the processed File. Include variables for all of the statistics that are computed for the file. Look at the list of accessor methods in the TextStatisticsInterface to determine which statistics will be stored (accessor methods typically are named with the word “get” following by whatever information they are accessing)
Constructor. The constructor takes a File object as a parameter. The constructor should open the file and read the entire file line-by-line, processing each line as it reads it. Your constructor needs to handle the FileNotFoundException that can occur when the File is opened in a Scanner. Use a try-catch statement to do this. Don’t just throw the exception. As the file is read, your program must collect the following statistics,
Here is my (word)!
The length of “word” is 4, NOT 7.
Here, is another word!
The length of “Here” is again 4, not 5.
You program must ignore punction and only count the length of the words.
./autograde.sh
at the command prompt. A perfect run will display the following results, statsDisplay2.jpg