generic_levenshtein

Crates.iogeneric_levenshtein
lib.rsgeneric_levenshtein
version
sourcesrc
created_at2019-12-15 18:17:45.861281+00
updated_at2025-03-02 09:53:38.304212+00
descriptionGeneric and fast implementation of the Levenshtein distance
homepagehttps://heptapod.host/jmb/rust_generic_levenshtein
repository
max_upload_size
id189585
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(jeberger)

documentation

README

README

Docs

A generic and fast implementation of the Levenshtein distance.

Generic

This crate can work on slices of any kind. It can therefore:

  • Compute a distance in characters between two strings:
assert_eq!(distance ("abc", "aaxcc"), 3);
  • Compute a distance in words between two strings:
assert_eq!(
   distance (
      "The quick brown fox".split (' ').collect::<Vec<_>>(),
      "The very quick brown cat".split (' ').collect()),
   2);
  • Or even compute a distance between two sequences of anything:
assert_eq!(distance (vec![1, 2, 3], vec![0, 1, 3, 3, 4]), 3);

Fast

At the time of writing, this crate is among the fastest on crates.io when working with text:

Identical Same length Different lengths
generic_levenshtein 2 3_316 3_842
levenshtein v1.0.4 2 3_461 3_960
strsim v0.11.1 2_450 2_279 2_928
distance v0.4.0 5_688 5_691 5_831
eddie v0.4.2 61 1_650 2_531
txtdist v0.2.1 4_263 4_240 4_963
fuzzy-search v0.1.1 5_879 5_761 6_532

All times in ns on an AMD Ryzen 7 9700X @ 3.8GHz.

Commit count: 0

cargo fmt