jhvst / go-jaro-winkler-distance Goto Github PK
View Code? Open in Web Editor NEWJaro-Winkler distance in Go
License: MIT License
Jaro-Winkler distance in Go
License: MIT License
jwd.Calculate("349398", "234567") // -0.1111...
jwd.Calculate("234567", "349398") // 0.1111...
Jaro-Winkler should return values from 0 to 1.
jwd.Calculate("dakota steakhouse", "amelie bar bistro") // -0.12
The result isn't the expected, should return 0.51
There is a panic when comparing the window runes with the matches slice if the strings.Index call returns an index greater than the number of matches.
idx := strings.Index(string(slider), string(runes1[i]))
if idx != -1 && !matches[idx] { // panic here
t += 0.5
matches[idx] = true
}
I was able to reproduce this when comparing the two following strings:
jwd.Calculate("asdfadsfT", "Academic Free License v1.2")
...
goroutine 19 [running]:
testing.tRunner.func1.2({0x104db2d80, 0x14000126258})
/opt/homebrew/Cellar/go/1.19.1/libexec/src/testing/testing.go:1396 +0x1c8
testing.tRunner.func1()
/opt/homebrew/Cellar/go/1.19.1/libexec/src/testing/testing.go:1399 +0x378
panic({0x104db2d80, 0x14000126258})
/opt/homebrew/Cellar/go/1.19.1/libexec/src/runtime/panic.go:884 +0x204
github.com/jhvst/go-jaro-winkler-distance.Calculate({0x104d16155?, 0x104d16ed8?}, {0x104d1c760, 0x1a})
/Users/xxx/go/pkg/mod/github.com/jhvst/[email protected]/algo.go:58 +0x4c4
testing.tRunner(0x14000107040, 0x104dc3a28)
While this can be fixed with ensuring the length, I'm not entirely sure the logic of the strings.Index
is correct, or how the matches slice is created is correct.
idx := strings.Index(string(slider), string(runes1[i]))
if idx != -1 && idx < len(matches) && !matches[idx] {
t += 0.5
matches[idx] = true
}
Should the index really ever be returning a value that's greater than the number of matches?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.