Skip to main content

Crate moine_core

Crate moine_core 

Source
Expand description

Language-independent Lattice Path Edit Distance core.

moine-core provides the Lattice DAG representation and exact edit distance algorithms used by the language adapters. It intentionally has no Japanese, Chinese, Unicode-normalization, dictionary, CLI, or artifact loading logic.

Use try_distance, try_damerau_distance, try_distance_with_trace, try_within_distance, and try_within_damerau_distance when lattices come from external input. The infallible convenience functions keep examples short, but panic if the configured matrix limits would be exceeded. Trace reconstruction stores more per cell than the plain distance path, so it uses the lower MAX_TRACE_MATRIX_CELLS limit.

use moine_core::{distance, try_distance, Lattice};

let left = Lattice::from_paths(["moine"]);
let right = Lattice::from_paths(["moinya"]);

assert_eq!(distance(&left, &right), 2);
assert_eq!(try_distance(&left, &right).unwrap(), 2);

Structs§

Arc
Directed arc between two lattice nodes.
DistanceTrace
Edit distance plus one best sequence of edit operations.
Lattice
A directed acyclic lattice with one start node and one end node.
TraceStep
One operation in a reconstructed edit-distance trace.

Enums§

DistanceError
Errors returned by fallible distance functions.
EditOp
Edit operation represented in a trace step.
LatticeError
Errors returned when constructing an invalid lattice.

Constants§

MAX_DISTANCE_MATRIX_CELLS
Maximum DP matrix size accepted by non-trace distance functions.
MAX_TRACE_MATRIX_CELLS
Maximum DP matrix size accepted by trace reconstruction.

Functions§

damerau_distance
Computes lattice edit distance with adjacent transpositions.
damerau_levenshtein_str
Computes optimal string alignment Damerau-Levenshtein distance.
distance
Computes lattice edit distance.
distance_with_trace
Computes edit distance and one best trace.
levenshtein_str
Computes Levenshtein distance over Unicode scalar values.
normalized_similarity_from_distance
Converts an edit distance and sequence lengths to a similarity score.
normalized_similarity_str
Computes normalized Levenshtein similarity for two strings.
try_damerau_distance
Computes lattice edit distance with adjacent transpositions and explicit matrix-size validation.
try_damerau_levenshtein_str
Computes optimal string alignment Damerau-Levenshtein distance with explicit matrix-size validation.
try_distance
Computes lattice edit distance with explicit matrix-size validation.
try_distance_with_trace
Computes edit distance and one best trace with explicit matrix-size validation.
try_within_damerau_distance
Returns whether lattice Damerau-Levenshtein distance is at most threshold, with explicit matrix-size validation.
try_within_distance
Returns whether lattice edit distance is at most threshold, with explicit matrix-size validation.
within_damerau_distance
Returns whether lattice Damerau-Levenshtein distance is at most threshold.
within_distance
Returns whether lattice edit distance is at most threshold.

Type Aliases§

Symbol
Integer symbol stored on lattice arcs.