Search code examples
python-3.xfuzzy-logicfuzzyfuzzywuzzy

python fuzzywuzzy limit, how does it work?


How exactly does the limit work with pythons fuzzywuzzy module, what does it mean?

matches = process.extract(query, choices, limit=2, scorer=fuzz.partial_ratio)

Solution

  • Limit is generally used in fuzzywuzzy when you need "x" best matching solutions.

    So, for example you are comparing the same column of a df to match with each other. It will be the case that 1st match will be the name itself. So, you do limit = 2 do get the 2nd best match.

    Ex: column values =['Apple','Banana','Orange','Appl','Banan']
    

    If you want to do fuzzy using same column and see how "Apple" is used in different contexts because of spelling mistakes etc. Now the best match of Apple will be Apple itself, so you do limit=2 do get "Appl" in this case

    I hope I was clear