text

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MPL-2.0 Imports: 2 Imported by: 0

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

func CloseMatches(target string, choices []string, n int) []string

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

func Levenshtein(a, b string) int

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

func Similarity(a, b string) float64

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL