Crates.io | str_edit_distance |
lib.rs | str_edit_distance |
version | 0.1.2 |
source | src |
created_at | 2024-05-19 21:08:44.703298 |
updated_at | 2024-07-03 20:13:43.679624 |
description | A Rust library for calculating various string distance and similarity metrics. |
homepage | |
repository | https://github.com/neonwarp/str_edit_distance |
max_upload_size | |
id | 1245213 |
size | 47,383 |
str_edit_distance
is a Rust library for calculating various string distance metrics. These metrics help measure the difference between two sequences by counting the minimum number of single-character edits required to change one string into the other.
Add str_edit_distance
to your Cargo.toml
:
[dependencies]
str_edit_distance = "0.1"
Then, run cargo build to install the package.
use str_edit_distance::levenshtein;
fn main() {
let distance = levenshtein("kitten", "sitting");
println!("The Levenshtein distance between 'kitten' and 'sitting' is: {}", distance);
}
use str_edit_distance::damerau_levenshtein;
fn main() {
let distance = damerau_levenshtein("ca", "abc");
println!("The Damerau-Levenshtein distance between 'ca' and 'abc' is: {}", distance);
}
use str_edit_distance::hamming;
fn main() {
let distance = hamming("karolin", "kathrin");
println!("The Hamming distance between 'karolin' and 'kathrin' is: {}", distance);
}
use str_edit_distance::jaro_winkler;
fn main() {
let distance = jaro_winkler("martha", "marhta");
println!("The Jaro-Winkler distance between 'martha' and 'marhta' is: {:.3}", distance);
}
use str_edit_distance::dice_coefficient;
fn main() {
let similarity = dice_coefficient("night", "nacht");
println!("The Dice's Coefficient between 'night' and 'nacht' is: {:.3}", similarity);
}