Skip to content

Argument max_cost doesn't seem to be respected #41

@janluke

Description

@janluke

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions