module
Opal::Input::Fuzzy
Overview
High-performance fuzzy matching algorithm with rune highlighting.
Defined in:
opal/input/fuzzy.crClass Method Summary
-
.filter(query : String, items : Array(String)) : Array(FuzzyMatch(String))
Filters and ranks a list of items by fuzzy match score in descending order.
-
.filter_by(query : String, items : Array(T), &key_selector : T -> String) : Array(FuzzyMatch(T)) forall T
Filters and ranks generic items using a custom key selector function.
-
.levenshtein(s1 : String, s2 : String) : Int32
Computes the Levenshtein edit distance between two strings.
-
.match(query : String, target : String) : FuzzyMatch(String) | Nil
Matches a query string against a target string and computes a score + matched rune indices.
-
.suggest(query : String, candidates : Array(String) | Enumerable(String), max_distance : Int32 = 3) : String | Nil
Suggests the closest matching candidate for a typo, or nil if no good match.
Class Method Detail
Filters and ranks a list of items by fuzzy match score in descending order.
Filters and ranks generic items using a custom key selector function.
Computes the Levenshtein edit distance between two strings.
Matches a query string against a target string and computes a score + matched rune indices.
Suggests the closest matching candidate for a typo, or nil if no good match.