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_distance_with_cutoff,
try_damerau_distance, try_damerau_distance_with_cutoff,
try_distance_with_trace, try_within_distance, and
try_within_damerau_distance when lattices come from external input. The
infallible lattice 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);Modules§
- dot
- DOT rendering helpers for lattice comparison graphs.
Structs§
- Arc
- Directed arc between two lattice nodes.
- Distance
Trace - Edit distance plus one best sequence of edit operations.
- Distance
Workspace - Reusable buffers for repeated lattice distance computations.
- Lattice
- A directed acyclic lattice with one start node and one end node.
- String
Distance Workspace - Reusable buffers for plain Unicode-scalar string distance computations.
- 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.
- levenshtein_
str_ with_ cutoff - Computes Levenshtein distance over Unicode scalar values up to
threshold. - 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_ distance_ with_ cutoff - Computes lattice Damerau-Levenshtein distance up to
threshold. - try_
damerau_ levenshtein_ str - Computes optimal string alignment Damerau-Levenshtein distance with the fallible API shape used by lattice distances.
- try_
damerau_ levenshtein_ str_ with_ cutoff - Computes optimal string alignment Damerau-Levenshtein distance up to
threshold. - try_
distance - Computes lattice edit distance with explicit matrix-size validation.
- try_
distance_ with_ cutoff - Computes lattice edit distance up to
threshold. - 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.