Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

partial_ratio not using best aligned substring with python-Levenshtein #274

Closed
maxbachmann opened this issue Apr 15, 2020 · 1 comment
Closed

Comments

@maxbachmann
Copy link

When using partial_ratio with python-Levenshtein it is not guaranteed to use the best aligned string, even though thats the purpose of partial_ratio.
As an example:

>>> fuzz.partial_ratio("aaaa", "babaaaab")
75.0

Here the best aligned string is a exact match. However the get_matching_blocks method from python-Levenshtein only finds the alignment aaaa <-> abaa and therefore calculates a ratio of 75% in partial_ratio.

In my opinion it should be either explicitly mentioned (probably in the docstring), that when using python-Levenshtein this function is not guaranteed to use the best aligned string, or it should keep using difflib to calculate the matching_blocks and python-Levenshtein only for the final ratio calculation when looping over the matching_blocks even when python-Levenshtein is available.

@maxbachmann
Copy link
Author

duplicate of #79

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

No branches or pull requests

1 participant