strdist.mod

module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT

README

go.dev reference Go Report Card GitHub License

strdist

String distance metrics

How to use the strdist package

There are two ways to use this package, you can either call the named distance functions which have been defined for the various algorithms or else you can use a Finder.

Distance functions

There are ...Distance functions provided for a number of algorithms and these all take a pair of strings and return a measure of distance between them. Note that the distances returned by different functions are not comparible so, for instance, the CosineDistance and the Levenshtein distance are on completely different scales.

var s1 = "hello"
var s2 = "world"

fmt.Println("the Levenshtein distance between ",
            s1, " and ", s2, " is ",
			strdist.LevenshteinDistance(s1, s2))

Finder

The Finder allows you to search a slice of strings for the closest match to a target string. You can specify the shortest string to consider, the threshold for similarity, whether or not to flatten case so that you can treat "hello" and "HELLO" as the same string and finally you specify the particular algorithm to be used. There are various default Finders constructed for the supplied algorithms.

Directories

Path Synopsis
Package strdist offers various string distance metrics and a Finder for using the algorithms to find strings in a population similar to a target string.
Package strdist offers various string distance metrics and a Finder for using the algorithms to find strings in a population similar to a target string.

Jump to

Keyboard shortcuts

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