Documentation
¶
Overview ¶
Package strsim provides string similarity functions for fuzzy matching.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindSimilar ¶
FindSimilar returns strings from candidates that are similar to the target string, using Levenshtein distance for fuzzy matching. Results are sorted by similarity (most similar first) and limited to maxResults.
The maxDistance parameter controls how different a candidate can be from the target. If maxDistance <= 0, a default threshold of max(len(target)/2, 2) is used.
Comparison is case-insensitive.
func LevenshteinDistance ¶
LevenshteinDistance calculates the minimum number of single-character edits (insertions, deletions, or substitutions) required to transform string a into string b.
This is a dynamic programming algorithm that builds a matrix where each cell [i][j] represents the edit distance between the first i characters of a and the first j characters of b.
Time complexity: O(len(a) * len(b)) Space complexity: O(len(a) * len(b))
Types ¶
This section is empty.