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

Fuzzy matching not working for typos #759

Open
1 of 2 tasks
dhyeythumar opened this issue Feb 7, 2024 · 3 comments
Open
1 of 2 tasks

Fuzzy matching not working for typos #759

dhyeythumar opened this issue Feb 7, 2024 · 3 comments
Labels

Comments

@dhyeythumar
Copy link

dhyeythumar commented Feb 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

My use case is to extract color names from a given string. And I have provided the list of color names as my collection.
But when I try to get the closest match for a color name with a typo, the fuse does not match with any of them, even when it's a single-character typo.

For example:
Collection = ["Red", "Green", "Black"]
Search word = "grean"
Result from fuse = []

I wanted to know why this is not working. And did anyone face this kind of issue earlier?

The Fuse.js version where this bug is happening.

6.6.2

Is this a regression?

  • This is a regression bug

Which version did this behavior use to work in?

Steps To Reproduce

Here is the fiddle link to check: https://jsfiddle.net/ykecbuaz/12/
Open the fiddle console and try "grean" in the search bar.

Fuse options I used:

const fuseOptions = {
    isCaseSensitive: false,
    includeScore: true,
    minMatchCharLength: 1,
    shouldSort: true,
    findAllMatches: false,
    location: 0,
    threshold: 0.1,
    distance: 10,
    // ignoreLocation: true,
    // useExtendedSearch: false,
    // ignoreFieldNorm: false,
    // fieldNormWeight: 1,
};

Expected behavior

Typo words should match the nearest similar word.
For example: "grean" should match "green".

Screenshots

No response

Additional context

No response

@dhyeythumar dhyeythumar added the bug label Feb 7, 2024
@dhyeythumar
Copy link
Author

dhyeythumar commented Feb 7, 2024

Also, one point I want to highlight. If I reduce the threshold to 0.4, then it will return "green" for "grean" query.

But now the issue with this threshold is it will return unrelated matches as well, for example, for "pen" we get "pink" which is completely unrelated.

@leeoniya
Copy link

leeoniya commented Feb 7, 2024

if you have an array of strings as your haystack and want simple typo tolerance, you can try uFuzzy (with intraMode: 1)

@dhyeythumar
Copy link
Author

@leeoniya thanks for the suggestion will check this out.

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

No branches or pull requests

2 participants