systemd-cron-next/vendor/strsim
2024-11-12 15:03:58 +03:00
..
src Cargo vendor 2024-11-12 15:03:58 +03:00
tests Cargo vendor 2024-11-12 15:03:58 +03:00
.cargo-checksum.json Cargo vendor 2024-11-12 15:03:58 +03:00
Cargo.toml Cargo vendor 2024-11-12 15:03:58 +03:00
LICENSE Cargo vendor 2024-11-12 15:03:58 +03:00
README.md Cargo vendor 2024-11-12 15:03:58 +03:00

strsim-rs Build Status

Rust implementations of string similarity metrics. Should compile cleanly on both the nightly and beta versions of Rust. Includes:

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