Using Python!! You are to create a program that analyzes a text file and produce
ID: 3839212 • Letter: U
Question
Using Python!!
You are to create a program that analyzes a text file and produces the following statistics:
• lexical richness of the text – percentage of unique words in the text (ratio of vocab words to all words in the text)
• word length frequency information for words of any length: how many words of length 2, length 3, length 4, etc appear in the vocabulary.
• text Flesch index and the text grade level – explained below
• the concordance of the word entered by the user – explained below
Flesch index and the grade level
The Flesch/Flesch–Kincaid readability tests are readability tests designed to indicate comprehension difficulty when reading a passage of contemporary academic English. The index is based on the average number of syllables per word and the average number of words per sentence in a piece of text.Index scores usually range from 0 to 100, and are calculated using the following formula:
206.8351.015((total words)/(total sentences))84.6((total syllables)/(total words))
Definitions of terms such as word and sentence have been already provided above. As far as syllables are concerned, we will use the following rules:• each vowel (a e i o u) is considered a syllable unless it occurs in -es, -ed, or -e ending• any word of length 3 or less counts as one syllableThe grade level is calculated using the following formula:
0.39((total words)/(total sentences))+11.8((total syllables)/ (total words))15.59
Note that the definitions of syllables, words, and sentence we are using are approximations of the actual syllables, words, and sentences in any natural language.
Concordance
A concordance is an alphabetical list of the principal words used in a book or body of work, with their immediate contexts. For the purpose of this assignment, your program is to ask the user for one word only and produce all the lines in which the word appears in the original text, for example, if the word nation is entered when processing the text of Gettysburg Address, it results in the following concordance phrases:
"continent a new nation, conceived in liberty and dedicated to the a great civil war, testing whether that nation or any nation so lives that that nation might live. it is altogether fitting and nation under god shall have a new birth of freedom, and that"
P.S
please don't post if the program doesn't work
Explanation / Answer
# Store input numbers num1 = input('Enter first number: ') num2 = input('Enter second number: ') # Add two numbers sum = float(num1) + float(num2) # Display the sum print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.