Crates.io | rustpostal |
lib.rs | rustpostal |
version | 0.3.0 |
source | src |
created_at | 2020-11-22 10:18:34.828899 |
updated_at | 2022-03-12 10:38:22.568079 |
description | Rust bindings to libpostal |
homepage | |
repository | https://github.com/kodemartin/rustpostal |
max_upload_size | |
id | 314955 |
size | 49,033 |
Rust bindings to libpostal, a fast statistical parser/normalizer for street addresses anywhere in the world.
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(())
}
Install the C library: See installation instructions.
Export the installation path to LD_LIBRARY_PATH
.
$ cargo test -- --test-threads 1