Documentation ¶
Overview ¶
Package stringmetric provides functions to calculate string metrics, also known as string similarity metrics or string distance functions.
A string metric measures the distance ("inverse similarity") between two text strings for approximate string matching, comparison, and fuzzy string searching.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DLDistance ¶
DLDistance calculates the Damerau-Levenshtein edit distance between two strings. It provides the distance between two strings as the minimum number of operations required to change one string into the other. The operations include insertions, deletions, substitutions, and transpositions of two adjacent characters.
Ref.: https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance
Example ¶
package main import ( "fmt" "github.com/Vonage/gosrvlib/pkg/stringmetric" ) func main() { d := stringmetric.DLDistance("a cat", "a abct") // "a cat" (one transposition)-> "a act" (one insertion)-> "a abct" fmt.Println(d) }
Output: 2
Types ¶
This section is empty.