def get_suggestions(self, word): recs = self.whisperer.findWildcard('%s*' % word) out = [] seen = {} for r in recs: seen[r['key']] = 1 out.append({'label': r['key'], 'value': r['key'], 'data': r['value']}) if len(out) < self.max_autocomplete: others = Whisperer.get_suggestions(self, word) i = 0 while len(out) < self.max_autocomplete and i < len(others): x = others[i] if x['label'] not in seen: out.append(x) i += 1 return out
def __init__(self, *args, **kwargs): Whisperer.__init__(self, *args, **kwargs) self.whisperer.setAccuracy(0.5)