import speling def tokenize(line): """Takes each line and returns a list of all the words in that line with the pronounciation stripped.""" words = line.strip().split() wordlist = [] for word in words: newword = stripPunctuation(word) if isWord(newword): wordlist.append(newword) return wordlist # Main Program misspelled = {} input = open('input.txt') for line in input: wordlist = tokenize(line) for word in wordlist: if not search(word): # word was not found in dictionary if word in misspelled: misspelled[word] = misspelled[word] + 1 else: misspelled[word] = 1 # Print words and number of occurences in alphabetical order. words = misspelled.keys() words.sort() for word in words: print word + " (" + str(misspelled[word]) + ")"