These are the NodeJS bindings to libpostal, a fast, multilingual NLP library for parsing/normalizing physical addresses. libpostal is written in C because virtually every other language can bind to C.
var postal = require('node-postal');
// Expansion API
postal.expand.expand_address('V XX Settembre, 20');
// Parser API
postal.parser.parse_address('Mayfield 688 Franklin Ave, Crown Heights, Brooklyn, NY 11238');
Before using the Node bindings, you must install the libpostal C library. Make sure you have the following prerequisites:
On Linux (Ubuntu)
sudo apt-get install libsnappy-dev autoconf automake libtool pkg-config
On Mac OSX
sudo brew install snappy autoconf automake libtool pkg-config
Installing 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
Installing node-gyp on Linux (Ubuntu)
First make sure you have:
- gcc, g++ and make (
sudo apt-get install build-essential
on Ubuntu) - NodeJS with all the development headers (if using a package manager like apt-get, follow the instructions here: https://nodejs.org/en/download/package-manager/)
- python 2.7
Then install node-gyp system-wide:
sudo npm install -g node-gyp
Installing the Node bindings
npm install openvenues/node-postal
node-postal is tested on most major versions of Node (0.10+) in continuous integration. The C++ bindings are written using Nan, which abstracts the API changes across various versions of V8.
If you're having trouble compiling, post a Github issue with your OS and Node versions along with the output of npm install / node-gyp rebuild.
To run the unit tests:
npm test
Lucas Hrabovsky (https://github.com/imlucas) for information and examples of repos using Nan, node-gyp, etc.