closestmatch icon indicating copy to clipboard operation
closestmatch copied to clipboard

Uppercases throw off the matcher

Open pierrecamilleri opened this issue 5 years ago • 1 comments

Thanks for the useful tool. It seems that the matcher does not deal well with uppercases. For instance:


import (
	"fmt"

	"github.com/schollz/closestmatch"
)

func main() {
	fmt.Println("Hello, playground")
	words := []string{
		"foo",
		"bar",
		"faz",
	}
	bagSize := []int{2}

	cm := closestmatch.New(words, bagSize)
	fmt.Println(cm.Closest("fooo"))
	fmt.Println(cm.Closest("FOO"))
}

https://play.golang.org/p/M9IMnrqRUsG does not find anything for FOO.

pierrecamilleri avatar Aug 09 '19 16:08 pierrecamilleri

@JazzyPierrot: Looks like closestmatch normalizes all entries to lowercase. So you can work around by sanitizing your input the same way.

coxley avatar Feb 09 '21 19:02 coxley