CIT 591 Readability, Corrections, clarifications, suggestions
Fall 2009, David Matuszek
As I feared, there are significantly more problems than usual with this assignment.
getTotalSentenceCount, getTotalWordCount, getTotalComplexWordCount, and getTotalLetterCount--have no need for a parameter, and in fact shouldn't have one.I created a number of additional "helper" functions (all of which have corresponding tests), in order to help me write the required functions. You do not have to write these functions; but if you are having trouble, you might get some useful ideas from these.
findFirstTerminator(string):None if no terminator can be found.containsALetter(string):True if there is at least one letter somewhere in the string.getWords(string):normalizeWhitespace(string):removeUnwantedSuffixes(word):ed, es, and e (unless preceded by l) from the word.getListOfWords(string):getWordCount, getComplexWordCount, getSyllableCount, and getLetterCount.)countVowelSequences(word):y is counted as a vowel, unless it is the first letter.As mentioned in lab, if you put the following code at the bottom of your program, you can run the main() function by hitting F5 while editing the program, or load it and not run the main() function if you hit F5 while editing the test file.
if __name__ == '__main__': main()
Here are some of the things that have given me trouble; maybe they are giving you trouble too.
global statement when you are trying to modify global variables, otherwise you are just working with a local variable. An error message such as local variable 'totalComplexWordCount' referenced before assignment probably means you forgot to use global.setUp(self). If you do, this function will be called before each and every test function. If you don't, the results of a test function will depend on whatever tests happen to have been called earlier. So it's a good idea to define this function and have it restore the program to a pristine state; you can do this by having it call the (assigned) initialize() function.unittest must be given names that begin with test.test-, (2) give them self as a first parameter, (3) when you call them, prefix the call with self. and ignore that first parameter. For example, you might define a function as def getTestSentence(self, n) and call it with self.getTestSentence(6).