Giter Site home page Giter Site logo

openvenues / node-postal Goto Github PK

View Code? Open in Web Editor NEW
215.0 11.0 76.0 44 KB

NodeJS bindings to libpostal for fast international address parsing/normalization

License: MIT License

Python 4.63% C++ 80.87% JavaScript 14.50%
address-parser address international nlp binding native

node-postal's Introduction

node-postal

Build Status npm

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.

Usage

var postal = require('node-postal');

// Expansion API
postal.expand.expand_address('V XX Settembre, 20');

// Parser API
postal.parser.parse_address('Barboncino (first unionized pizza place in NYC), 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238');

Installation

Before using the Node bindings, you must install the libpostal C library. Make sure you have the following prerequisites:

On Ubuntu/Debian

sudo apt-get install curl autoconf automake libtool pkg-config

On CentOS/RHEL

sudo yum install curl autoconf automake libtool pkgconfig

On Mac OSX

brew install curl 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

Install node-gyp

Then install node-gyp system-wide:

sudo npm install -g node-gyp

Installing node-gyp on Linux (Ubuntu)

First make sure you have:

  1. gcc, g++ and make (sudo apt-get install build-essential on Ubuntu)
  2. 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/)
  3. python 2.7

Installing the Node bindings

npm install node-postal

Compatibility

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, so the latest versions of Node will likely work.

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.

Tests

To run the unit tests:

npm test

Troubleshooting

Installing libpostal: node-postal is a thin wrapper around libpostal, which is written in C. Installing node-postal with npm will not install libpostal as a dependency. The install steps described above will install it in standard locations for your OS. For OS X and Linux, that's /usr/local/include and /usr/local/lib. node-postal will look in these locations for the C libraries. If you have problems installing node-postal, check there for recently installed libpostal libraries.

