stringutil

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package cmdsim provides functionality for finding the best matching command based on the Jaro-Winkler distance algorithm.

Index

Constants

View Source
const DefaultSimilarityThreshold = 0.7

DefaultSimilarityThreshold is the default similarity threshold for the Jaro-Winkler distance.

Variables

This section is empty.

Functions

func FindBestMatch

func FindBestMatch(source []string, input string, threshold float64) string

FindBestMatch finds the best matching string to the input

func FindBestMatchFunc

func FindBestMatchFunc[F ~func(K, V) string, K, V any](seq iter.Seq2[K, V], input string, threshold float64, fn F) string

FindBestMatchFunc finds the best matching value and its similarity score from the given list of values. It returns the best match and its similarity score. If no command meets the threshold, it returns an zero key and zero similarity score.

func IsASCIIIdentifier

func IsASCIIIdentifier(s string) bool

IsASCIIIdentifier checks if a string is a valid ascii identifier.

func JaroWinklerDistance

func JaroWinklerDistance(s1, s2 string) float64

JaroWinklerDistance calculates the Jaro-Winkler distance between two strings. The result is a value between 0 and 1, where 1 indicates a perfect match. This function is case-sensitive.

Types

This section is empty.

Jump to

Keyboard shortcuts

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