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

Argument max_cost doesn't seem to be respected #41

Open
janluke opened this issue Dec 8, 2022 · 1 comment
Open

Argument max_cost doesn't seem to be respected #41

janluke opened this issue Dec 8, 2022 · 1 comment

Comments

@janluke
Copy link

janluke commented Dec 8, 2022

First of all, thank you so much for making this work publicly available :)

Describe the bug
Not sure this is a bug. If it's not, take it as a clarification request.

The max_cost argument is documented as being the "maximum edit distance" allowed between the query and the results. It's not totally clear what it's meant by that (I'd expect the used edit distance corresponds to thefuzz.partial_ratio). Nonetheless, setting max_cost to zero, I still get matches that don't contain the query.

To Reproduce

from fast_autocomplete import AutoComplete

autocomplete = AutoComplete({
    "spiaggia": {},
    "spiaggia al tramonto": {},
    "spiaggia all'alba": {},
})
print(autocomplete.search("spiagggg", max_cost=0))

Output:

[['spiaggia'], ["spiaggia all'alba"], ['spiaggia al tramonto']]

Expected behavior
I'd expect no results are returned.

OS, DeepDiff version and Python version (please complete the following information):

  • OS: Windows 10
@janluke janluke changed the title max_cost Argument max_cost doesn't seem to be respected Dec 8, 2022
@seperman
Copy link
Owner

seperman commented Dec 9, 2022

@janluke You are right. The docs are not explaining it right. max_cost really comes to play when we don't have enough hits from the cheaper search algorithms and we switch to Levenshtein edit distance. In your case the cheaper algorithms found enough hits so the max_cost was never used. The docs need to be updated.

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

2 participants