def simple_single_word_cand_gen(w, dictionary): return set(e1 for e1 in norvig.edits1(w) if e1 in dictionary)
def simple_word_cand_gen(w, dictionary): return set(e2 for e1 in norvig.edits1(w) for e2 in norvig.edits1(e1) if e2 in dictionary)
""" Let's see how big and spacey a dict of 1-edits of all words would be. """ import norvig as speller s = speller.Speller() s.load(open('bigdict')) edits = set() for i, word in enumerate(s.d): #if i % 1000: print '.', edits |= set(speller.edits1(word)) print '' print len(edits), sum(map(len, edits)), len(s.d)