pypostal
1.0
这些是与https://github.com/openvenues/libpostal的官方python绑定,这是世界上任何地方的街道地址的快速统计解析器/标准式。
from postal . expand import expand_address
expand_address ( 'Quatre vingt douze Ave des Champs-Élysées' )
from postal . parser import parse_address
parse_address ( 'The Book Club 100-106 Leonard St, Shoreditch, London, Greater London, EC2A 4RH, United Kingdom' )在使用Python绑定之前,您必须安装LibPostal C库。确保您有以下先决条件:
在Ubuntu/Debian上
sudo apt-get install curl autoconf automake libtool python-dev pkg-config
在Centos/Rhel上
sudo yum install curl autoconf automake libtool python-devel pkgconfig
在Mac OSX上
brew install curl autoconf automake libtool pkg-config
安装libpostal
git clone https://github.com/openvenues/libpostal
cd libpostal
./bootstrap.sh
./configure --datadir=[...some dir with a few GB of space...]
make
sudo make install
# On Linux it's probably a good idea to run
sudo ldconfig
要安装Python库,只需运行:
pip install postal
Pypostal支持Python 2.7+和Python 3.4+。这些绑定是使用Python C API编写的,因此仅支持CPYTHON。由于LibPostal是独立的C库,因此CFFI包装器仍然可以使用对PYPY的支持,但并不是此存储库的目标。
确保安装鼻子,然后运行:
python setup.py build_ext --inplace
nosetests postal/tests
需要build_ext --inplace业务,因此C扩展名在源结帐目录中构建,并由Python模块访问/非常重要。