Fuzzy name matching for the "Perhaps you meant ..." hints, modelled on the
fuzzyset library PostgREST uses: gram-count cosine similarity (gram size 3,
then 2), rescored with a Levenshtein ratio.
Summary
Functions
The best match scoring at least min_score (default 0.33), or nil.
Returns [{score, candidate}], best first, for candidates scoring at least
0.33 against value.
Like get/2 with a caller-chosen minimum score: PostgREST asks for 0.75 when suggesting
a table or function name and 0.33 for a parameter list. The first gram size with any
candidate at or above min_score wins.
render.(best) for the closest candidate scoring at least min_score, or nil: the shape of
every "Perhaps you meant ..." hint.
Levenshtein edit distance between two strings (by grapheme).
Functions
The best match scoring at least min_score (default 0.33), or nil.
Returns [{score, candidate}], best first, for candidates scoring at least
0.33 against value.
Like get/2 with a caller-chosen minimum score: PostgREST asks for 0.75 when suggesting
a table or function name and 0.33 for a parameter list. The first gram size with any
candidate at or above min_score wins.
render.(best) for the closest candidate scoring at least min_score, or nil: the shape of
every "Perhaps you meant ..." hint.
@spec levenshtein(String.t(), String.t()) :: non_neg_integer()
Levenshtein edit distance between two strings (by grapheme).