fuzzywuzzy icon indicating copy to clipboard operation
fuzzywuzzy copied to clipboard

Partial Ratio Force Partial of 2nd Argument Only

Open akashbudhia opened this issue 7 years ago • 2 comments

Consider this example: fuzz.partial_ratio("An Act of Wisdom - In Theatres", "Theatres") => 100%

The result would be misleading. What's the best way to handle this and still leverage the benefits of partial_ratio for the longer strings?

akashbudhia avatar Jan 05 '18 11:01 akashbudhia

As I said in the other issue:

I'm not implementing that in fuzzywuzzy, but you are free to do so in a wrapper function by just checking if one string is in another. Note that you'll definitely incur a performance penalty.

josegonzalez avatar Jan 05 '18 16:01 josegonzalez

Note: it technically shouldn't matter as we're swapping the shorter/longer strings here: https://github.com/seatgeek/fuzzywuzzy/blob/master/fuzzywuzzy/fuzz.py#L61-L66

josegonzalez avatar Jan 05 '18 16:01 josegonzalez