class Oxide::Utils::SuggestionList

Overview

Provides fuzzy matching suggestions using Levenshtein distance algorithm. Used to generate "Did you mean?" messages for GraphQL errors.

Defined in:

oxide/utils/suggestion_list.cr

Constant Summary

MAX_SUGGESTIONS = 5

Class Method Summary

Class Method Detail

def self.did_you_mean_message(suggestions : Array(String)) : String | Nil #

Formats suggestions into a "Did you mean?" message. Returns nil if no suggestions provided.


[View source]
def self.suggest(input : String, options : Array(String)) : Array(String) #

Returns up to 5 best matches from options based on Levenshtein distance. Uses a threshold of 40% of input length to filter suggestions.


[View source]