fuzzysort icon indicating copy to clipboard operation
fuzzysort copied to clipboard

add support for normalizing diacritics, accents, and ligatures

Open jove4015 opened this issue 2 years ago • 0 comments

We just implemented your fuzzy sort into the search function in our grid component and it is working great - our search accuracy and performance has improved substantially.

Along the way, we were asked to include functionality to normalize accents and diacritics:

ü should match u (ie, "uber" should match the string "Über") é should match e Å should match a fi should match fi

And so on. We found that the best way to introduce this was to modify this library, and so I'm submitting it now to be included.

Normalization is triggered by a configuration option "normalizeDiacritics" which defaults to false - so any existing implementation should continue to work exactly as before. If this new option is specified, additional parsing occurs in the prepareLowerInfo function. Every time this option is changed, the built-in cache is cleared so that unnormalized results don't contaminate normalized searches and vice versa.

I didn't spend a lot of time on the performance impacts of this - obviously normalizing all the strings comes with a cost, but for our use case this is pretty negligible. I hope that by making this optional and not default, any performance impact is minimized to just those who want to use the functionality.

Thanks for your consideration! Please let me know if there's anything you'd like for me to update.

jove4015 avatar Aug 05 '22 17:08 jove4015