1 | import speling |
2 | |
3 | def tokenize(line): |
4 | """Takes each line and returns a list of all the words in that line |
5 | with the pronounciation stripped.""" |
6 | words = line.strip().split() |
7 | wordlist = [] |
8 | for word in words: |
9 | newword = stripPunctuation(word) |
10 | if isWord(newword): |
11 | wordlist.append(newword) |
12 | return wordlist |
13 | |
14 | |
15 | # Main Program |
16 | misspelled = {} |
17 | input = open('input.txt') |
18 | for line in input: |
19 | wordlist = tokenize(line) |
20 | for word in wordlist: |
21 | if not search(word): # word was not found in dictionary |
22 | if word in misspelled: |
23 | misspelled[word] = misspelled[word] + 1 |
24 | else: |
25 | misspelled[word] = 1 |
26 | # Print words and number of occurences in alphabetical order. |
27 | words = misspelled.keys() |
28 | words.sort() |
29 | for word in words: |
30 | print word + " (" + str(misspelled[word]) + ")" |