• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

benches/H03-May-2022-8571

src/H03-May-2022-787566

tests/H03-May-2022-5040

.cargo-checksum.jsonH A D03-May-202289 11

.editorconfigH A D27-Aug-2016213 1411

.gitattributesH A D25-Sep-201684 42

.gitignoreH A D11-Oct-201742 65

.travis.ymlH A D27-Aug-2016114 128

CHANGELOG.mdH A D19-Aug-20183.9 KiB12499

Cargo.tomlH A D01-Jan-19701.1 KiB2926

Cargo.toml.orig-cargoH A D19-Aug-2018586 1917

LICENSEH A D17-Jan-20181.1 KiB2418

README.mdH A D19-Aug-20182.8 KiB7052

appveyor.ymlH A D27-Aug-2016354 1410

devH A D06-Nov-20171.1 KiB4230

README.md

1# strsim-rs [![Crates.io](https://img.shields.io/crates/v/strsim.svg)](https://crates.io/crates/strsim) [![Crates.io](https://img.shields.io/crates/l/strsim.svg?maxAge=2592000)](https://github.com/dguo/strsim-rs/blob/master/LICENSE) [![Linux build status](https://travis-ci.org/dguo/strsim-rs.svg?branch=master)](https://travis-ci.org/dguo/strsim-rs) [![Windows build status](https://ci.appveyor.com/api/projects/status/ggue6i785618a39w?svg=true)](https://ci.appveyor.com/project/dguo/strsim-rs)
2
3[Rust](https://www.rust-lang.org) implementations of [string similarity metrics]:
4  - [Hamming]
5  - [Levenshtein] - distance & normalized
6  - [Optimal string alignment]
7  - [Damerau-Levenshtein] - distance & normalized
8  - [Jaro and Jaro-Winkler] - this implementation of Jaro-Winkler does not limit the common prefix length
9
10### Installation
11```toml
12# Cargo.toml
13[dependencies]
14strsim = "0.8.0"
15```
16
17### [Documentation](https://docs.rs/strsim/)
18You can change the version in the url to see the documentation for an older
19version in the
20[changelog](https://github.com/dguo/strsim-rs/blob/master/CHANGELOG.md).
21
22### Usage
23```rust
24extern crate strsim;
25
26use strsim::{hamming, levenshtein, normalized_levenshtein, osa_distance,
27             damerau_levenshtein, normalized_damerau_levenshtein, jaro,
28             jaro_winkler};
29
30fn main() {
31    match hamming("hamming", "hammers") {
32        Ok(distance) => assert_eq!(3, distance),
33        Err(why) => panic!("{:?}", why)
34    }
35
36    assert_eq!(3, levenshtein("kitten", "sitting"));
37
38    assert!((normalized_levenshtein("kitten", "sitting") - 0.57142).abs() < 0.00001);
39
40    assert_eq!(3, osa_distance("ac", "cba"));
41
42    assert_eq!(2, damerau_levenshtein("ac", "cba"));
43
44    assert!((normalized_damerau_levenshtein("levenshtein", "löwenbräu") - 0.27272).abs() < 0.00001)
45
46    assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() <
47            0.001);
48
49    assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() <
50            0.001);
51}
52```
53
54### Development
55If you don't want to install Rust itself, you can run `$ ./dev` for a
56development CLI if you have [Docker] installed.
57
58Benchmarks require a Nightly toolchain. They are run by `cargo +nightly bench`.
59
60### License
61[MIT](https://github.com/dguo/strsim-rs/blob/master/LICENSE)
62
63[string similarity metrics]:http://en.wikipedia.org/wiki/String_metric
64[Damerau-Levenshtein]:http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance
65[Jaro and Jaro-Winkler]:http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance
66[Levenshtein]:http://en.wikipedia.org/wiki/Levenshtein_distance
67[Hamming]:http://en.wikipedia.org/wiki/Hamming_distance
68[Optimal string alignment]:https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#Optimal_string_alignment_distance
69[Docker]:https://docs.docker.com/engine/installation/
70