Go to file
Viktor Lazarev ab17c1e9ab Add normalized Levenshtein and Damerau-Levenstein (#20)
* Add tests for 'normalized_levenshtein'

* Implement 'normalized_levenshtein'

* Implement 'normalized_damerau_levenshtein'

* Add benchmarking of new functions

* Move test cases from integration tests to unit tests

* Use 'is_empty' instead of 'len'

* Count chars instead of bytes

* Update Readme
2018-08-19 17:30:28 -04:00
benches Add normalized Levenshtein and Damerau-Levenstein (#20) 2018-08-19 17:30:28 -04:00
src Add normalized Levenshtein and Damerau-Levenstein (#20) 2018-08-19 17:30:28 -04:00
tests Add normalized Levenshtein and Damerau-Levenstein (#20) 2018-08-19 17:30:28 -04:00
.editorconfig Add EditorConfig 2016-06-05 03:47:56 -04:00
.gitattributes Let Git normalize line endings 2016-09-24 23:45:57 -04:00
.gitignore Use the official Docker image for Rust 2017-10-11 12:03:09 -04:00
.travis.yml Test against the full Rust suite 2015-10-01 00:01:05 -04:00
appveyor.yml Add configuration for AppVeyor 2016-02-20 12:31:03 -05:00
Cargo.toml Bump the minor version 2018-01-17 11:06:17 -05:00
CHANGELOG.md Fix a typo in CHANGELOG.md 2018-06-09 08:29:19 -04:00
dev Improve the dev CLI 2017-11-06 22:01:24 -05:00
LICENSE Update the LICENSE 2018-01-17 10:53:00 -05:00
README.md Add normalized Levenshtein and Damerau-Levenstein (#20) 2018-08-19 17:30:28 -04:00

strsim-rs Crates.io Crates.io Linux build status Windows build status

Rust implementations of string similarity metrics:

Installation

# Cargo.toml
[dependencies]
strsim = "0.7.0"

Documentation

You can change the version in the url to see the documentation for an older version in the changelog.

Usage

extern crate strsim;

use strsim::{hamming, levenshtein, normalized_levenshtein, osa_distance, damerau_levenshtein,
             normalized_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!((normalized_levenshtein("kitten", "sitting") - 0.57142).abs() < 0.00001);

    assert_eq!(3, osa_distance("ac", "cba"));

    assert_eq!(2, damerau_levenshtein("ac", "cba"));

    assert!((normalized_damerau_levenshtein("levenshtein", "löwenbräu") - 0.27272).abs() < 0.00001)

    assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() <
            0.001);

    assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() <
            0.001);
}

Development

If you don't want to install Rust itself, you can run $ ./dev for a development CLI if you have Docker installed.

Benchmarks require a Nightly toolchain. They are run by cargo +nightly bench.

License

MIT