class_docstr: Uses an ExpansionModel to expand the set of query terms based on the top
  N result documents.
docstr: :param reader: A :class:whoosh.reading.IndexReader object.
  :param fieldname: The name of the field in which to search.
  :param model: (classify.ExpansionModel) The model to use for expanding
      the query terms. If you omit this parameter, the expander uses
      :class:`Bo1Model` by default.
docstr_tok: [":","param","reader",":","A",":","class",":","whoosh.reading.IndexReader","object",".",":","param","fieldname",":","The","name","of","the","field","in","which","to","search",".",":","param","model",":","(","classify.ExpansionModel",")","The","model","to","use","for","expanding","the","query","terms",".","If","you","omit","this","parameter",",","the","expander","uses",":","class",":","`","Bo1Model","`","by","default","."]
code: def __init__(self, ixreader, fieldname, model=Bo1Model):
      """
      :param reader: A :class:whoosh.reading.IndexReader object.
      :param fieldname: The name of the field in which to search.
      :param model: (classify.ExpansionModel) The model to use for expanding
          the query terms. If you omit this parameter, the expander uses
          :class:`Bo1Model` by default.
      """
  
      self.ixreader = ixreader
      self.fieldname = fieldname
      doccount = self.ixreader.doc_count_all()
      fieldlen = self.ixreader.field_length(fieldname)
  
      if type(model) is type:
          model = model(doccount, fieldlen)
      self.model = model
  
      # Maps words to their weight in the top N documents.
      self.topN_weight = defaultdict(float)
  
      # Total weight of all terms in the top N documents.
      self.top_total = 0
  
imports: from __future__ import division
  import random
  from collections import defaultdict
  from math import log
  from whoosh.compat import xrange, iteritems
label_desc: Use image node_id 1 to create a new Expander object from inherited base classes: object with example: obj = Expander(ixreader, fieldname, model)