Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA In this you are to implement a simplified version of the Flesch reading-ease test. Create a program called FleschReadingEase that meets the following requirements

JAVA

In this you are to implement a simplified version of the Flesch reading-ease test. Create a program called FleschReadingEase that meets the following requirements

1. Takes one argument from the command line. The name of the text file to read

a. If an invalid number of arguments is provided print

Usage: java FleschReadingEase filename

b. If the file doesn't exist print

FILE NOT FOUND

2. Implements the algorithm described below and prints the computed score

3. To help you develop the code you will be required to implement the following methods (all public and static):

a. getTokensFromFile

i. Input parameter: String

Filename to be read

ii. returns: String[]

Tokens of text in file

iii. Note: you need to implement error handling. Have the method throw FileNotFound Exception.

Your main method will have a try/catch block to handle any exception thrown by this method. See the class notes on using a try/catch block.

b. removeNonAlphabetCharacters

i. Input parameter: String

The original string possibly containing alphabet and non-alphabetic characters

ii. returns: String

A new string with all non-alphabetic characters removed

Hello! should return Hello

!@#$!goodbye<>: should return goodbye

You may find the Character.isLetter method helpful

c. getSentenceCount

i. Input parameter: String[]

Word tokens

ii. returns: int

Count of sentences using word counting algorithm listed below

d. getSyllableCount

i. Input parameter: String

A word

ii. returns: int

Count of syllables in word using the word counting algorithm listed below

e. getFleschScore

i. Input parameter: String[]

Tokenized input text

ii. returns: int

Calculated Flesch score using algorithm listed below

Algorithm Details

Count all tokens in the file. A token is any sequence of characters delimited by white space, whether or not it is an actual English word. There are multiple ways to do this. However, to make grading consistent you are to use a Scanner to generate tokens (which we assume to be words) using white space as the delimiter.

Count all syllables in each token. Use the following rules:

Vowels are: aeiouyAEIOUY

Each group of two vowels counts as one syllable (for example, the "ea" in "real" is one syllable.

Following our rules, the word you has two(2) syllables. The grouping of yo and the u

Each individual vowel that is not adjacent counts as one syllable ( for example, the "e .. a" in "regal" counts as two syllables).

However, an "e" or "E" at the end of a word doesn't count as a syllable.

Note: you will need to remove punctuation before counting syllables

Hint: use the removeNonAlphabetCharacters method

Also, each token has at least one syllable, even if the previous rules produce a count of 0.

Note: The above rules may not work in all cases and may produce incorrect syllable counts. There is no simple syllable counting method that works in all cases. These syllable rules apply to this assignment only.

Count all sentences. A sentence is ended by a period, colon, semicolon, question mark, or exclamation mark .:;?!. Assume the number of times these characters appear is equivalent to the number of sentences. ONLY count if the last character in the token is one of the punctuation marks.

The score is computed by the following formula rounded to the nearest integer.

Scores can be interpreted as shown in the table below.

Score

School level (US)

Notes

100 90

5th grade

Very easy to read. Easily understood by an average 11-year-old student.

90 80

6th grade

Easy to read. Conversational English for consumers.

80 70

7th grade

Fairly easy to read.

70 60

8th & 9th grade

Plain English. Easily understood by 13- to 15-year-old students.

60 50

10th to 12th grade

Fairly difficult to read.

50 30

College

Difficult to read.

30 10

College graduate

Very difficult to read. Best understood by university graduates.

10 0

Professional

Extremely difficult to read. Best understood by university graduates.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions