fuzzy

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyTypo

func AnyTypo(term string, candidates []string) bool

AnyTypo reports whether term is a typo of any of the candidates (see IsTypo).

func FindClosestByLevenshtein

func FindClosestByLevenshtein(target string, candidates []string) (string, int)

FindClosestByLevenshtein returns the closest match to target from candidates and its distance. If candidates is empty, it returns ("", 0).

func IsTypo

func IsTypo(term, candidate string) bool

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

func LevenshteinDistance(a, b string) int

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.

Jump to

Keyboard shortcuts

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