module

Opal::Input::Fuzzy

High-performance fuzzy matching algorithm with rune highlighting.

Class methods

filter(query : String, items : Array(String)) : Array(FuzzyMatch(String))

Filters and ranks a list of items by fuzzy match score in descending order.

Source
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.

Source
levenshtein(s1 : String, s2 : String) : Int32

Computes the Levenshtein edit distance between two strings.

Source
match(query : String, target : String) : FuzzyMatch(String) | Nil

Matches a query string against a target string and computes a score + matched rune indices.

Source
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.

Source