antzucaro/matchr

JaroWinkler -- panic: runtime error: index out of range

Closed this issue · 1 comments

matchr.JaroWinkler("dr", "driveway", true)
--
panic: runtime error: index out of range
github.com/antzucaro/matchr.jaroWinklerBase(0xc82056cf71, 0x2, 0xc82056cfd1, 0x8, 0x101, 0x3fe8000000000000)
    /home/vagrant/workspace/go/src/github.com/antzucaro/matchr/jarowinkler.go:100 +0x59d
github.com/antzucaro/matchr.JaroWinkler(0xc82056cf71, 0x2, 0xc82056cfd1, 0x8, 0xb69801, 0xc8202a8418)
    /home/vagrant/workspace/go/src/github.com/antzucaro/matchr/jarowinkler.go:134 +0x50

As a hotfix, I've changed line :100 to explicitly checking r1 & r2 have an index at i like this:
for i = 0; i < j && len(r1) > i && len(r2) > i && r1[i] == r2[i] && nan(r1[i]); i++ {

I accepted your pull. Thanks!