def terms_within(self, fieldname, text, maxdist, prefix=0): if not self.has_word_graph(fieldname): # This reader doesn't have a graph stored, use the slow method return IndexReader.terms_within(self, fieldname, text, maxdist, prefix=prefix) gr = self._get_graph() return fst.within(gr, text, k=maxdist, prefix=prefix, address=self._graph.root(fieldname))
def _suggestions(self, text, maxdist, prefix): for sug in fst.within(self.graph, text, k=maxdist, prefix=prefix): # Higher scores are better, so negate the edit distance yield (0 - maxdist, sug)