Repository navigation
Fix partial_ratio ignoring score_cutoff > 100 for two empty strings in the Python fallback - #512
Open
ines-besrour wants to merge 1 commit into
Open
ines-besrour wants to merge 1 commit into
ines-besrour wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pure-Python
partial_ratio_alignmentreturns a perfect score for two empty strings before it looks atscore_cutoff. With a cutoff above 100, the fallback therefore disagrees with the C++ implementation:This adds the
score_cutoff > 100guard that the C++ code and the other Python scorers already use (token_sort_ratio, and the token scorers since #488), placed before the empty-string shortcut.partial_token_sort_ratiogoes throughpartial_ratio, so it is fixed as well.Tests.
test_score_cutoff_above_100now also checks two empty strings for every scorer in both implementations, and a new test checkspartial_ratio_alignment. Without the fix they fail forpartial_ratio,partial_token_sort_ratioandpartial_ratio_alignment; with it,tests/test_fuzz.pypasses (built from source onmain, CPython 3.12, Linux).Note:
tests/distance/test_distance.py::test_score_cutoff_equal_to_score[scorer9]fails onmainboth before and after this change, so it is unrelated to this PR.Fixes #510