Open Pranav082001 opened 1 year ago
The edit distance that is being used as a default is RapidFuzz, more specifically, it uses the WRatio method for calculating the edit distance. The output is expected according to the scoring function that is being used. You can check it with the following:
>>> from rapidfuzz import process, fuzz
>>> match = process.extractOne(list2[0], list1, scorer=fuzz.WRatio)
>>> match
('american Futures and Options Exchange', 90.0, 0)
If you want to use a different edit distance technique, you can do something like this instead:
from polyfuzz import PolyFuzz
from polyfuzz.models import EditDistance
from rapidfuzz.distance import Levenshtein
list1 = ["american Futures and Options Exchange","America First Credit Union"]
list2 = ["America"]
distance = EditDistance(scorer=Levenshtein.distance, normalize=False)
model = PolyFuzz(distance).match(list1, list2)
I have been experimenting with PolyFuzz for a while. I have observed some weird scoring behavouir. Following is the case in which I am getting a very high score of 90 despite the string hardly equal. It is not expected to get such high scores just because of common string "america", the edit distance would be very low if you compare it with list1 strings.
Any workaround would be appreciated... Thanks!