class_docstr: A simple query corrector based on a mapping of field names to
  :class:`Corrector` objects, and a list of ``("fieldname", "text")`` tuples
  to correct. And terms in the query that appear in list of term tuples are
  corrected using the appropriate corrector.
class_docstr_tok: ["A","simple","query","corrector","based","on","a","mapping","of","field","names","to",":","class",":","`","Corrector","`","objects",",","and","a","list","of","``","(","``","fieldname","''",",","``","text","''",")","``","tuples","to","correct",".","And","terms","in","the","query","that","appear","in","list","of","term","tuples","are","corrected","using","the","appropriate","corrector","."]
code: def correct_query(self, q, qstring):
      correctors = self.correctors
      aliases = self.aliases
      termset = self.termset
      prefix = self.prefix
      maxdist = self.maxdist
  
      # A list of tokens that were changed by a corrector
      corrected_tokens = []
  
      # The corrected query tree. We don't need to deepcopy the original
      # because we use Query.replace() to find-and-replace the corrected
      # words and it returns a copy of the query tree.
      corrected_q = q
  
      # For every word in the original query...
      # Note we can't put these in a set, because we must preserve WHERE
      # in the query each token occured so we can format them later
      for token in q.all_tokens():
          fname = token.fieldname
          aname = aliases.get(fname, fname)
  
          # If this is one of the words we're supposed to correct...
          if (fname, token.text) in termset:
              c = correctors[aname]
              sugs = c.suggest(
                  token.text, prefix=prefix, maxdist=maxdist
              )
              if sugs:
                  # This is a "simple" corrector, so we just pick the first
                  # suggestion :/
                  sug = sugs[0]
  
                  # Return a new copy of the original query with this word
                  # replaced by the correction
                  corrected_q = corrected_q.replace(
                      token.fieldname, token.text, sug
                  )
                  # Add the token to the list of corrected tokens (for the
                  # formatter to use later)
                  token.original = token.text
                  token.text = sug
                  corrected_tokens.append(token)
  
      return Correction(q, qstring, corrected_q, corrected_tokens)
  
imports: from bisect import bisect_left
  from heapq import heappush, heapreplace
  from whoosh import highlight
  from whoosh.compat import iteritems, xrange
label_desc: Use image node_id 2 for calling the SimpleQueryCorrector obj's underlying member method code with example usage: obj.correct_query(q, qstring) and returns: Correction