Question

I am having trouble with this problem. This is the question: Jack...

I am having trouble with this problem. This is the question:

Jack just completed the program for the Flesch text analysis from this chapter's case study. His supervisor, Jill, has discovered an error in his code. The error causes the program to count a syllable containing consecutive vowels as multiple syllables.

Suggest solution to this problem in Jack's code and modify the program so that it handles these cases correctly.

An example text and the program input and output is shown below:

example.txt

Or to take arms against a sea of troubles, And by opposing end them? To die: to sleep.

```Enter the file name: example.txt
The Flesch Index is 102.045
The Grade Level Equivalent is 1
3 sentences
18 words
21 syllables
```

This is what is already given to me:

"""

Program: textanalysis.py

Author: Ken

Computes and displays the Flesch Index and the Grade

Level Equivalent for the readability of a text file.

"""

# Take the inputs

fileName = input("Enter the file name: ")

inputFile = open(fileName, 'r')

# Count the sentences

sentences = text.count('.') + text.count('?') +

text.count(':') + text.count(';') +

text.count('!')

# Count the words

words = len(text.split())

# Count the syllables

syllables = 0

vowels = "aeiouAEIOU"

for word in text.split():

for vowel in vowels:

syllables += word.count(vowel)

for ending in ['es', 'ed', 'e']:

if word.endswith(ending):

syllables -= 1

if word.endswith('le'):

syllables += 1

# Compute the Flesch Index and Grade Level

index = 206.835 - 1.015 * (words / sentences) -

84.6 * (syllables / words)

level = int(round(0.39 * (words / sentences) + 11.8 *

(syllables / words) - 15.59))

# Output the results

print("The Flesch Index is", index)

print("The Grade Level Equivalent is", level)

print(sentences, "sentences")

print(words, "words")

print(syllables, "syllables")

Solved by verified expert

sum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus effi

gue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante

Explore over 16 million step-by-step answers from our library

Step-by-step explanation

Donec aliquet. Lorem ipsum dolor sit a

or nec facilisis. Pellentesque dapibus effic

molestie cons

onec aliquet. Lorem ipsum do

ac, dictum vitae odio. Donec

at, ultrices ac magna. Fusce

nec facilisis. Pellentesque dapib

ur laoreet. Nam risu

ipiscing elit. Na

itur laoreet. Nam risus ante, dapibus a m

sque dapibus efficitur laoreet.

icitur laoreet. Nam ri

risus ante, dapibus

, dictum vitae odio. Donec aliquet. Lorem ipsum d

ipsum dolor sit amet, consectetur adi

e vel laoreet

icitur laoreet. N

itur laoreet. Nam risus a

lestie consequat, ult

a molestie co

llentesque dapibus ef

pulvinar tortor nec fac

trices ac magna. Fusce dui lectus, congue ve

ur laoreet. Nam risus ante, dapibus a molestie

s a molestie consequat, ultrices ac magna. Fusce

s a molestie consequat, ultrices ac

fficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultric

ce dui lectus, congue vel laoreet a

, consec

, consectetur adipiscing elit. Nam lacin

entesque dapibus efficitur laoreet. Nam r

entesque dapibus efficitur laoreet. Na

acinia pulvinar tortor nec facilisis. P

risus ante, dapibus a molestie conse

ongue vel laoreet ac, dictum vitae odio. D

or nec facilisis. Pellentesque dapibus efficitur

a molestie consequat, ultr

sus ante, dapibus a molestie consequat, ultrices ac mag

e vel laoreet ac, dictum vit

lestie consequat, ul

a. Fusce dui lectus, congue vel lao

cing elit. Nam lacinia pulvinar tortor nec fa

itur laoreet. Nam risus ante,

pulvinar tortor nec

molestie consequat, ultrices

ec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing

ongue ve

3 Attachments
JPG
JPG
JPG
Student reviews
50% (4 ratings)