Ejemplo n.º 1
0
def do_fuzzy(self, word):
    """Compute fuzzy extensions of word.
    FUZZY lilas"""
    word = list(preprocess_query(word))[0]
    fuzzy = make_fuzzy(word)
    print(white(fuzzy))
    print(blue("{} items".format(len(fuzzy))))
Ejemplo n.º 2
0
def pair(word):
    """See all token associated with a given token.
    PAIR lilas"""
    word = list(preprocess_query(word))[0]
    key = pair_key(word)
    tokens = [t.decode() for t in DB.smembers(key)]
    tokens.sort()
    print(white(tokens))
    print(magenta('(Total: {})'.format(len(tokens))))
Ejemplo n.º 3
0
def pair(cmd, word):
    """See all token associated with a given token.
    PAIR lilas"""
    word = list(preprocess_query(word))[0]
    key = pair_key(word)
    tokens = [t.decode() for t in DB.smembers(key)]
    tokens.sort()
    print(white(tokens))
    print(magenta('(Total: {})'.format(len(tokens))))
Ejemplo n.º 4
0
def do_fuzzyindex(self, word):
    """Compute fuzzy extensions of word that exist in index.
    FUZZYINDEX lilas"""
    word = list(preprocess_query(word))[0]
    token = Token(word)
    neighbors = make_fuzzy(token)
    neighbors = [(n, DB.zcard(dbkeys.token_key(n))) for n in neighbors]
    neighbors.sort(key=lambda n: n[1], reverse=True)
    for token, freq in neighbors:
        if freq == 0:
            break
        print(white(token), blue(freq))
Ejemplo n.º 5
0
def do_fuzzyindex(self, word):
    """Compute fuzzy extensions of word that exist in index.
    FUZZYINDEX lilas"""
    word = list(preprocess_query(word))[0]
    token = Token(word)
    token.make_fuzzy()
    neighbors = [(n, DB.zcard(dbkeys.token_key(n))) for n in token.neighbors]
    neighbors.sort(key=lambda n: n[1], reverse=True)
    for token, freq in neighbors:
        if freq == 0:
            break
        print(white(token), blue(freq))
Ejemplo n.º 6
0
def do_fuzzy(self, word):
    """Compute fuzzy extensions of word.
    FUZZY lilas"""
    word = list(preprocess_query(word))[0]
    print(white(make_fuzzy(word)))
Ejemplo n.º 7
0
def do_AUTOCOMPLETE(cmd, s):
    """Shows autocomplete results for a given token."""
    s = list(preprocess_query(s))[0]
    keys = [k.decode() for k in DB.smembers(edge_ngram_key(s))]
    print(white(keys))
    print(magenta('({} elements)'.format(len(keys))))
Ejemplo n.º 8
0
def do_autocomplete(self, s):
    """Shows autocomplete results for a given token."""
    s = list(preprocess_query(s))[0]
    keys = [k.decode() for k in DB.smembers(edge_ngram_key(s))]
    print(white(keys))
    print(magenta('({} elements)'.format(len(keys))))
Ejemplo n.º 9
0
def do_fuzzy(self, word):
    """Compute fuzzy extensions of word.
    FUZZY lilas"""
    word = list(preprocess_query(word))[0]
    print(white(make_fuzzy(word)))