-
Notifications
You must be signed in to change notification settings - Fork 876
fuzzywuzzy returns 0 instead of 100 in many corner cases #196
Comments
Pull requests - with the accompanying tests - are welcome and encouraged :) |
First I'd like to discuss those issues, I didn't have a look into the code yet. Additionally I still have to check if this behaviour depends on python-levenshtein (which I'm using) or not. Maybe there's even some rationale behind this and the behaviour is intended for some reason. Or in other words: Am I facing a bug or does it work as intended? :-) |
From my perspective, the tests pass, so any behavior is expected. If you can add this functionality and tests continue to pass, great! One thing to note is that the ratio may be misleading if the tokens are all the same but actually mis-ordered. That might have actual implications on someone's code, but if we're not testing for that now, its fine to break imo. |
I'm currently writing some patches. Think I will have to touch the check_for_none and check_empty_string decorators... Let me return with a pull request in a couple of hours. |
Please be sure to include perf benchmarks :) |
Hi, before requesting to pull, here are the fixes. How can I run performance benchmarks? Thanks |
@rralf I looked over those changes and can assure @josegonzalez that they are performant. @josegonzalez do you actually need a perf tests here? This changeset looks good to me. |
Sounds fine with me. PR it. |
Huh, that went quickly... Thanks for reviewing. |
Hi,
following issue(s) can be reproduced with python-levenshtein 0.12.0 and fuzzywuzzy 0.16.0
There are several combinations that should be considered similar while being scored as absolutely dissimilar.
fuzz.ratio('', '')
evaluates to 0. Two empty absolutely identical, so this should be 100.
fuzz.ratio('{', '{')
evaluates to 100, while
fuzz.token_sort_ratio(['{'], ['{'])
evaluates erroneously to 0. Inconsistently,
fuzz.token_sort_ratio(['{a'], ['{a'])
evaluates to 100. (which is correct IMO).
Proposal: Independent of the method, fuzzywuzzy should always return 100 if both arguments are absolutely equal. I think this could efficiently be checked.
Thanks!
The text was updated successfully, but these errors were encountered: