1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Lattice data structures for representing correction alternatives.
//!
//! A lattice is a weighted directed acyclic graph (DAG) where:
//! - Nodes represent positions in the input sequence
//! - Edges represent token alternatives with weights
//! - Paths from start to end represent complete correction sequences
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────────────┐
//! │ Lattice Structure │
//! ├─────────────────────────────────────────────────────────────────────────┤
//! │ │
//! │ Input: "teh quik fox" │
//! │ │
//! │ ┌───the(0.5)───┐ │
//! │ start ────►│ ├───quick(0.5)───►fox(0.0)──►end │
//! │ └───teh(0.0)───┤ ▲ │
//! │ └───quik(0.0)───┘ │
//! │ │
//! │ Best path: "the quick fox" (weight: 1.0) │
//! │ │
//! └─────────────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Example
//!
//! ```rust
//! use lling_llang::lattice::{LatticeBuilder, EdgeMetadata};
//! use lling_llang::backend::HashMapBackend;
//! use lling_llang::semiring::TropicalWeight;
//!
//! let backend = HashMapBackend::new();
//! let mut builder = LatticeBuilder::<TropicalWeight, _>::new(backend);
//!
//! // Add correction alternatives
//! builder.add_correction(0, 1, "the", TropicalWeight::new(0.5), EdgeMetadata::default());
//! builder.add_correction(0, 1, "teh", TropicalWeight::new(0.0), EdgeMetadata::original());
//!
//! let lattice = builder.build(1);
//! ```
pub use ;
pub use LatticeBuilder;
pub use ;
pub use Lattice;
pub use ;