https://github.com/kodemartin/rustpostal
Rust bindings to libpostal
https://github.com/kodemartin/rustpostal
bindings parser rust tokenizer
Last synced: 23 days ago
JSON representation
Rust bindings to libpostal
- Host: GitHub
- URL: https://github.com/kodemartin/rustpostal
- Owner: kodemartin
- License: mit
- Created: 2020-11-22T09:25:22.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-03-28T01:29:28.000Z (over 3 years ago)
- Last Synced: 2025-03-26T20:49:27.170Z (8 months ago)
- Topics: bindings, parser, rust, tokenizer
- Language: Rust
- Homepage:
- Size: 64.5 KB
- Stars: 14
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Geospatial - postal - Rust bindings to libpostal. (Rust)
README
# rustpostal
Rust bindings to [libpostal][], a fast statistical parser/normalizer
for street addresses anywhere in the world.
## Usage
```rust
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
1. Install the C library: See [installation instructions][linux-install].
2. Export the installation path to `LD_LIBRARY_PATH`.
## Tests
```
$ cargo test -- --test-threads 1
```
[libpostal]: https://github.com/openvenues/libpostal
[linux-install]: https://github.com/openvenues/libpostal#installation-maclinux