def complete(self, instring, limit=0, redirected=False): """ Wrapper for Completions object - prioritizes and aggregates completion results. In the case where there are no results, tries to swap keyboards and get completion results from the other language. :param instring: :param limit: Number of results. 0 is unlimited. :param redirected: Is this request redirected from the other language? Prevents infinite loops. :return: completions list, completion objects list """ instring = instring.strip( ) # A terminal space causes some kind of awful "include everything" behavior if len(instring) >= self.max_completion_length: return [], [] cm = Completions( self, self.lang, instring, limit, do_autocorrect=len(instring) < self.max_autocorrect_length) cm.process() if cm.has_results(): return cm.get_completion_strings(), cm.get_completion_objects() # No results. Try letter swap if not redirected and self.other_lang_ac: swapped_string = hebrew.swap_keyboards_for_string(instring) return self.other_lang_ac.complete(swapped_string, limit, redirected=True) return [], []
def complete(self, instring, limit=0, redirected=False): """ Wrapper for Completions object - prioritizes and aggregates completion results. In the case where there are no results, tries to swap keyboards and get completion results from the other language. :param instring: :param limit: Number of results. 0 is unlimited. :param redirected: Is this request redirected from the other language? Prevents infinite loops. :return: """ instring = instring.strip( ) # A terminal space causes some kind of awful "include everything" behavior completions = Completions(self, self.lang, instring, limit).process() if len(completions): return completions # No results. Try letter swap if not redirected and self.other_lang_ac: swapped_string = hebrew.swap_keyboards_for_string(instring) return self.other_lang_ac.complete(swapped_string, limit, redirected=True) return []