The problem
Same city, different names
Every time we integrated a new shipping company, someone had to sit down and match its list of cities with ours.
Take Mohammedia, for example. It could be written as Mohammadia or Mohamadia.
Now imagine doing that for hundreds of cities. Not the most enjoyable way to spend a few days.
My approach
Why not look for similar names?
I built a small internal tool using fuzzy search.
Instead of looking for exact matches, the tool looked for similar city names and preselected the most likely match. All you had to do was paste the list of cities and review the suggestions.
The interesting part
Similar doesn't always mean the same
Two cities can have very similar names and still be completely different places. Automatically accepting every match could mean sending someone's package to the wrong city.
So I kept a human in the process. The tool provided up to ten suggestions per city, with the freedom to change or skip a match.
I wanted to automate the boring part, not the decision that actually mattered.
What changed
Five minutes later
The first version generated a PHP file containing the mappings. I later made it save directly to the database, removing the need for a deployment.
What used to take days could now be done in about five minutes.
Nothing fancy, just a boring algorithm making someone's life a little easier :)