Documentation
¶
Overview ¶
Package text holds generic string-matching utilities used by the CLI for "did you mean…?" suggestions. It belongs in infra because it has no project-specific knowledge: the same Levenshtein code could ship as a stand-alone library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseMatches ¶
CloseMatches returns up to n entries from choices that are similar to target, ordered by similarity descending. Comparison is case-insensitive. Matches must score at least 0.6 (where 1.0 is identical).
func Levenshtein ¶
Levenshtein returns the edit distance between a and b. Operates on runes, so unicode characters count as one edit each. O(len(a)*len(b)) time, O(len(b)) space.
func Similarity ¶
Similarity returns a 0-1 score based on Levenshtein distance normalized by the longer string's length. Identical strings score 1.0; entirely different strings score 0.
Types ¶
This section is empty.