Part B: Readability
This program will read in the contents of a text file containing a normal text document
and reorganize its contents by separately storing each sentence of the text.
For our purposes, the end of a sentence is marked by any word that ends with one of the three characters . ? !
Read in the lines of text, process them into words, and store them into an array (or, optionally, an ArrayList) of objects of your Sentence class. Each Sentence object should start out empty, and have words added to it as they are received from the file. Your Sentence class must contain at least the following:
- text— (String) the text of the sentence;
- wordCount— (int) the number of words in the sentence (only count words, where a word contains one or more letters); and
- add(String word)— add the given word to the sentence.
If you are storing the sentences in an array, you can assume that the text file contains at most 1000 sentences.
Once you have read in the contents of the file, process it in the following way:
- Print the first five sentences in the file. Number the sentences according to their sequence in the document (the first sentence is number 1).
- Print the last five sentences in the file. Number the sentences according to their sequence in the document.
- Print summary statistics over the entire document, including the number of letters (counting only letters, not digits, spaces, or other punctuation), words, and sentences, and the Automated Readability Index of the text. The ARI is calculated as follows: and provides an estimate of the readability of the text according to its grade level. Round it to one decimal place.
For example, given the following text file: