-
-
Notifications
You must be signed in to change notification settings - Fork 772
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
Option to ignore accents (diacritics) [feature] #415
Comments
Hello! export const removeAccents = str => str.normalize('NFD').replace(/[\u0300-\u036F]/g, '') |
You could use a custom https://fusejs.io/api/options.html#getfn import diacritics from 'diacritics';
function getFn() {
return diacritics.remove(Fuse.config.getFn.apply(this, arguments));
} You'll probably also want to remove diacritics from the search query. fuse.search(diacritics.remove(query)) |
I had some issues using above code with undefined values and string arrays like:
So I did it as below.
Maybe this is helpful for others. |
One problem with the proposed workarounds is that you lose diacritic characters from the original value in the returned matches array (when using option |
I am using fuse.js to fuzzy-search in french language. In french (as in other languages) we have accentuated characters (é, è, ê, and e for instance).
Some users will search with no accents, others using wrong ones (quite common misspelling), and others with the exact correct spelling, leading to different search score. I would like, if possible, an option "isAccentSensitive" (for instance) so I can choose if the score should be the same even with the wrong accent-spelling.
Thank you. It would really help if it is by default included in fuse :) .
(edit: sorry, close to #181 )
The text was updated successfully, but these errors were encountered: