1package smetrics
2
3import (
4	"math"
5)
6
7func JaroWinkler(a, b string, boostThreshold float64, prefixSize int) float64 {
8	j := Jaro(a, b)
9
10	if j <= boostThreshold {
11		return j
12	}
13
14	prefixSize = int(math.Min(float64(len(a)), math.Min(float64(prefixSize), float64(len(b)))))
15
16	var prefixMatch float64
17	for i := 0; i < prefixSize; i++ {
18		if a[i] == b[i] {
19			prefixMatch++
20		}
21	}
22
23	return j + 0.1*prefixMatch*(1.0-j)
24}
25