首页 > > 详细

辅导Python程序、讲解data编程、Python编程调试 解析Java程序|讲解数据库SQL

项目预算:   开发周期:  发布时间:   要求地区:
Modul e 10 Lab: Ex c eption Handl ing
In this assignment, you are asked to use what we have covered in Modules 1-10 to calculate
the Flesch readability index of a document. Invented by Dr. Rudolf Flesch, the Flesch readability
index is a tool for estimating how difficult a document is to read and comprehend. The index
does not consider the meaning of words, only their lengths and the lengths of sentences, in
order to assign a readability index to the document. The higher the readability index, the easier
a document is to comprehend.
U n d e r s t a n d i n g F l e s c h I n d e x
Flesch index is calculated using the following formula:
Once calculated, this index can be translated into the educational level that is usually necessary
to understand a document, as shown in the table below.
Flesch Index (F) Grade Level (G) Example
90.0-100.0 5th Grader Comic
80.0-89.9 6th Grader Consumer ads
70.0-79.9 7th Grader Alice in Wonderland
65.0-69.9 8th Grader Sports Illustrated
50.0-64.9 High schooler Time Magazine
30.0-49.9 College New York Times
0.0-29.9 College graduate Auto Insurance
< 0.0 Law school graduate IRS tax code
Wo r d s a n d s e n t e n c e s
A character is any symbol in the text file. Examples of characters include letters, numerical
digits, hyphens, and punctuation marks but not whitespace characters (e.g, spaces, tabs,
new-line characters).
Words are sequences of characters that are separated by whitespace.
Sentences are separated by a period, question mark, exclamation point, colon or semicolon.
S y l l a b l e s

𝐹 = 206.835 − 1.015 × (𝑤𝑜𝑟𝑑𝑠/𝑠𝑒𝑛𝑡𝑒𝑛𝑐𝑒) − 84.6 × (𝑠𝑦𝑙𝑙𝑎𝑏𝑙𝑒𝑠/𝑤𝑜𝑟𝑑)
2021/3/28 Module 10 Lab
https://northeastern.instructure.com/courses/63364/assignments/827242 3/5
It is difficult to determine the exact number of syllables in a word just from the spelling. However,
we can do a pretty good job using the following heuristics:
Count up the groups of adjacent vowels (aeiouy) in the word. (Note that the letter 'y' is
considered a vowel for this algorithm)
If 'e' is the last letter in the word and is preceded by a non-vowel, then it does not count as a
syllable (i.e., the 'e' is silent). For example, "life" has only 1 syllable, while "alumnae" has 3
Under the previous 2 rules "me" would have zero syllables since the 'e' at the end of the
word isn't considered a syllable. To address this, always report that there is at least 1
syllable
If you apply these rules, then Creighton has 2 syllables, "University" has 5, and "sea" has 1.
Don't worry if the answer given by your program isn't exactly the correct number of syllables.
This is a heuristic after all. Rather make sure your program produces values that agree with the
heuristic described above.
Wha t to do
readability.zip
Your job will be to implement the functions that are required by the provided driver program. You
should implement the indicated functions in the provided "readability.py" module (we highly
recommend implementing tests for your functions as well). Then you should modify the driver
program so that any errors that are raised by your modules are handled by printing an
appropriate message to the screen.
Additionally, I am providing a number of example documents that you can use to test various
aspects of your program. Each file has a different challenge that your program should be able to
handle.
To help clarify what the main() function is supposed to do consider the following runs of the
program:
Case 1: In case the user tries to open a non-existing file
Filename: abc.txt
abc.txt does not exist
Case 2: In case the user tries to open a file that he does not have permission to open
Filename: abc.txt
You do not have sufficient permissions to open abc.txt
Case 3: In case of any operating system error
2021/3/28 Module 10 Lab
https://northeastern.instructure.com/courses/63364/assignments/827242 4/5
Filename: abc.txt
An unexpected error occurred while attempting to open abc.txt.
Case 4: Using the "college.txt" example
Filename: college.txt
Sentences: 1
Words: 15
Syllables: 31
Words per Sentence: 15.0
Syllables per Word: 2.1
Flesch Index: 16.8
Flesch Grade: College graduate
Case 5: Using the "sixth-grade.txt" example
Filename: sixth-grade.txt
Sentences: 2
Words: 29
Syllables: 37
Words per Sentence: 14.5
Syllables per Word: 1.3
Flesch Index: 84.2
Flesch Grade: 6th grader
Case 6: Using the "gettysburg.txt" example
Filename: gettysburg.txt
Sentences: 11
Words: 282
Syllables:400
Words per Sentence: 25.6
Syllables per Word: 1.4
Flesch Index: 60.8
Flesch Grade: High schooler
There are a couple more provided files that we will leave for you to figure out on your own!
Your test suite should be implemented in a file called "readability_tests.py" and should make
sure that the functions in the readability module work correctly. The goal here is to write tests
so that you have confidence in your own work. Write enough tests with enough variety that you
would feel comfortable handing your indexer off to the Editor of the Addison-Wesley Publishing
Company saying, "Don't worry it works great!"
2021/3/28 Module 10 Lab
https://northeastern.instructure.com/courses/63364/assignments/827242 5/5
Submi s s ion
When your program successfully passes your tests locally, upload it to codePost and make sure
it passes the visible test cases there and that you are following the style guidelines for Modules
1-10.
 完成

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!