Esempio n. 1
0
def deindex_edge_ngrams(token):
    for ngram in compute_edge_ngrams(token):
        DB.srem(edge_ngram_key(ngram), token)
Esempio n. 2
0
def test_compute_edge_ngrams_honor_max_edge_ngrams_setting(config):
    config.MAX_EDGE_NGRAMS = 5
    assert compute_edge_ngrams('abcdefghijklmn') == ['abc', 'abcd', 'abcde']
Esempio n. 3
0
def index_edge_ngrams(pipe, token):
    for ngram in compute_edge_ngrams(token):
        pipe.sadd(edge_ngram_key(ngram), token)
Esempio n. 4
0
def test_compute_edge_ngrams():
    assert compute_edge_ngrams('vanbrechi') == [
        'van', 'vanb', 'vanbr', 'vanbre', 'vanbrec', 'vanbrech'
    ]
Esempio n. 5
0
def test_compute_edge_ngrams_honor_min_edge_ngrams_setting(config):
    config.MIN_EDGE_NGRAMS = 1
    assert compute_edge_ngrams('abcd') == ['a', 'ab', 'abc']
Esempio n. 6
0
def deindex_edge_ngrams(token):
    for ngram in compute_edge_ngrams(token):
        DB.srem(edge_ngram_key(ngram), token)
Esempio n. 7
0
def index_edge_ngrams(pipe, token):
    for ngram in compute_edge_ngrams(token):
        pipe.sadd(edge_ngram_key(ngram), token)
Esempio n. 8
0
def test_compute_edge_ngrams_honor_min_edge_ngrams_setting(config):
    config.MIN_EDGE_NGRAMS = 1
    assert compute_edge_ngrams('abcd') == ['a', 'ab', 'abc']
Esempio n. 9
0
def test_compute_edge_ngrams():
    assert compute_edge_ngrams('vanbrechi') == [
        'van', 'vanb', 'vanbr', 'vanbre', 'vanbrec', 'vanbrech'
    ]
Esempio n. 10
0
def test_compute_edge_ngrams_honor_max_edge_ngrams_setting(config):
    config.MAX_EDGE_NGRAMS = 5
    assert compute_edge_ngrams('abcdefghijklmn') == ['abc', 'abcd', 'abcde']