Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rewrite textanalysis.py with functions: main, countSentences, countWords, countSyllables. Test it with plain.txt. Here is the code for text analysis.py import os # Take the inputs

Rewrite textanalysis.py with functions: main, countSentences, countWords, countSyllables. Test it with plain.txt.

Here is the code for text analysis.py

import os # Take the inputs fileName = input("Enter the file name: ") while not os.path.exists(fileName): fileName = input("Files does not exist, 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 wordslist = text.split() words = len(wordslist)

# Count the syllables syllables = 0 vowels = "aeiouAEIOU"

# Generate double vowels doubleVowels = [] for v1 in vowels: temp = [] for v2 in vowels: doubleVowels.append(v1+v2) for word in wordslist: for vowel in vowels: syllables += word.count(vowel) for dv in doubleVowels: syllables -= word.count(dv) 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")

you could test the code using whatever Im just stuck on one part and I want to compare it with somebody else's code but if you want the plane. txt is below

The objective of this paper is to develop a mechanism to increase the lifetime of homogeneous wireless sensor networks (WSNs) through minimizing long range communication, efficient data delivery and energy balancing. Energy efficiency is a very important issue for sensor nodes which affects the lifetime of sensor networks. To achieve energy balancing and maximizing network lifetime we divided the whole network into different clusters. In cluster based architecture, the role of aggregator node is very crucial because of extra processing and long range communication. Once the aggregator node becomes non functional, it affects the whole cluster. We introduced a candidate cluster head node on the basis of node density. We proposed a modified cluster based WSN architecture by introducing a server node (SN) that is rich in terms of resources. This server node (SN) takes the responsibility of transmitting data to the base station over longer distances from the cluster head. We proposed cluster head selection algorithm based on residual energy, distance, reliability and degree of mobility. The proposed method can save overall energy consumption and extend the lifetime of the sensor network and also addresses robustness against even/uneven node deployment.

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

Big Data And Hadoop Fundamentals Tools And Techniques For Data Driven Success

Authors: Mayank Bhushan

2nd Edition

9355516665, 978-9355516664

More Books

Students also viewed these Databases questions

Question

Describe how to train managers to coach employees. page 404

Answered: 1 week ago

Question

Discuss the steps in the development planning process. page 381

Answered: 1 week ago