예제 #1
0
파일: results.py 프로젝트: mkc188/addok
def score_by_autocomplete_distance(helper, result):
    if not helper.autocomplete:
        return
    score = 0
    query = ascii(helper.query)
    for idx, label in enumerate(result.labels):
        label = ascii(label)
        result.labels[idx] = label  # Cache ascii folding.
        if equals(query, label):
            score = 1.0
        elif startswith(query, label):
            score = 0.9
        elif contains(query, label):
            score = 0.7
        if score:
            result.add_score('str_distance', score, ceiling=1.0)
    if not score:
        _score_by_str_distance(helper, result, scale=0.9)
예제 #2
0
파일: results.py 프로젝트: xlqian/addok
def score_by_autocomplete_distance(helper, result):
    if not helper._autocomplete:
        return
    score = 0
    query = ascii(helper.query)
    for idx, label in enumerate(result.labels):
        label = ascii(label)
        result.labels[idx] = label  # Cache ascii folding.
        if equals(query, label):
            score = 1.0
        elif startswith(query, label):
            score = 0.9
        elif contains(query, label):
            score = 0.7
        if score:
            result.add_score('str_distance', score, ceiling=1.0)
            if score >= config.MATCH_THRESHOLD:
                break
    if not score:
        _score_by_ngram_distance(helper, result)
예제 #3
0
def test_contains(candidate, target):
    assert contains(candidate, target)
예제 #4
0
def test_contains(candidate, target):
    assert contains(candidate, target)