mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-12-04 18:15:00 +00:00
026055a0b7
Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.3.0 to 2.27.1. - [Release notes](https://github.com/urfave/cli/releases) - [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/urfave/cli/compare/v2.3.0...v2.27.1) --- updated-dependencies: - dependency-name: github.com/urfave/cli/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
29 lines
999 B
Go
29 lines
999 B
Go
package smetrics
|
|
|
|
import (
|
|
"math"
|
|
)
|
|
|
|
// The Jaro-Winkler distance. The result is 1 for equal strings, and 0 for completely different strings. It is commonly used on Record Linkage stuff, thus it tries to be accurate for common typos when writing real names such as person names and street names.
|
|
// Jaro-Winkler is a modification of the Jaro algorithm. It works by first running Jaro, then boosting the score of exact matches at the beginning of the strings. Because of that, it introduces two more parameters: the boostThreshold and the prefixSize. These are commonly set to 0.7 and 4, respectively.
|
|
func JaroWinkler(a, b string, boostThreshold float64, prefixSize int) float64 {
|
|
j := Jaro(a, b)
|
|
|
|
if j <= boostThreshold {
|
|
return j
|
|
}
|
|
|
|
prefixSize = int(math.Min(float64(len(a)), math.Min(float64(prefixSize), float64(len(b)))))
|
|
|
|
var prefixMatch float64
|
|
for i := 0; i < prefixSize; i++ {
|
|
if a[i] == b[i] {
|
|
prefixMatch++
|
|
} else {
|
|
break
|
|
}
|
|
}
|
|
|
|
return j + 0.1*prefixMatch*(1.0-j)
|
|
}
|