Flesch-Kincaid Grade Level Homework: Analyzing Text Files, Slides of Data Structures and Algorithms

A homework assignment where students are required to design and implement a program that calculates the flesch-kincaid grade level of a text file. The flesch-kincaid grade level indicates the approximate grade level of student that could understand the text. Students must consider functional-decomposition design, use meaningful variable names, add comments, and follow a main function structure. The document also provides definitions for sentences, words, syllables, and examples.

Typology: Slides

2012/2013

Uploaded on 04/30/2013

naji
naji 🇮🇳

4.3

(6)

87 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework #1 Data Structures
Flesch-Kincaid Grade Level Program
Design and implement a program that analyzes a text file to determine its Flesch-Kincaid grade level. The
Flesch-Kincaid grade level indicates the approximate grade level of student that could understand the text.
Alternatively, it indicates the number of years of education generally required to understand the text. The
Flesch-Kincaid grade level is calculated by the formula:
0.39 + 11.8 - 15.59
total number of words
total number of sentences
total number of syllables
total number of words
Use the following definitions for a sentence, word, syllable:
A sentence is considered to be any String ending in a '.', ':', ';', '?', or '!'. (Yes, I know this
allow sentences that do not represent gramatically correct English sentences)
A word is considered to be any elements of a sentence that is separated by spaces, tabs or new lines.
We’ll calculate the number of syllables in a word by counting the number of groups of adjacent vowels with
the exception of an 'e' appearing at the end of a word which does not count as a syllable. For example:
"simplicity" contains 4 syllables
"though" contains 1 syllable
"cleaning" contains 2 syllables
"yet" contains 1 syllable
“are" contains 1 syllable
"syllable" contains 2 syllables.
"able" contains 1 syllable.
All non-letter's such as digits and punctuation should be treated as non-vowels. For example:
"myString123" counts as 2 syllables.
"What?" counts as 1 syllable.
All words must have at least 1 syllable. So, if by the above calculations a word would have 0 syllables it
should be reported to have 1 syllable. For example:
"pqr132" counts as 1 syllable.
"X=227-314" counts as 1 syllable.
When you write your program, be sure you:
think about the functional-decomposition (top-down) design before you start to write code
use meaningful variable names with good style (i.e., useCamelCase)
use comments (""" Multi-line Comment """) at the start of the program and immediately after each
function definition describing what they do (see lab1 diceOutcomes.py program)
use a main function (see lab1 diceOutcomes.py program) located at the top of program with a call to
it at the bottom to start execution
use global constants where appropriate with good style (ALL_CAPS_AND_UNDERSCORES). (Put your
global constants after your initial comments describing the program and before your main function
definition so they can be found and changed easily in future versions of your program.)
allow the user to enter the file name to be analyzed and verify that the file name exsists (import os.path)
Submit your homework electronically at https://math-cs.cns.uni.edu/~schafer/submit/which_course.cgi
Submit the single file, hw1.zip containing the following:
hw1.py (your Python program)
design.doc (or design.pdf, or design.txt, or design.rtf) a document describing the design of your program
including a functional-decomposition diagram with text describing each function (see lab1 description)
Docsity.com

Partial preview of the text

Download Flesch-Kincaid Grade Level Homework: Analyzing Text Files and more Slides Data Structures and Algorithms in PDF only on Docsity!

Homework #1 Data Structures

Flesch-Kincaid Grade Level Program

Design and implement a program that analyzes a text file to determine its Flesch-Kincaid grade level. The Flesch-Kincaid grade level indicates the approximate grade level of student that could understand the text. Alternatively, it indicates the number of years of education generally required to understand the text. The Flesch-Kincaid grade level is calculated by the formula:

0.39 + 11.8 - 15.

total number of words total number of sentences

total number of syllables total number of words

Use the following definitions for a sentence, word, syllable:

A sentence is considered to be any String ending in a '.', ':', ';', '?', or '!'. (Yes, I know this allow sentences that do not represent gramatically correct English sentences)

A word is considered to be any elements of a sentence that is separated by spaces, tabs or new lines.

We’ll calculate the number of syllables in a word by counting the number of groups of adjacent vowels with the exception of an 'e' appearing at the end of a word which does not count as a syllable. For example:  "simplicity" contains 4 syllables  "though" contains 1 syllable  "cleaning" contains 2 syllables  "yet" contains 1 syllable “are" contains 1 syllable  "syllable" contains 2 syllables. "able" contains 1 syllable.

All non-letter's such as digits and punctuation should be treated as non-vowels. For example: "myString123" counts as 2 syllables. "What?" counts as 1 syllable.

All words must have at least 1 syllable. So, if by the above calculations a word would have 0 syllables it should be reported to have 1 syllable. For example: "pqr132" counts as 1 syllable. "X=227-314" counts as 1 syllable.

When you write your program, be sure you:  think about the functional-decomposition (top-down) design before you start to write code  use meaningful variable names with good style (i.e., useCamelCase)  use comments (""" Multi-line Comment """) at the start of the program and immediately after each function definition describing what they do (see lab1 diceOutcomes.py program)  use a main function (see lab1 diceOutcomes.py program) located at the top of program with a call to it at the bottom to start execution  use global constants where appropriate with good style (ALL_CAPS_AND_UNDERSCORES). (Put your global constants after your initial comments describing the program and before your main function definition so they can be found and changed easily in future versions of your program.)  allow the user to enter the file name to be analyzed and verify that the file name exsists (import os.path)

Submit your homework electronically at https://math-cs.cns.uni.edu/~schafer/submit/which_course.cgi

Submit the single file, hw1.zip containing the following:  hw1.py (your Python program)  design.doc (or design.pdf, or design.txt, or design.rtf) a document describing the design of your program including a functional-decomposition diagram with text describing each function (see lab1 description)

Docsity.com