2 releases
| 0.1.1 | Feb 17, 2022 |
|---|---|
| 0.1.0 | Feb 17, 2022 |
#661 in Geospatial
33 downloads per month
Used in geocode-csv
40MB
609K
SLoC
libpostal-rust: A high-level, threadsafe wrapper around libpostal
The open source C library
libpostal provides support for
parsing and normalizing addresses using an external language model trained
on addresses around the world. We provide a high-level Rust wrapper around
that library, in a way that it can be linked into your main Rust binary.
Note that you will need to use libpostal_data (included with libpostal)
to download and install about 2GB of language model data:
sudo libpostal_data download all /usr/local/share/libpostal
Once this is done, you can parse addresses as follows:
use libpostal_rust::{ParseAddressOptions, parse_address};
let addr = "781 Franklin Ave Crown Heights Brooklyn NYC NY 11216 USA";
let opt = ParseAddressOptions::default();
let parsed = parse_address(addr, &opt).unwrap();
assert_eq!(parsed.get("state"), Some(&"ny".to_owned()));
You can turn parsed back into a nicely-formatted address (almost anywhere
in the world) by using
address-formatter's support
for OpenCage address templates.
libpostal-rust: Yet Another libpostal Wrapper
This is another set of high-level bindings for the libpostal library. Several other Rust wrappers for this library exist. This one includes the following features, which may or may not be available elsewhere:
- No need to have
libpostalinstalled. - Support for building static Rust binaries.
- Support for thread-safe initialization of
libpostal. - Support from cross-compiling from
x86_64Macs toaarch64(Apple Silicon), for use with GitHub CI builders and similar setups.