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模塊訪問/非常重要。