def add_spelling(ix, fieldnames, commit=True):
 from whoosh.filedb.filereading import SegmentReader
 writer = ix.writer()
 storage = writer.storage
 schema = writer.schema
 segments = writer.segments
 for segment in segments:
  filename = segment.dawg_filename
  r = SegmentReader(storage, schema, segment)
  f = storage.create_file(filename)
  dawg = DawgBuilder(field_root=True)
  for fieldname in fieldnames:
   ft = (fieldname,)
   for word in r.lexicon(fieldname):
    dawg.insert((ft + tuple(word)))
  dawg.write(f)
 for fieldname in fieldnames:
  schema[fieldname].spelling = True
 if commit:
  writer.commit(merge=False)

def add_spelling ( ix , fieldnames , commit = True ) : from whoosh . filedb . filereading import SegmentReader writer = ix . writer ( ) storage = writer . storage schema = writer . schema segments = writer . segments for segment in segments : filename = segment . dawg_filename r = SegmentReader ( storage , schema , segment ) f = storage . create_file ( filename ) dawg = DawgBuilder ( field_root = True ) for fieldname in fieldnames : ft = ( fieldname , ) for word in r . lexicon ( fieldname ) : dawg . insert ( ( ft + tuple ( word ) ) ) dawg . write ( f ) for fieldname in fieldnames : schema [ fieldname ] . spelling = True if commit : writer . commit ( merge = False )
adds spelling files to an existing index that was created without them .