1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Crank
3 years ago
3

Jack just completed the program for the Flesch text analysis from this chapter’s case study. His supervisor, Jill, has discovere

d an error in his code. The error causes the program to count a syllable containing consecutive vowels as multiple syllables. Suggest a 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
"""
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')
text = inputFile.read()

# 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")

The given code needs to be edited to be correct.

Computers and Technology
2 answers:
balandron [24]3 years ago
6 0

Answer:

Check the explanation

Explanation:

CODE;

# Take the inputs.

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

inputFile = open(fileName, 'r')

text = inputFile.read()

# 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():

   if word[0] in vowels:

       syllables += 1

   for index in range(1, len(word)):

       if word[index] in vowels and word[index - 1] not in vowels:

           syllables += 1

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

       if word.endswith(ending):

           syllables -= 1

   if word.endswith('le'):

       syllables += 1

# Compute the Flesh 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")

====================================================

Kindly check the attached image below for the code screenshot and output.

Mandarinka [93]3 years ago
4 0

Answer:

see explaination

Explanation:

# Take the inputs.

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

inputFile = open(fileName, 'r')

text = inputFile.read()

# 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():

if word[0] in vowels:

syllables += 1

for index in range(1, len(word)):

if word[index] in vowels and word[index - 1] not in vowels:

syllables += 1

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

if word.endswith(ending):

syllables -= 1

if word.endswith('le'):

syllables += 1

# Compute the Flesh 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))

You might be interested in
Cú pháp câu lệnh xóa thủ tục
saw5 [17]

Answer:

DROP PROCEDURE procedure_name;

Explanation:

Cú pháp: Tên procedure bạn muốn xóa bỏ...

Ví dụ

DROP PROCEDURE spNhanvien;

4 0
3 years ago
How do I mark brainlyist
Katyanochek1 [597]

Answer:

You ask a question get at least two responses and you will see the button! Hope this helps, bye!

5 0
3 years ago
Read 2 more answers
Define the missing function. licenseNum is created as: (100000 * customID) licenseYear, where customID is a function parameter.
Mumz [18]

Answer:

Written in Python:

def licenseNum(licenseYear, customID):

    output = 100000 * customID + licenseYear

    print("Dog license: "+str(output))

 

Explanation:

This line defines the function with parameters licenseYear and customID

def licenseNum(licenseYear, customID):

This calculates the output as stated in the question

    output = 100000 * customID + licenseYear

This displays the output

    print("Dog license: "+str(output))

To call the function, make use of: licenseNum(2014, 777)

Where 2014 and 777 can be replaced with other digits as required

6 0
3 years ago
Click/press _______ to remove the most recently typed text.
Zolol [24]
D undo is the answer
7 0
4 years ago
Read 2 more answers
Narrowband Satellite Communications supports ______________ data rates for both mobile and fixed users by providing access on a
Mashcka [7]

Answer:

The correct answer to the following question will be "Safe and relatively low data and voice transmission".

Explanation:

Frequently, the word narrow band corresponds to ultra-high-frequency, S and L bands where the reasonable range is restricted compared to the bands of high-frequency.

  • It is desirable throughout the extremely-high-frequency, L-, including S-bands due to the beneficial propagation characteristics of the wavelengths.
  • Narrow band Satellite systems facilitate the efficient delivery of both wireless mobile networks at comparatively low bandwidths.

So, By the safe and low data transmission, it's the right answer.

4 0
3 years ago
Other questions:
  • True or False? When shooting OTS shots of two actors / subjects speaking to each other, it is best to place the camera(s) over t
    10·1 answer
  • The first step in the information processing cycle involves the _____ of data.
    10·1 answer
  • This type of handout prints only the text of the presentation.
    7·1 answer
  • Which of the following tasks is least effective at preventing a computer virus?
    7·1 answer
  • Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. Given a variable modelYear write a statement that prin
    9·1 answer
  • Which type of project data would you review for an accurate picture of the project progress and labor costs
    8·1 answer
  • D> Windows is the most popular for ​
    11·1 answer
  • A(n) ________ address is the address that external entities use when communicating with your network.
    11·1 answer
  • Lookups comes before Tags in the search-time operation sequence. True or False: Lookups can reference Tags.
    15·1 answer
  • Java Provide the command to call the calcCirArea() function using a value of 15 for the circle’s radius and storing the result
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!