The Flesch Reading Ease test is generally regarded as the most accurate score to express how quickly a particular English text can be read. Several U.S. government agencies use this test to check the readability of their documents. For example, the State of Florida requires a minimum Flesch Reading Ease score of 45 for life insurance contracts. The score was also built in into several popular word processors such as Microsoft Office Word and WordPerfect. The Flesch Reading Ease formula goes as follows: \[FRES=206.835 -1.015 \times \frac{\text{total words}}{\text{total sentences}} - 84.6 \times \frac{\text{total syllables}}{\text{total words}} \] The result of the formula is the Flesch Reading Ease Score (FRES). The higher the FRES, the easier it is to understand the text. A score between 0 and 30 is considered to be readable for university graduates. A text with a score between 60 and 70 should be readable for pupils from 13-15 years, and a score between 90 and 100 should be readable for pupils at the end of primary school. The highest (easiest) readability score is about 120, this is achieved when each sentence is composed of two monosyllabic words. The score has no theoretical limit. It is always possible to reduce the score by adding words with many syllables.

Although the application of FRES seems simple, we still have to clearly formulate how sentences, words and syllables are counted. Sentences are separated by punctuation marks: periods(.), exclamation marks(!), question marks(?), colons(:) and semicolons (;). The fragment after the last punctuation mark should also be counted as a sentence, unless the fragment is empty or consists only of white space. Each group of consecutive letters (a-z, A-Z) forms a separate word. In English texts an apostrophe (') is exclusively used to indicate a contraction of two words. The fragment "It's" thus contains two words. To count syllables the following rules are applied:

Assignment

The aim of this assignment is to determine the Flesch Reading Ease score of the text in a given text file. To do this, follow these steps.

Example

In the example session below the Flesch Reading Ease score is calculated of a couple sentences of chapter 64 from the classic Moby Dick1 by Herman Melville. These sentences can be found in the text file moby_dick.txt2.

>>> syllables('reliable')
3
>>> syllables('creature')
2
>>> syllables('three')
1

>>> words('The Australian platypus is seemingly a hybrid of a mammal and reptilian creature.')
(13, 24)
>>> words("Stubb's whale had been killed some distance from the ship.")
(11, 13)

>>> sentences('moby_dick.txt')
(12, 220, 298)

>>> FRES(12, 220, 298)
73.63212121212123