def LanguageFacet(locale_ident, extra_weights={}):
 def score(searcher, docnum):
  doc = searcher.stored_fields(docnum)
  weight = extra_weights.get(doc['name'], 1.0)
  doc_language = doc['language']
  if (doc_language == locale_ident):
   weight *= 2.0
  elif (doc_language == u'roomaji'):
   weight *= 1.4
  return (- weight)
 return whoosh.sorting.FunctionFacet(score)

def LanguageFacet ( locale_ident , extra_weights = { } ) : def score ( searcher , docnum ) : doc = searcher . stored_fields ( docnum ) weight = extra_weights . get ( doc [ 'name' ] , 1.0 ) doc_language = doc [ 'language' ] if ( doc_language == locale_ident ) : weight *= 2.0 elif ( doc_language == u'roomaji' ) : weight *= 1.4 return ( - weight ) return whoosh . sorting . FunctionFacet ( score )
constructs a sorting function that bubbles results from the current locale to the top of the list .