Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
.github/ | 07-Sep-2024 | - | 28 | 22 | ||
benches/ | 07-Sep-2024 | - | 101 | 85 | ||
src/ | 07-Sep-2024 | - | 1,006 | 712 | ||
tests/ | 07-Sep-2024 | - | 50 | 40 | ||
.editorconfig | D | 07-Sep-2024 | 213 | 14 | 11 | |
.gitattributes | D | 07-Sep-2024 | 84 | 4 | 2 | |
.gitignore | D | 07-Sep-2024 | 42 | 6 | 5 | |
BUILD.gn | D | 07-Sep-2024 | 1 KiB | 28 | 24 | |
CHANGELOG.md | D | 07-Sep-2024 | 5.1 KiB | 204 | 124 | |
Cargo.toml | D | 07-Sep-2024 | 531 | 16 | 15 | |
LICENSE | D | 07-Sep-2024 | 1.1 KiB | 24 | 19 | |
README.OpenSource | D | 07-Sep-2024 | 346 | 11 | 11 | |
README.md | D | 07-Sep-2024 | 3.4 KiB | 103 | 72 | |
dev | D | 07-Sep-2024 | 1.1 KiB | 42 | 30 |
README.OpenSource
1 [ 2 { 3 "Name": "strsim-rs", 4 "License": "Apache License V2.0, MIT", 5 "License File": "LICENSE-APACHE, LICENSE-MIT", 6 "Version Number": "0.10.0", 7 "Owner": "fangting12@huawei.com", 8 "Upstream URL": "https://github.com/dguo/strsim-rs", 9 "Description": "A Rust library that provides support for string similarity metrics." 10 } 11 ]
README.md
1 # strsim-rs 2 3 [](https://crates.io/crates/strsim) 4 [](https://github.com/dguo/strsim-rs/blob/master/LICENSE) 5 [](https://github.com/dguo/strsim-rs/actions?query=branch%3Amaster) 6 [](https://github.com/rust-secure-code/safety-dance/) 7 8 [Rust](https://www.rust-lang.org) implementations of [string similarity metrics]: 9 - [Hamming] 10 - [Levenshtein] - distance & normalized 11 - [Optimal string alignment] 12 - [Damerau-Levenshtein] - distance & normalized 13 - [Jaro and Jaro-Winkler] - this implementation of Jaro-Winkler does not limit the common prefix length 14 - [Sørensen-Dice] 15 16 The normalized versions return values between `0.0` and `1.0`, where `1.0` means 17 an exact match. 18 19 There are also generic versions of the functions for non-string inputs. 20 21 ## Installation 22 23 `strsim` is available on [crates.io](https://crates.io/crates/strsim). Add it to 24 your `Cargo.toml`: 25 ```toml 26 [dependencies] 27 strsim = "0.10.0" 28 ``` 29 30 ## Usage 31 32 Go to [Docs.rs](https://docs.rs/strsim/) for the full documentation. You can 33 also clone the repo, and run `$ cargo doc --open`. 34 35 ### Examples 36 37 ```rust 38 extern crate strsim; 39 40 use strsim::{hamming, levenshtein, normalized_levenshtein, osa_distance, 41 damerau_levenshtein, normalized_damerau_levenshtein, jaro, 42 jaro_winkler, sorensen_dice}; 43 44 fn main() { 45 match hamming("hamming", "hammers") { 46 Ok(distance) => assert_eq!(3, distance), 47 Err(why) => panic!("{:?}", why) 48 } 49 50 assert_eq!(levenshtein("kitten", "sitting"), 3); 51 52 assert!((normalized_levenshtein("kitten", "sitting") - 0.571).abs() < 0.001); 53 54 assert_eq!(osa_distance("ac", "cba"), 3); 55 56 assert_eq!(damerau_levenshtein("ac", "cba"), 2); 57 58 assert!((normalized_damerau_levenshtein("levenshtein", "löwenbräu") - 0.272).abs() < 59 0.001); 60 61 assert!((jaro("Friedrich Nietzsche", "Jean-Paul Sartre") - 0.392).abs() < 62 0.001); 63 64 assert!((jaro_winkler("cheeseburger", "cheese fries") - 0.911).abs() < 65 0.001); 66 67 assert_eq!(sorensen_dice("web applications", "applications of the web"), 68 0.7878787878787878); 69 } 70 ``` 71 72 Using the generic versions of the functions: 73 74 ```rust 75 extern crate strsim; 76 77 use strsim::generic_levenshtein; 78 79 fn main() { 80 assert_eq!(2, generic_levenshtein(&[1, 2, 3], &[0, 2, 5])); 81 } 82 ``` 83 84 ## Contributing 85 86 If you don't want to install Rust itself, you can run `$ ./dev` for a 87 development CLI if you have [Docker] installed. 88 89 Benchmarks require a Nightly toolchain. Run `$ cargo +nightly bench`. 90 91 ## License 92 93 [MIT](https://github.com/dguo/strsim-rs/blob/master/LICENSE) 94 95 [string similarity metrics]:http://en.wikipedia.org/wiki/String_metric 96 [Damerau-Levenshtein]:http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance 97 [Jaro and Jaro-Winkler]:http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance 98 [Levenshtein]:http://en.wikipedia.org/wiki/Levenshtein_distance 99 [Hamming]:http://en.wikipedia.org/wiki/Hamming_distance 100 [Optimal string alignment]:https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#Optimal_string_alignment_distance 101 [Sørensen-Dice]:http://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient 102 [Docker]:https://docs.docker.com/engine/installation/ 103