| 1 |
[](http://travis-ci.org/xrash/smetrics) |
| 2 |
|
| 3 |
# smetrics |
| 4 |
|
| 5 |
`smetrics` is "string metrics". |
| 6 |
|
| 7 |
Package smetrics provides a bunch of algorithms for calculating the distance between strings. |
| 8 |
|
| 9 |
There are implementations for calculating the popular Levenshtein distance (aka Edit Distance or Wagner-Fischer), as well as the Jaro distance, the Jaro-Winkler distance, and more. |
| 10 |
|
| 11 |
# How to import |
| 12 |
|
| 13 |
```go |
| 14 |
import "github.com/xrash/smetrics" |
| 15 |
``` |
| 16 |
|
| 17 |
# Documentation |
| 18 |
|
| 19 |
Go to [https://pkg.go.dev/github.com/xrash/smetrics](https://pkg.go.dev/github.com/xrash/smetrics) for complete documentation. |
| 20 |
|
| 21 |
# Example |
| 22 |
|
| 23 |
```go |
| 24 |
package main |
| 25 |
|
| 26 |
import ( |
| 27 |
"github.com/xrash/smetrics" |
| 28 |
) |
| 29 |
|
| 30 |
func main() { |
| 31 |
smetrics.WagnerFischer("POTATO", "POTATTO", 1, 1, 2) |
| 32 |
smetrics.WagnerFischer("MOUSE", "HOUSE", 2, 2, 4) |
| 33 |
|
| 34 |
smetrics.Ukkonen("POTATO", "POTATTO", 1, 1, 2) |
| 35 |
smetrics.Ukkonen("MOUSE", "HOUSE", 2, 2, 4) |
| 36 |
|
| 37 |
smetrics.Jaro("AL", "AL") |
| 38 |
smetrics.Jaro("MARTHA", "MARHTA") |
| 39 |
|
| 40 |
smetrics.JaroWinkler("AL", "AL", 0.7, 4) |
| 41 |
smetrics.JaroWinkler("MARTHA", "MARHTA", 0.7, 4) |
| 42 |
|
| 43 |
smetrics.Soundex("Euler") |
| 44 |
smetrics.Soundex("Ellery") |
| 45 |
|
| 46 |
smetrics.Hamming("aaa", "aaa") |
| 47 |
smetrics.Hamming("aaa", "aab") |
| 48 |
} |
| 49 |
``` |