Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using MaxInt instead of -1 #44

Open
rodrigombsoares opened this issue Jan 23, 2023 · 0 comments
Open

Using MaxInt instead of -1 #44

rodrigombsoares opened this issue Jan 23, 2023 · 0 comments

Comments

@rodrigombsoares
Copy link

rodrigombsoares commented Jan 23, 2023

First of all, what an awesome lib! Thanks for the work. But I do have this design doubt:

Let's say I wanna compare strings two by two to a target using RankMatchNormalizedFold, for example:

s1 := "Hello Wor"
s2 := "Hello"
target := "hello world"
fmt.Println(fuzzy.RankMatchNormalizedFold(s1, target)) //2
fmt.Println(fuzzy.RankMatchNormalizedFold(s2, target)) //6

I could easily use math.Min(2,6) -> "Hello Wor" to find the best string in this case. But it would get me in trouble if any of the strings don't match, eg:

s1 := "foo"
s2 := "Hello"
target := "hello world"
fmt.Println(fuzzy.RankMatchNormalizedFold(s1, target)) //-1
fmt.Println(fuzzy.RankMatchNormalizedFold(s2, target)) //6

Where math.Min(-1,6) -> "foo"

Why using -1 instead of math.MaxInt if the lower the distance, the closer the strings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant