.. | ||
src | ||
tests | ||
.cargo-checksum.json | ||
Cargo.toml | ||
LICENSE | ||
README.md |
strsim-rs
Rust implementations of string similarity metrics. Should compile cleanly on both the nightly and beta versions of Rust. Includes:
- Hamming
- Levenshtein and Damerau-Levenshtein
- Jaro and Jaro-Winkler - this implementation of Jaro-Winkler does not limit the common prefix length
Installation
# Cargo.toml
[dependencies]
strsim = "0.3.0"
Usage
extern crate strsim;
use strsim::{hamming, levenshtein, damerau_levenshtein, jaro, jaro_winkler};
fn main() {
match hamming("hamming", "hammers") {
Ok(distance) => assert_eq!(3, distance),
Err(why) => panic!("{:?}", why)
}
assert_eq!(3, levenshtein("kitten", "sitting"));
assert_eq!(1, damerau_levenshtein("specter", "spectre"));
assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() <
0.001);
assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() <
0.001);
}
License
MIT