I have about 10k categories, represented by their name. I need to find a match for a category input among this list of 10k categories.
This is done through an API, and by batches: the endpoint will receive about 500 categories to match.
The process is:
-> Receive request with all categories to match
-> For each word, run fuzzy matching algorithm with the 10k categories.
-> Return match
I'm using Fuzzy Wuzzy for the algorithm, and Django for the API. Basically, this would look like this:
response = {}
for category in categories_received:
for master_category in master_categories:
if fuzz.ratio(category, master_category) > 95:
response[category] = master_category
This is terribly inefficient, but I couldn't find another way to do it. I control both sides: the way data is sent to the API, and of course the way it is compared to the existing categories.
Any idea/input on how to make this code more efficient would be much appreciated