#!/usr/bin/env python ## $Id: misspels.py,v 1.3 2003/02/07 07:25:38 quarl Exp $ ## Spell check a document given Nadia's speling.py. import nadiah_speling import re nadiah_speling.import_dictionary("dict.txt") global input, word, words word = words = None input = open('input.txt') def get_next_word(): global input, word, words word = None while 1: while words: word = words[0] words = words[1:] if word: return word line = input.readline() if not line: return None words = re.split('[^A-Za-z]+', line) bad_words = {} while get_next_word(): if not nadiah_speling.exists(word): bad_words[word] = bad_words.get(word, 0) + 1 for word in bad_words: print "%s (%d)" % (word, bad_words[word])