#levenshtein #distance #algorithm #sequence #difference #compute #operational

leven-distance

Compute operational differences between two sequences using the Levenshtein algorithm

1 stable release

1.0.0 Feb 6, 2024

#1526 in Text processing

Download history 7/week @ 2024-12-07 1/week @ 2024-12-14 1/week @ 2025-02-08 1/week @ 2025-02-15 41/week @ 2025-02-22 75/week @ 2025-03-01 38/week @ 2025-03-08

156 downloads per month

MIT license

14KB
221 lines

Levenshtein

Compute operational differences between two sequences using the Levenshtein algorithm.

Add to Cargo.toml

leven-distance = "*"

Usage:

Basic Usage

use levenshtein::Levenshtein;
use levenshtein::Results;

fn main() {
    let mut levenshtein: Levenshtein = Levenshtein::new();

    // Specify costs as you see fit, the default is 1 for all parameters.
    levenshtein.set_insert_cost(2);
    levenshtein.set_replace_cost(2);
    levenshtein.set_delete_cost(2);

    let results: Results = levenshtein.calculate("test", "text");

    let distance: i32 = results.distance();
    let sequence: &Vec<Vec<i32>> = results.sequence();

    println!("Distance: {}", distance);
    println!("Sequence: {:#?}", sequence);
}

License

This project is licensed under the MIT License.
See the LICENSE file for more information.

No runtime deps