Name: usaddress
Owner: datamade
Description: :us: a python library for parsing unstructured address strings into address components
Created: 2014-07-17 19:22:46.0
Updated: 2018-01-20 15:37:57.0
Pushed: 2017-06-30 13:12:30.0
Homepage: https://parserator.datamade.us/usaddress
Size: 6800
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
usaddress is a Python library for parsing unstructured address strings into address components, using advanced NLP methods. Try it out on our web interface! For those who aren't Python developers, we also have an API.
What this can do: Using a probabilistic model, it makes (very educated) guesses in identifying address components, even in tricky cases where rule-based parsers typically break down.
What this cannot do: It cannot identify address components with perfect accuracy, nor can it verify that a given address is correct/valid.
Install usaddress with pip, a tool for installing and managing python packages (beginner's guide here).
In the terminal,
install usaddress
Parse some addresses!
Note that parse
and tag
are different methods:
rt usaddress
='123 Main St. Suite 100 Chicago, IL'
e parse method will split your address string into components, and label each component.
pected output: [(u'123', 'AddressNumber'), (u'Main', 'StreetName'), (u'St.', 'StreetNamePostType'), (u'Suite', 'OccupancyType'), (u'100', 'OccupancyIdentifier'), (u'Chicago,', 'PlaceName'), (u'IL', 'StateName')]
dress.parse(addr)
e tag method will try to be a little smarter
will merge consecutive components, strip commas, & return an address type
pected output: (OrderedDict([('AddressNumber', u'123'), ('StreetName', u'Main'), ('StreetNamePostType', u'St.'), ('OccupancyType', u'Suite'), ('OccupancyIdentifier', u'100'), ('PlaceName', u'Chicago'), ('StateName', u'IL')]), 'Street Address')
dress.tag(addr)
usaddress uses parserator, a library for making and improving probabilistic parsers - specifically, parsers that use python-crfsuite's implementation of conditional random fields. Parserator allows you to train the usaddress parser's model (a .crfsuite settings file) on labeled training data, and provides tools for adding new labeled training data.
To build a development version of usaddress on your machine, run the following code in your command line:
t clone https://github.com/datamade/usaddress.git
usaddress
p install -r requirements.txt
thon setup.py develop
rserator train training/labeled.xml usaddress
Then run the testing suite to confirm that everything is working properly:
osetests .
Having trouble building the code? Open an issue and we'd be glad to help you troubleshoot.
If usaddress is consistently failing on particular address patterns, you can adjust the parser's behavior by adding new training data to the model. Follow our guide in the training directory, and be sure to make a pull request so that we can incorporate your contribution into our next release!
Report issues in the issue tracker
If an address was parsed incorrectly, please let us know! You can either open an issue or (if you're adventurous) add new training data to improve the parser's model. When possible, please send over a few real-world examples of similar address patterns, along with some info about the source of the data - this will help us train the parser and improve its performance.
If something in the library is not behaving intuitively, it is a bug, and should be reported.
Copyright (c) 2014 Atlanta Journal Constitution. Released under the MIT License.