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.
- Distance
Trace - Edit distance plus one best sequence of edit operations.
- Lattice
- A directed acyclic lattice with one start node and one end node.
- Trace
Step - One operation in a reconstructed edit-distance trace.
Enums§
- Distance
Error - Errors returned by fallible distance functions.
- EditOp
- Edit operation represented in a trace step.
- Lattice
Error - 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.