Crates.io | distance |
lib.rs | distance |
version | 0.4.0 |
source | src |
created_at | 2016-06-27 22:50:44.836758 |
updated_at | 2016-07-10 14:23:28.899206 |
description | A collection of approximate string matching algorithms |
homepage | |
repository | https://github.com/mbrlabs/distance |
max_upload_size | |
id | 5514 |
size | 31,453 |
This is a rust library for approximate string matching algorithms.
Possible applications for this are fuzzy string searching, spell checkers, spam filters, etc.
All algorithms support UTF-8 encoded strings.
distance is available on crates.io.
[dependencies]
distance = "0.4"
use distance::*;
// Levenshtein distance
let distance = levenshtein("hannah", "hanna");
assert_eq!(1, distance);
// Damerau Levenshtein distance
let distance = damerau_levenshtein("hannah", "hannha");
assert_eq!(1, distance);
// Hamming distance
let distance = hamming("karolin", "kathrin").unwrap();
assert_eq!(3, distance);
// Sift3 distance
let distance = sift3("hannah", "hanna");
assert_eq!(0.5, distance);