openvenues / node-postal

NodeJS bindings to libpostal for fast international address parsing/normalization
MIT License
219 stars 76 forks source link

Expose options like in pypostal #16

Open jefffriesen opened 7 years ago

jefffriesen commented 7 years ago

pypostal has all of these options available: https://github.com/openvenues/pypostal/blob/master/postal/expand.py#L17-L51

node-postal has direct-to-c sorcery: expand: require('bindings')('expand'). It looks like you can't pass options in (and I couldn't by trial and error).

Is there a way to expose options for the node binding? Or if you can use them, how?

Thanks

albarrentine commented 7 years ago

The options are exposed in node-postal (not really documented though) and can be passed in as a second argument in a JS object:

var postal = require('node-postal');
postal.expand.expand_address('Pine St', {'address_components': postal.expand.ADDRESS_STREET});

The source for node-postal expand is mostly C/C++, options can be found here: https://github.com/openvenues/node-postal/blob/master/src/expand.cc#L61-L98

serge-medvedev commented 11 months ago

transliterate option doesn't seem to affect the results: setting it to false doesn't prevent transliterated results from appearing.