Parse street addresses around the world.
This is a Python binding for libpostal
, a C library for parsing/normalizing street addresses around the world using statistical NLP and open data. The goal of this project is to understand location-based strings in every language, everywhere.
You can install the latest stable version via:
$ pip install pylibpostal
libpostal
needs to download some data files and models from S3. The basic files are on-disk representations of the data structures necessary to perform expansion. Please refer to the documentation how to download the files.
Export the path to the data folder as environment variable:
export LIBPOSTAL_DATA_DIR="data-folder"
>>> from pylibpostal.expand import expand_address
>>> expand_address('Quatre vingt douze Ave des Champs-Élysées')
['92 avenue des champs-elysees',
'92 avenue des champs elysees',
'92 avenue des champselysees']
>>> from pylibpostal.parser import parse_address
>>> parse_address('The Book Club 100-106 Leonard St, Shoreditch, London,EC2A 4RH, UK')
[('the book club', 'house'),
('100-106', 'house_number'),
('leonard st', 'road'),
('shoreditch', 'suburb'),
('london', 'city'),
('ec2a 4rh', 'postcode'),
('uk', 'country')]