class

Nucleoc::Matcher

Inherits Reference < Object

A matcher engine that can execute (fuzzy) matches.

Constants

MAX_HAYSTACK_LEN = 2048
MAX_MATRIX_SIZE = 100 * 1024
MAX_NEEDLE_LEN = 128

Constructors

new(config : Config = Config::DEFAULT)
Source

Instance methods

config
Source
config=(config : Config)
Source
exact_indices(haystack : String, needle : String, indices : Array(UInt32)) : UInt16 | Nil
Source
exact_match(haystack : String, needle : String) : UInt16 | Nil

Exact match

Source
fuzzy_indices(haystack : String, needle : String, indices : Array(UInt32)) : UInt16 | Nil

Find the fuzzy match with the highest score and compute indices.

Source
fuzzy_indices_greedy(haystack : String, needle : String, indices : Array(UInt32)) : UInt16 | Nil
Source
fuzzy_indices_normalized(haystack : String, needle : String, indices : Array(UInt32)) : UInt16 | Nil

Find the fuzzy match and indices using a pre-normalized needle.

Source
fuzzy_match(haystack : String, needle : String) : UInt16 | Nil

Find the fuzzy match with the highest score in the haystack.

Source
fuzzy_match_greedy(haystack : String, needle : String) : UInt16 | Nil

Greedy fuzzy match

Source
fuzzy_match_normalized(haystack : String, needle : String) : UInt16 | Nil

Find the fuzzy match using a pre-normalized needle.

Source
normalize_needle(needle : String) : String

Normalize a needle string using the current config.

Source
parallel_fuzzy_indices(haystacks : Array(String), needle : String, chunk_size : Int32 | Nil = nil) : Array(Tuple(UInt16, Array(UInt32)) | Nil)

Parallel fuzzy match with indices

Source
parallel_fuzzy_indices_fiber(haystacks : Array(String), needle : String, chunk_size : Int32 | Nil = nil) : Array(Tuple(UInt16, Array(UInt32)) | Nil)

Parallel fuzzy match with indices using Crystal spawn + Channel

Source
parallel_fuzzy_indices_fiber_preallocated(haystacks : Array(String), needle : String, chunk_size : Int32 | Nil = nil) : Array(Tuple(UInt16, Array(UInt32)) | Nil)

Parallel fuzzy match with indices using pre-allocated results array (fiber version)

Source
parallel_fuzzy_indices_preallocated(haystacks : Array(String), needle : String, chunk_size : Int32 | Nil = nil) : Array(Tuple(UInt16, Array(UInt32)) | Nil)

Parallel fuzzy match with indices using pre-allocated results array

Source
parallel_fuzzy_match(haystacks : Array(String), needle : String, chunk_size : Int32 | Nil = nil) : Array(UInt16 | Nil)

Parallel fuzzy match across multiple haystacks using Crystal spawn Returns array of scores in the same order as input Uses pre-allocated results array for optimal performance

Source
parallel_fuzzy_match_fiber(haystacks : Array(String), needle : String, chunk_size : Int32 | Nil = nil) : Array(UInt16 | Nil)

Parallel fuzzy match across multiple haystacks using Crystal spawn + Channel

Source
parallel_fuzzy_match_optimized(haystacks : Array(String), needle : String, chunk_size : Int32 | Nil = nil) : Array(UInt16 | Nil)

Optimized parallel fuzzy match with manual chunking (no Array#each_slice) Returns array of scores in the same order as input

Source
parallel_fuzzy_match_preallocated(haystacks : Array(String), needle : String, chunk_size : Int32 | Nil = nil) : Array(UInt16 | Nil)

Parallel fuzzy match with pre-allocated results array (most optimized) Returns array of scores in the same order as input

Source
postfix_indices(haystack : String, needle : String, indices : Array(UInt32)) : UInt16 | Nil
Source
postfix_match(haystack : String, needle : String) : UInt16 | Nil

Postfix match

Source
prefix_indices(haystack : String, needle : String, indices : Array(UInt32)) : UInt16 | Nil
Source
prefix_match(haystack : String, needle : String) : UInt16 | Nil

Prefix match

Source
substring_indices(haystack : String, needle : String, indices : Array(UInt32)) : UInt16 | Nil
Source
substring_match(haystack : String, needle : String) : UInt16 | Nil

Substring match

Source