strsim

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 3 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func FindSimilar(target string, candidates []string, maxResults int, maxDistance int) []string

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

func LevenshteinDistance(a, b string) int

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.

Jump to

Keyboard shortcuts

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