News for hackers. Stuff that matters.

Ask HN: What's a good US address parsing library?

I'm looking to parse address strings (user input) into address objects for use across multiple services. What's a good library to do this?

I'm currently using Google Geocoding API, but since I don't use these addresses within a Google Map, I'm pretty sure I'm violating the TOS and would like to yank and replace it before I get shut down.

( 13 comments | 19 points | on HN )
Re:Ask HN: What's a good US address parsing library? by SingAlong on Sunday November 20, 2016 @04:12AM (#12998014)
My coworkers recently setup an internal API using a Flask app for US address parsing. They used libpostal after comparing it with usaddress and address (both are Python libraries).

libpostal had the best results and good abbreviation parsing ("St" for street, "blvd" for Boulevard, etc). We use this to check if two address strings are equal, so you can imagine how much abbreviations are important to us. The US postal department website has a list of postal abbreviations but writing our own address parser with this is not a simple task.

libpostal is a few gigs of download and will take about 2gb ram to setup. But worth it.

Re:Ask HN: What's a good US address parsing library? by traviswingo on Monday November 21, 2016 @01:18PM (#13007629)
Yeah. I've tested it before and it looks very promising, but I'm not sure the overhead is necessary for my use case. I'll need to run some tests against all options and figure out where the equilibrium lies between cost (size, memory, price, etc.) and functionality/ux.
Re:Ask HN: What's a good US address parsing library? by kardos on Saturday November 19, 2016 @10:29PM (#12997099)
Have you looked into libpostal?

https://github.com/openvenues/libpostal

Re:Ask HN: What's a good US address parsing library? by traviswingo on Monday November 21, 2016 @01:16PM (#13007599)
I have looked into libpostal. I'm not sure the overhead is completely necessary for my use case. Since posting I've toyed with usaddress and it seems nice. It's a python library so I've had to pull it into my project (node.js) with a child process but it seems to work very well.
Re:Ask HN: What's a good US address parsing library? by VoidWhisperer on Sunday November 20, 2016 @09:33AM (#12999010)
It would appear you are correct that you are breaking google's ToS

https://developers.google.com/maps/documentation/geocoding/p...

Re:Ask HN: What's a good US address parsing library? by traviswingo on Monday November 21, 2016 @01:15PM (#13007580)
Thanks. I found this after adding the reply below since I felt the need to verify :)
Re:Ask HN: What's a good US address parsing library? by tylercubell on Tuesday November 22, 2016 @03:34PM (#13017418)
Keep in mind that address parsing is only one piece of the puzzle. A good library can parse out address components with some degree of accuracy but unless the address can be verified, the result is worthless in many cases. In order to get accurate results, the library must use up to date, real world data.

The best options are commercial: ArcGIS, HERE, Google Maps, SmartyStreets, etc. There are free options such as OpenStreetMap, Census TIGER, and Open Addresses but in my experience the results are unreliable.

Re:Ask HN: What's a good US address parsing library? by urbanstat on Tuesday November 22, 2016 @04:26AM (#13012853)
Our company is dealing with this problem. We have implemented an API to provide enterprises address parsing & geocoding capabilities.

If you want something cheap, business-friendly and ready to go asap, I would advise you to use Here Maps. They have batch-geocoding plans that are quite affordable.

If you want an API that runs behind the firewall or some customization on parsing & geocoding, then we can help you with that.

Re:Ask HN: What's a good US address parsing library? by olegkikin on Saturday November 19, 2016 @06:55PM (#12996421)
Why do you think you're breaking Google's ToS?
Re:Ask HN: What's a good US address parsing library? by traviswingo on Saturday November 19, 2016 @07:01PM (#12996445)
I'm automatically parsing the user input and using the geocoding api data output to link their address with their account, and then I'm charging for services that are placed by using this address. I'm currently under the impression that automatic parsing without using the data in a Google Map is against the TOS, but haven't been able to verify this 100%.
Re:Ask HN: What's a good US address parsing library? by zbyte64 on Sunday November 20, 2016 @04:20PM (#13001300)
There is a python library that uses probabilistic string parsing on addresses. You can even add labeled data to improve accuracy: https://github.com/datamade/usaddress
Re:Ask HN: What's a good US address parsing library? by caleblloyd on Saturday November 19, 2016 @08:14PM (#12996711)
I've had luck using https://smartystreets.com/ if you don't mind using a paid service. They're far cheaper than Google.
Re:Ask HN: What's a good US address parsing library? by bruck on Saturday November 19, 2016 @08:53PM (#12996844)
I also use SmartyStreets - generally very happy with it, and you can do up to 250 lookups per month for free. One thing to watch out for is that SS is meant primarily for mail delivery. There are many addresses in the US that represent real places on a map, but cannot receive USPS mail, and thus will be rejected by SmartyStreets. Our customer base includes a large number of industrial addresses, so that may skew our results, but we find that up to 20% of our legitimate addresses get rejected by the service. You can control how strict the validation will be, up to a point, but beyond that we have to rely on Google as a backup for cleanup and standardization.