Downloading Large Files The make process downloads ~750MB of data, ~2GB unzipped (note: these are production-quality machine learning models trained on over a billion addresses, that's how much disk/memory it takes). Make sure the --datadir argument to configure, which requires an absolute path, has enough room to accommodate the models. If you get errors after downloading, e.g.:

make[3]: *** [all-local] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

there may be problems with subsequent install steps. Occasionally something will go wrong and it will give up downloading. Once downloading is complete, the make script will unpack the langauge_classifier.tar.gz.X files. If you see these files, your download may have stopped. Try running the make script again.

Special Thanks

Lucas Hrabovsky (https://github.com/imlucas) for information and examples of repos using Nan, node-gyp, etc.

node-postal's People

Contributors

abdulrahman-khankan avatar albarrentine avatar ben-pr-p avatar frederickjansen avatar jefffriesen avatar kembuco avatar missinglink avatar orangejulius avatar sporkmonger avatar zack09holland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-postal's Issues

cannot install node-postal in amazon linux

i have followed the instruction as in the doc

Following are the steps of the execution

all above commands worked

  • sudo make install
    this command does not work it gives following error
    gcc: internal compiler error: Killed (program cc1)
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See http://bugzilla.redhat.com/bugzilla for instructions.
    make[2]: *** [libscanner_la-scanner.lo] Error 1
    make[2]: Leaving directory /root/libpostal/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory /root/libpostal'
    make: *** [all] Error 2

Publish new changes

It doesn't seem like there is an NPM update available after the new pull request just got merged (#25) that supports node v12. Is that something that can be added? As a temporary measure I've been using the forked repo https://github.com/kembuco/node-postal as my dependency, but would like to switch back to this repo as soon as it gets published.

shared memory for multiple processes on same machine.

is it possible to share the libpostal memory between two different nodejs processes calling require('node-postal') on the same machine?

calling require('node-postal') uses a fair chunk of RAM so having two different services on the same machine using node-postal consumes more RAM than maybe it needs to?

I'm assuming that the memory is read-only so would it be possible to share that memory between processes?

ImportError: No module named compiler.ast


> [email protected] install /root/courier-bhanuc/node_modules/node-postal
> (node-gyp rebuild) || (exit 0)

Traceback (most recent call last):
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 13, in <module>
    import gyp
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
    import gyp.input
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 5, in <module>
    from compiler.ast import Const
ImportError: No module named compiler.ast
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-45-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/courier-bhanuc/node_modules/node-postal
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

any help on the issue would be great. Please comment here if can help

error installing node-postal

node -v == v13.1.0
npm -v == 6.12.1

I can successfully use address parser..

error log ==

/home/ec2-user/.cache/node-gyp/13.1.0/include/node/v8.h:3427:37: note: candidate expects 3 arguments, 2 provided make: *** [Release/obj.target/expand/src/expand.o] Error 1 make: Leaving directory /efs/pelias-code/interpolation/node_modules/node-postal/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/ec2-user/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.14.146-120.181.amzn2.x86_64
gyp ERR! command "/home/ec2-user/.nvm/versions/node/v13.1.0/bin/node" "/home/ec2-user/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /efs/pelias-code/interpolation/node_modules/node-postal
gyp ERR! node -v v13.1.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok

Publish node-postal to NPM registry

I would really love to see node-postal published to the NPM registry. Any changes on doing that ?

The problem is, other projects now need to depend on node-postal as a github dependency in their package.json and that really doesn't work in offline environments (using npm-mirror or similar).

I'm available for assistance if needed.

Segmentation fault

has anyone experienced this?

root@f34e0cbbc3d5:/app/user# node
> require("node-postal");
Segmentation fault

Same using the bin directly!

root@f34e0cbbc3d5:/app/user# ./libpostal/src/libpostal "Quatre vignt douze Ave des Champs-lyses"
Segmentation fault

can't install anymore

Hi,

Since i'd like to reinstall in the aim to test the 1.0 version, i have some error with node-gyp build.

> [email protected] install /home/sragneau/node-postal
> (node-gyp rebuild) || (exit 0)

make : on entre dans le répertoire « /home/sragneau/node-postal/build »
  CXX(target) Release/obj.target/expand/src/expand.o
../src/expand.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE ExpandAddress(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/expand.cc:26:5: error: ‘libpostal_normalize_options_t’ was not declared in this scope
     libpostal_normalize_options_t options = libpostal_get_default_options();
     ^
../src/expand.cc:55:64: error: ‘LIBPOSTAL_MAX_LANGUAGE_LEN’ was not declared in this scope
                             if (lang != NULL && strlen(lang) < LIBPOSTAL_MAX_LANGUAGE_LEN) {
                                                                ^
../src/expand.cc:63:25: error: ‘options’ was not declared in this scope
                         options.address_components = (uint16_t) Nan::To<uint32_t>(value).FromJust();
                         ^
../src/expand.cc:66:21: error: ‘options’ was not declared in this scope
                     options.latin_ascii = Nan::To<bool>(value).FromJust();
                     ^
../src/expand.cc:68:21: error: ‘options’ was not declared in this scope
                     options.transliterate = Nan::To<bool>(value).FromJust();
                     ^
../src/expand.cc:70:21: error: ‘options’ was not declared in this scope
                     options.strip_accents = Nan::To<bool>(value).FromJust();
                     ^

It is cause by my machine or by the new version ?

Thanks you

Error in Windows while installing node-postal

fatal error C1083: Cannot open include file: 'libpostal/libpost
al.h': No such file or directory [C:\libpostal\node_modules\node-postal\build\expand.vcxproj]
parser.cc

Hi, I have followed all these steps below to install libpostal (C library in itself is working for me):

git clone https://github.com/openvenues/libpostal
cd libpostal
cp -rf windows/* ./
./bootstrap.sh
./configure --datadir=[...some dir with a few GB of space...]
make -j4
make install

But when now I am trying to do
npm install openvenues/node-postal
it is throwing the below error:

C:\libpostal>npm install openvenues/node-postal

> [email protected] install C:\libpostal\node_modules\node-postal
> (node-gyp rebuild) || (exit 0)


C:\libpostal\node_modules\node-postal>if not defined npm_config_node_gyp (node "C:\ProgramData\nvm\v10.13.0\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\ProgramData\nvm\v10.13.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  expand.cc
  win_delay_load_hook.cc
c:\libpostal\node_modules\node-postal\src\expand.cc(1): fatal error C1083: Cannot open include file: 'libpostal/libpost
al.h': No such file or directory [C:\libpostal\node_modules\node-postal\build\expand.vcxproj]
  parser.cc
  win_delay_load_hook.cc
c:\libpostal\node_modules\node-postal\src\parser.cc(1): fatal error C1083: Cannot open include file: 'libpostal/libpost
al.h': No such file or directory [C:\libpostal\node_modules\node-postal\build\parser.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\ProgramData\nvm\v10.13.0\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\ProgramData\\nvm\\v10.13.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\libpostal\node_modules\node-postal
gyp ERR! node -v v10.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
updated 1 package and audited 46 packages in 20.363s
found 0 vulnerabilities

Node version: v10.13.0
image

More explicit installation instructions

I've been hoping for something like this for a long time. I'm also hoping to get it running : ). Even though installation instructions are fairly thorough, there are a couple confusing parts I'm hoping someone can clear up for myself and others.

  1. In the "Installing libpostal" section, where do we clone that? If it doesn't matter, do we need to set the PATH to the lib so node-postal can find it?
  2. "Installing node-gyp on Linux (Ubuntu)" section: Are some of these steps needed on OSX? I assume(?) sudo npm install -g node-gyp is needed, but are the steps above needed?
  3. Version of node required? I think node-gyp installs based on node version, so I would assume this would?

For both node 5.x and 6.x, I'm getting these errors:

~/git/jefffriesen/data-pipeline/libpostal[master+]$ npm install openvenues/node-postal --save

> [email protected] install /Users/jeffers/git/jefffriesen/data-pipeline/node_modules/node-postal
> (node-gyp rebuild) || (exit 0)

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
  CXX(target) Release/obj.target/expand/src/expand.o
../src/expand.cc:1:10: fatal error: 'libpostal/libpostal.h' file not found
#include <libpostal/libpostal.h>
         ^
1 error generated.
make: *** [Release/obj.target/expand/src/expand.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/jeffers/.nvm/versions/node/v5.10.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/Users/jeffers/.nvm/versions/node/v5.10.1/bin/node" "/Users/jeffers/.nvm/versions/node/v5.10.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/jeffers/git/jefffriesen/data-pipeline/node_modules/node-postal
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

I got no errors on any of the previous install steps, unless this is an error

Checking for new libpostal geodb data file...
New libpostal geodb data file available
Downloading multipart: http://libpostal.s3.amazonaws.com/geodb.tar.gz, size=486746092, num_chunks=7
...
Downloading part 7: filename=/Users/jeffers/git/libpostal_data/libpostal/geodb.tar.gz.7, offset=402653184, max=486746092
make[3]: *** [all-local] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Any suggestions or clarifications on installation? Thank you

error: unknown FP unit 'sse'

libpostal on  master [?] via C v15.0.0-clang took 29s
❯ system_profiler SPSoftwareDataType

Software:

    System Software Overview:

      System Version: macOS 13.5 (22G74)
      Kernel Version: Darwin 22.6.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: EB-KD96KV36L0
      User Name: Geoff Langenderfer (geoff.langerderfer)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 10 days, 9 hours, 55 minutes


libpostal on  master [?] via C v15.0.0-clang
❯

libpostal on  master [?] via C v15.0.0-clang took 16s
❮ git clone https://github.com/openvenues/libpostal
cd libpostal
./bootstrap.sh
mkdir libpostal_datadir
./configure --datadir=$(pwd)/libpostal_datadir
make
sudo make install
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... aarch64-apple-darwin22.6.0
checking host system type... aarch64-apple-darwin22.6.0
checking how to print strings... printf
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin22.6.0 file names to aarch64-apple-darwin22.6.0 format... func_convert_file_noop
checking how to convert aarch64-apple-darwin22.6.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... ld: warning: -single_module is obsolete
no
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for sys/time.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin22.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for library containing log... none required
checking for egrep... (cached) /usr/bin/grep -E
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for _Bool... yes
checking for stdbool.h that conforms to C99... yes
checking for fcntl.h... yes
checking for float.h... yes
checking for inttypes.h... (cached) yes
checking for limits.h... yes
checking for locale.h... yes
checking for malloc.h... no
checking for memory.h... yes
checking for stddef.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for inline... inline
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for int8_t... yes
checking for off_t... yes
checking for size_t... yes
checking for ssize_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for uint8_t... yes
checking for ptrdiff_t... yes
checking for malloc... yes
checking for realloc... yes
checking for drand48... yes
checking for getcwd... yes
checking for gettimeofday... yes
checking for memmove... yes
checking for memset... yes
checking for regcomp... yes
checking for setlocale... yes
checking for sqrt... yes
checking for strdup... yes
checking for strndup... yes
checking for shuf... no
checking for gshuf... no
checking for cblas.h... no
configure: extra cflags for scanner.c:
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
chmod: src/libpostal_data: No such file or directory
config.status: creating libpostal.pc
chmod: src/libpostal_data: No such file or directory
config.status: creating src/Makefile
chmod: src/libpostal_data: No such file or directory
config.status: creating src/libpostal_data
config.status: creating test/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in src
gcc -DHAVE_CONFIG_H -I.. -I/usr/local/include    -Wall -Wextra -Wno-unused-function -Wformat -Werror=format-security -Winit-self -Wno-sign-compare -DLIBPOSTAL_DATA_DIR='"/Users/geoff.langerderfer/work/api-v1/libpostal/libpostal_datadir/libpostal"' -g -mfpmath=sse -msse2 -DUSE_SSE -g -O2 -O3  -MT libpostal-strndup.o -MD -MP -MF .deps/libpostal-strndup.Tpo -c -o libpostal-strndup.o `test -f 'strndup.c' || echo './'`strndup.c
clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
error: unknown FP unit 'sse'
make[2]: *** [libpostal-strndup.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Making install in src
gcc -DHAVE_CONFIG_H -I.. -I/usr/local/include    -Wall -Wextra -Wno-unused-function -Wformat -Werror=format-security -Winit-self -Wno-sign-compare -DLIBPOSTAL_DATA_DIR='"/Users/geoff.langerderfer/work/api-v1/libpostal/libpostal_datadir/libpostal"' -g -mfpmath=sse -msse2 -DUSE_SSE -g -O2 -O3  -MT libpostal-strndup.o -MD -MP -MF .deps/libpostal-strndup.Tpo -c -o libpostal-strndup.o `test -f 'strndup.c' || echo './'`strndup.c
clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
error: unknown FP unit 'sse'
make[1]: *** [libpostal-strndup.o] Error 1
make: *** [install-recursive] Error 1

node-postal does not build on nodejs versions >10.x (see pull request #25)

I tried installing node-postal on the latest LTS version of node (v12.18.3) and get the following errors (it builds and works fine on node v10.x). I've tried every solution that comes up on a Google search for this error and still get the same result. This is on Macos Catalina v10.15.6

19 warnings and 2 errors generated.
make: *** [Release/obj.target/expand/src/expand.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/xxxxx/.nvm/versions/node/v12.18.3/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/Users/xxxxx/.nvm/versions/node/v12.18.3/bin/node" "/Users/xxxxx/.nvm/versions/node/v12.18.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/xxxxx/dev/libtest/node_modules/node-postal
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

Expose Dedupe

Currently, only the Python binding exposes dedupe functionality. It would be nice if node-postal did as well.

Install with non-standard libpostal location

I don't have sudo access to the server I'm working on, so I installed libpostal into ~/local/lib. My LD_LIBRARY_PATH is set correctly, and the libpostal tests passed so I believe it installed correctly. But npm install node-postal fails because it can't find libpostal/libpostal.h. Is it possible to install node-postal using the local library path?

Can't find bindings expand

Hi we have facing issue on make node-postal working. All 3+Gb of data has been downloaded and postal c library works perfectly so we can parse address via command line utility.

Sadly we spent 3+ hours to make node-postal working with no luck.

We are working on Ubuntu 16.4.0.2
Node 7.7.2

this is the result of node:

`node main.js
/home/ufficio/libpostal/node/node_modules/bindings/bindings.js:90
throw err
^

Error: Could not locate the bindings file. Tried:
→ /home/ufficio/libpostal/node/node_modules/node-postal/build/expand.node
→ /home/ufficio/libpostal/node/node_modules/node-postal/build/Debug/expand.node
→ /home/ufficio/libpostal/node/node_modules/node-postal/build/Release/expand.node
→ /home/ufficio/libpostal/node/node_modules/node-postal/out/Debug/expand.node
→ /home/ufficio/libpostal/node/node_modules/node-postal/Debug/expand.node
→ /home/ufficio/libpostal/node/node_modules/node-postal/out/Release/expand.node
→ /home/ufficio/libpostal/node/node_modules/node-postal/Release/expand.node
→ /home/ufficio/libpostal/node/node_modules/node-postal/build/default/expand.node
→ /home/ufficio/libpostal/node/node_modules/node-postal/compiled/7.7.2/linux/x64/expand.node
at bindings (/home/ufficio/libpostal/node/node_modules/bindings/bindings.js:87:9)
at Object. (/home/ufficio/libpostal/node/node_modules/node-postal/index.js:3:32)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/home/ufficio/libpostal/node/main.js:2:14)
`

thanks a lot

Output format

Is there anyway to change the format of the address being returned by the parser? For example when an address is parsed I get back an array looking like this:

  [ { value: '8809', component: 'house_number' },
  { value: 'madison ave', component: 'road' },
  { value: 'cleveland', component: 'city' },
  { value: 'oh', component: 'state' },
  { value: '44102-2738', component: 'postcode' },
  { value: 'usa', component: 'country' } ]

[ { value: '2511', component: 'house_number' },
  { value: 'w genesee st', component: 'road' },
  { value: 'syracuse', component: 'city' },
  { value: 'ny', component: 'state' },
  { value: '13219-1549', component: 'postcode' },
  { value: 'usa', component: 'country' } ]

This is making it very difficult to reconstruct the address and send it to a database. Is there anyway to format the data like:

house_number: '123',
street: 'Some St'
city: 'CA'
postalcode: '12345'

Thanks for the great package.

Node v20.5.0 issue and fix

I was getting this error originally

Error: Could not locate the bindings file. Tried:
 → /home/user/Documents/workspace/repos/.../.../node_modules/node-postal/build/expand.node
...
...continues on for a bit
...

When on Node v14.18.0, you have to do a node-gyp rebuild within the node-postal module folder, which builds successfully and will recreate the bindings. However when I would do this on Node v20.5.0 it was failing during the make stage

make: *** [expand.target.mk:115: Release/obj.target/expand/src/expand.o] Error 1
make: Leaving directory '/home/user/Documents/workspace/repos/.../.../node_modules/node-postal/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/zholland/.nvm/versions/node/v20.5.0/lib/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Linux 6.0.6-76060006-generic
gyp ERR! command "/home/user/.nvm/versions/node/v20.5.0/bin/node" "/home/user/.nvm/versions/node/v20.5.0/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/user/Documents/workspace/repos/.../.../node_modules/node-postal
gyp ERR! node -v v20.5.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok 

Spent a few hours researching both of those issues. I went through the debug logs and saw an error

../src/expand.cc: In function ‘void init(v8::Local<v8::Object>)’:
../src/expand.cc:136:47: error: ‘class v8::Object’ has no member named ‘CreationContext’; did you mean ‘GetCreationContext’?
  136 |     v8::Local<v8::Context> context = exports->CreationContext();
      |                                                                                                  ^~~~~~~~~~~~~~~
      |                                                                                                  GetCreationContext

On an entirely different packages github issues post, someone commented with a change to get the correct JS context and sure enough I was able to run node-gyp rebuild within the node-postal directory to rebind it and the errors went away

Within parser.cc and expand.cc change:
v8::Local<v8::Context> context = exports->CreationContext();

to

v8::Local<v8::Context> context = exports->GetCreationContext().ToLocalChecked();

Documentation

Hi, thanks for making node-postal. It seems to be the best option short of paying for a monthly subscription. However, the keys returned with parse_address are not documented. Is there a list of all of them somewhere? It looks like they aren't all in the tests, either.

Loading time is too large when a new machine is created with the older Image.

I'm using this library in one of my Linux cloud servers and I've successfully done the setup and the NodeJs node-postal modules is also working as expected.

When I take an Image of the working server and create a new server the node-postal module is taking longer time to load in the nodejs application, but in the existing server when i turn that OFF and turn that ON again there is no such issue and the node-postal module loads faster & I can't see any difference.

So what is the issue when I create a new server out of an Image? and how to overcome the slow loading of the node-postal module during such cases?

npm test fail on "should handle non-ASCII addresses correctly from Node"

Hello, !

I got a failed test when running npm test. The 6 others are OK.
Ubuntu 15.04
Node v4.2.6
node-postal 0.3.0 (just cloned)

[email protected] test /root/test/node-postal
mocha ./test

expand
expand_address
✓ should correctly expand a US address
✓ should correctly dedupe equivalent addresses
{ _items:
[ 'friedrichstrasse 128 berlin germany',
'friedrich strasse 128 berlin germany' ] }
1) should handle non-ASCII addresses correctly from Node

parser
parse_address
✓ should parse a US address
✓ should parse a venue and state
✓ should parse house/apt style house_number
✓ should parse different comma styles correctly

6 passing (22ms)
1 failing

  1. expand expand_address should handle non-ASCII addresses correctly from Node:
  AssertionError: false == true
  + expected - actual

  -false
  +true

  at Context.<anonymous> (test/index.test.js:21:13)

npm ERR! Test failed. See above for more details.

Thank you!

Node Bindings

I have set up the installation files on windows and I am able to run it using command line utility. But the problem is when I set up the node bindings with "npm install openvenues/node-postal", it gives me stack of error messages. Please see below:

\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\no
de-gyp.js" rebuild ) else (node "C:\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-
gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error
MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK vers
ion in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:
\Libpostal\libpostal\src\node_modules\node-postal\build\expand.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error
MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK vers
ion in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:
\Libpostal\libpostal\src\node_modules\node-postal\build\parser.vcxproj]

gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp
lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\AppData\Roaming\npm\node_modules\npm\
ode_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Libpostal\libpostal\src\node_modules\node-postal
gyp ERR! node -v v6.11.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN saveError ENOENT: no such file or directory, open 'C:\Libpostal\libpostal\src\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Libpostal\libpostal\src\package.json'
npm WARN src No description
npm WARN src No repository field.
npm WARN src No README data
npm WARN src No license field.

Can you help me resolve the error?

Can not start node js project

I'm trying to var postal = require('node-postal');
But the system keeps saying errors as below:

[email protected] start /home/ups_poc/webapp
node ./bin/www

/home/ups_poc/webapp/node_modules/bindings/bindings.js:88
throw e
^

Error: libpostal.so.1: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (module.js:664:18)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at bindings (/home/ups_poc/webapp/node_modules/bindings/bindings.js:81:44)
at Object. (/home/ups_poc/webapp/node_modules/node-postal/index.js:3:32)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!

The detail log as below:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 info lifecycle [email protected]
start: [email protected]
7 verbose lifecycle [email protected]start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
start: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/ups_poc/webapp/node_modules/.bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ups_poc/.local/bin:/home/ups_poc/bin
9 verbose lifecycle [email protected]start: CWD: /home/ups_poc/webapp
10 silly lifecycle [email protected]
start: Args: [ '-c', 'node ./bin/www' ]
11 silly lifecycle [email protected]start: Returned: code: 1 signal: null
12 info lifecycle [email protected]
start: Failed to exec start script
13 verbose stack Error: [email protected] start: node ./bin/www
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/ups_poc/webapp
16 verbose Linux 3.10.0-693.5.2.el7.x86_64
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v8.9.1
19 verbose npm v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: node ./bin/www
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Could someone help me with this error? I used CentOS 7.4

Error: Could not locate the bindings file

I tried to install and use node-postal today and continue to get an error. I'm using MacOS Version 11.2.3 (Big Sur), node v12.16.2. I can run libpostal cli via terminal just fine, so I'm pretty sure I did the installation of libpostal correctly. Any suggestions?

/Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/bindings/bindings.js:135
  throw err;
  ^

Error: Could not locate the bindings file. Tried:
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/build/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/build/Debug/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/build/Release/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/out/Debug/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/Debug/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/out/Release/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/Release/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/build/default/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/compiled/12.16.2/darwin/x64/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/addon-build/release/install-root/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/addon-build/debug/install-root/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/addon-build/default/install-root/expand.node
 → /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/lib/binding/node-v72-darwin-x64/expand.node
    at bindings (/Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/bindings/bindings.js:126:9)
    at Object.<anonymous> (/Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/node_modules/node-postal/index.js:3:32)

Here's the output of node-gyp rebuild as requested in the read me:

 % node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 3.7.3 found at "/usr/local/bin/python3"
gyp info spawn /usr/local/bin/python3
gyp info spawn args [
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/wyattgrantham/Documents/GitHub/lsp/api-lsp/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/wyattgrantham/Library/Caches/node-gyp/12.16.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/wyattgrantham/Library/Caches/node-gyp/12.16.2',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/wyattgrantham/Library/Caches/node-gyp/12.16.2/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/wyattgrantham/Documents/GitHub/lsp/api-lsp',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: binding.gyp not found (cwd: /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp) while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 20.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/wyattgrantham/Documents/GitHub/lsp/api-lsp
gyp ERR! node -v v12.16.2
gyp ERR! node-gyp -v v8.0.0
gyp ERR! not ok 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.