weighted_levenshtein 0.1.0

Generic implementation of Levenshtein distance allowing arbitrary weighting of operations
Documentation

README

Docs

A generic implementation of the Levenshtein distance that allows weighting operations.

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);

Weighting

This crate allows defining custom weights for each operation on each symbol.