module Opal::Input::Fuzzy

Overview

High-performance fuzzy matching algorithm with rune highlighting.

Defined in:

opal/input/fuzzy.cr

Class Method Summary

Class Method Detail

def self.filter(query : String, items : Array(String)) : Array(FuzzyMatch(String)) #

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


[View source]
def self.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.


[View source]
def self.levenshtein(s1 : String, s2 : String) : Int32 #

Computes the Levenshtein edit distance between two strings.


[View source]
def self.match(query : String, target : String) : FuzzyMatch(String) | Nil #

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


[View source]
def self.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.


[View source]