| Crates.io | metaphone3-sys |
| lib.rs | metaphone3-sys |
| version | 0.3.0 |
| created_at | 2025-05-08 11:38:38.048901+00 |
| updated_at | 2025-06-25 13:03:44.706738+00 |
| description | Bindings for the Metaphone3 Go library |
| homepage | |
| repository | https://github.com/kakserpom/metaphone3-rs |
| max_upload_size | |
| id | 1665220 |
| size | 15,308 |
metaphone3-rsmetaphone3-sys is a Rust crate providing bindings to the Metaphone 3 algorithm, enabling phonetic encoding of words.
The Metaphone 3 algorithm is designed for generating a primary and secondary phonetic encoding of a word, which can be
used for fuzzy matching, searching, and comparison tasks involving English words and names.
This crate allows you to interact with the Go library for Metaphone 3, providing an easy-to-use Rust API. It provides bindings for the Go-based Metaphone 3 library.
To use the metaphone3-sys crate, add it as a dependency in your Cargo.toml file:
[dependencies]
metaphone3-sys = "0.1"
metaphone3This function encodes a word using the Metaphone 3 algorithm and returns a tuple containing the primary and secondary encodings.
pub fn metaphone3(word: &str, encode_vowels: bool, encode_exact: bool) -> (String, String)
word: The word to encode (type: &str).encode_vowels: Setting EncodeVowels to true will include non-first-letter vowel sounds in the output.encode_exact: Setting EncodeExact to true will tighten the output so that certain sounds will be differentiated.
E.g. more separation between hard "G" sounds and hard "K" sounds.Strings: the primary and secondary phonetic encodings of the word.Here’s a simple usage example:
use metaphone3_sys::metaphone3;
fn main() {
let word = "SMITH";
let (primary, secondary) = metaphone3(word, false, false).unwrap();
println!("Primary: {}, Secondary: {}", primary, secondary);
}
The crate includes some tests to ensure proper functionality. To run the tests, use the following command:
cargo test
Since the crate interacts with C code via FFI, it is marked as unsafe in places where direct memory manipulation
occurs. Please ensure that you are working with valid input and handle the results safely.
This crate is licensed under the MIT License.