4 releases (2 breaking)
0.3.0 | Mar 12, 2022 |
---|---|
0.2.0 | Jul 19, 2021 |
0.1.1 | Nov 22, 2020 |
0.1.0 | Nov 22, 2020 |
#5 in #street
30 downloads per month
42KB
805 lines
rustpostal
Rust bindings to libpostal, a fast statistical parser/normalizer for street addresses anywhere in the world.
Usage
use rustpostal::address;
use rustpostal::expand;
use rustpostal::LibModules;
fn main() -> Result<(), rustpostal::error::RuntimeError> {
let postal_module = LibModules::All;
postal_module.setup()?;
let address = "St Johns Centre, Rope Walk, Bedford, Bedfordshire, MK42 0XE, United Kingdom";
let labeled_tokens = address::parse_address(address, None, None)?;
for (token, label) in &labeled_tokens {
println!("{}: {}", token, label);
}
let expanded = expand::expand_address_with_options(address, Some(["en"].iter()))?;
for expansion in &expanded {
println!("{}", expansion);
}
Ok(())
}
Setup
-
Install the C library: See installation instructions.
-
Export the installation path to
LD_LIBRARY_PATH
.
Tests
$ cargo test -- --test-threads 1
Dependencies
~150KB