News for hackers. Stuff that matters.
Re:Cocktail Similarity by tyingq on Sunday February 24, 2019 @10:05AM (#19238789)
I use Levenshtein matching for a small business. We take in orders, and some of them end up being ordered from a partner that ships them out. They often change the shipping address in small ways, and don't provide a nice api for us to match orders to tracking numbers. Instead, we just get an email from Fedex or UPS.

So, we trawl IMAP to extract the addresses and find close matches for open orders with Levenshtein. Not perfect, especially when one customer places more than one order, but saves us a lot of time.

Re:Cocktail Similarity by nerdponx on Sunday February 24, 2019 @10:09AM (#19238814)
For addresses, I believe USPS provides a free address standardization API as long as you are using it for shipping purposes.
Re:Cocktail Similarity by tyingq on Sunday February 24, 2019 @10:26AM (#19238881)
This is a bit different. It's matching what you have versus what a 3rd party has. You have no control over the third party.

We do use SmartyStreets to normalize the address before submitting, but the 3rd party uses something else. Also, address correction is a weird space. UPS, for example, delivers to many places that the USPS does not. Rural communities are especially tricky. UPS, Fedex, and USPS disagree on things like "Rural Route 24" vs "State Route 24" versus "Arizona Route 24".

Re:Cocktail Similarity by craz8 on Sunday February 24, 2019 @12:37PM (#19239538)
Fun fact: my address gets corrected to one on the other side of town with a South suffix added. The Post Office, UPS and FedEx all have manual procedures in place to handle this case. No-one has yet to fix their software more than to flag a manual review at the local office
Re:Cocktail Similarity by aero142 on Sunday February 24, 2019 @12:52PM (#19239616)
Have you thought about requesting to change the number of your house to one that doesn't exist on the other side of town? That is usually much easier and cheaper than changing the street name.
Re:Cocktail Similarity by heavenlyblue on Sunday February 24, 2019 @11:43AM (#19239249)
Why can't you normalize the third-party address and then normalize yours?

That should give you the necessary match.

Re:Cocktail Similarity by tyingq on Sunday February 24, 2019 @11:47AM (#19239266)
Because humans make typos that address correction can't always deal with. Address correction is a very inexact space. It even does the wrong thing fairly often, like dropping an apartment or suite that's needed, because it thinks it isn't needed.

Also, address correction doesn't know anything about people's names, business names, etc. Sometimes you need those to disambiguate.

Re:Cocktail Similarity by arundelo on Sunday February 24, 2019 @12:32PM (#19239503)
This all sounds like it would make an interesting blogpost/article if you're into writing one.
Re:Cocktail Similarity by tyingq on Sunday February 24, 2019 @12:36PM (#19239527)
You're probably right. It's pretty surprising how many people don't know their own address. And I don't mean typos. Completely wrong zip codes, missing suite numbers in a huge strip mall, wrong city, no business name when that matters, etc.

The best change I made was having them first enter zip code, then pick city/state from a list that goes with that zip code. Both Google and the USPS have apis for that mapping.

Also, fun fact: UPS charges me $15 if they have to make an address correction at delivery time. So, for example, if a customer fails to put a Suite number in, and the UPS software doesn't tell me it's missing, UPS charges me $15. I've complained that I shouldn't have to pay when their software fails. They don't care. Argh!

Re:Cocktail Similarity by dmix on Sunday February 24, 2019 @01:17PM (#19239744)
Agreed with the other guy, this would be a good blog post similar to that "falsehoods programmers don't know about phone numbers" [1] post that came up recently - but more of a general interest sort of life-experience building the system.

[1] https://news.ycombinator.com/item?id=11321236

Re:Cocktail Similarity by kennywinker on Sunday February 24, 2019 @12:19PM (#19239433)
No way to tack a reference number in there somehow? Like, in the “name” field if nowhere else?
Re:Cocktail Similarity by tyingq on Sunday February 24, 2019 @12:33PM (#19239514)
I could do that, but avoided it because it would have to be at least 6 characters for various reasons. And, as you mention, in the address itself somewhere.

What I have works well enough. It shows the matches in a UI, so a human has final say.

The UI looks like this: https://imgur.com/a/C0GziSe (redacted to hide store/customer info). So it's easy to eyeball the match and make sure it's okay. One button to assign the tracking number. The "match %" field is derived from the Levenshtein distance.