Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Question Also a reference link:https://eayd.in/?p=232 In this part, you will read a paragraph containing multiple English sentences as text from the user. Assume a

image text in transcribedPython Question

image text in transcribed

Also a reference link:https://eayd.in/?p=232

In this part, you will read a paragraph containing multiple English sentences as text from the user. Assume a period marks the end of a sentence. Read the paragraph as a single (long) line of text. Compute and print the following measures corresponding to the overall readability of this text. ASL (average sentence length) is given by the number of words per sentence. Print ASL. PHW (percent hard words): To compute this first count the number of words of three or more syllables that do not contain a hyphen (-) and three-syllable words that do not end with 'es' or ed. Divide this count by the total number of words in the text and multiply the result by 100 to get a percentage. Print PHW. Collect all words that are used in the PHW computation in a list exactly as they appear in the input, and print this list. ASYL (average number of syllables) is given by the total number of syllables divided by the total number of words. Print ASYL. GFRI is given by the formula 0.4+ (ASL + PHW). Print GFRI. FKRI is given by the formula 206.835-1.015*ASL-86.4*ASYL. Print FKRI. Note that the measures GFRI and FKRI are slightly modified versions of well-known readability measures named Gunning-Fog and Flesch Kincaid. In Gunning-fog, the higher the value calculated, the more difficult it is to read a text. For Flesch Kincaid it is the opposite with higher values indicating more easily read text. Enter a paragraph => We hold these truths to be self evident, that all men are created equal , that they are endowed by their creator with certain unalienable Rights that among these are Life , Liberty and the pursuit of Happiness. We hold these truths to be self-evident, that al men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness Here are the hard words in this paragraph ['urnalienable, liberty, "Mappiness Statistics. As 35.00 PHW857% ASYL:151 Readability index (GFRI); 1743 Readability index (FKRI). 40.48 Enter a paragraph => There is a theory which states that if ever anyone discovers exactly what the Liniverse is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened. There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened Here are the hard words in this paragraph [discovers', 'exactly, Universe, instantly, disappear something, "inexplicable another', 'already'] Statistics: ASL:23:50 PHW.19.15% ASYL:1.64 Readability index (GFRI) 17.06 Readability index (FKRI): 4143 A few things to get familiar with before solving this part. In this part, you must get familiar with a function called .split() that takes a piece of text, and converts it to a list of strings. Here is an example run: >>> line = "Citadel Morning News News about the Citadel in the morning, pretty self explanatory." >>> m = line.split() >>> m ['Citadel', 'Morning', 'News.', 'News', 'about', 'the', Citadel', 'in', 'the', 'morning,', 'pretty', 'self', 'explanatory.') You will also need to use the function find_num_syllables() from the file syllables.py which takes as input an English word as a string and that returns the total number of syllables in that word as an integer. The module works even if the word has punctuation symbols, so you do not need to remove those explicitly. Make sure you import this module appropriately into your program. >>> findnum-syllables ('computer') 3 >>> find num-syllables ('science') 1 >>> find.num-syllables ('introduction') 4 Clearly, the second result is incorrect. The module we provided is not a perfect implementation of syllable counting, so you may find errors. It is not your job to fix them, use the module as it is, with errors and all. Do not worry about the mistakes it makes. To properly compute this, we would need to use a Natural Language Processing (NLP) module like NLTK, which we have not installed in this course

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

How do books become world of wonder?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago