#!/bin/env python import time import sys # This is where the 'words' is. WORDS = '/usr/share/dict/words' # Make a dictionary W = file(WORDS).read().lower().split() WD = {} for w in W: WD[w] = 1 # text for the spell check text = file(sys.argv[1]).read() twords = text.split() nowords = [] start = time.time() print 'start %f' % start for w in twords: w = w.strip('.,;').lower() if not WD.has_key(w) and w not in nowords: nowords.append(w) stop = time.time() print 'stop %f' % stop print 'time %f' % (stop - start) print 'not in words %d' % len(nowords) # uncomment hereafter for result comparison #nowords.sort() #for w in nowords: # print w