Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindClosestByLevenshtein ¶
FindClosestByLevenshtein returns the closest match to target from candidates and its distance. If candidates is empty, it returns ("", 0).
func IsTypo ¶
IsTypo reports whether candidate is a plausible typo of term — within a small, length-scaled Levenshtein distance. Terms shorter than 4 characters are never typo-matched: at that length too many unrelated words are a single edit apart (e.g. "car"/"cart"/"care") to match safely. Both inputs should already be normalized (e.g. lowercased) by the caller.
Tolerance is 1 edit for 4–5 character terms and 2 for longer ones. The looser bound on longer terms also admits a single adjacent transposition — which Levenshtein scores as 2 edits — so common typos like "updaet" → "update" still match.
func LevenshteinDistance ¶
LevenshteinDistance computes the Levenshtein edit distance between two strings. The implementation is iterative and uses O(min(m,n)) additional memory.
Types ¶
This section is empty.