MCPcopy Index your code
hub / github.com/dbcli/pgcli / test_ranking_based_on_shortest_match

Function test_ranking_based_on_shortest_match

tests/test_fuzzy_completion.py:31–49  ·  view source on GitHub ↗

Fuzzy result rank should be based on shortest match. Result ranking in fuzzy searching is partially based on the length of matches: shorter matches are considered more relevant than longer ones. When searching for the text 'user', the length component of the match 'user_group' could

(completer)

Source from the content-addressed store, hash-verified

29
30
31def test_ranking_based_on_shortest_match(completer):
32 """Fuzzy result rank should be based on shortest match.
33
34 Result ranking in fuzzy searching is partially based on the length
35 of matches: shorter matches are considered more relevant than
36 longer ones. When searching for the text 'user', the length
37 component of the match 'user_group' could be either 4 ('user') or
38 7 ('user_gr').
39
40 This test checks that the fuzzy ranking algorithm uses the shorter
41 match when calculating result rank.
42
43 """
44
45 text = "user"
46 collection = ["api_user", "user_group"]
47 matches = completer.find_matches(text, collection)
48
49 assert matches[1].priority > matches[0].priority
50
51
52@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

find_matchesMethod · 0.80

Tested by

no test coverage detected