pub struct Lattice { /* private fields */ }
Expand description
Lattice which is constructed for performing the Viterbi search. Contain several parallel arrays. First level of parallel arrays is indexed by end word boundary. Word boundaries are always aligned to codepoint boundaries, not to byte boundaries.
During the successive analysis, we do not drop inner vectors, so the size of vectors never shrink. You must use the size parameter to check the current size and never access vectors after the end.
Implementations§
source§impl Lattice
impl Lattice
sourcepub fn reset(&mut self, length: usize)
pub fn reset(&mut self, length: usize)
Prepare lattice for the next analysis of a sentence with the specified length (in codepoints)
sourcepub fn connect_eos(&mut self, conn: &ConnectionMatrix<'_>) -> SudachiResult<()>
pub fn connect_eos(&mut self, conn: &ConnectionMatrix<'_>) -> SudachiResult<()>
Find EOS node – finish the lattice construction
sourcepub fn insert(&mut self, node: Node, conn: &ConnectionMatrix<'_>) -> i32
pub fn insert(&mut self, node: Node, conn: &ConnectionMatrix<'_>) -> i32
Insert a single node in the lattice, founding the path to the previous node Assumption: lattice for all previous boundaries is already constructed
sourcepub fn connect_node(
&self,
r_node: &Node,
conn: &ConnectionMatrix<'_>,
) -> (NodeIdx, i32)
pub fn connect_node( &self, r_node: &Node, conn: &ConnectionMatrix<'_>, ) -> (NodeIdx, i32)
Find the path with the minimal cost through the lattice to the attached node Assumption: lattice for all previous boundaries is already constructed
sourcepub fn has_previous_node(&self, i: usize) -> bool
pub fn has_previous_node(&self, i: usize) -> bool
Checks if there exist at least one at the word end boundary
sourcepub fn fill_top_path(&self, result: &mut Vec<NodeIdx>)
pub fn fill_top_path(&self, result: &mut Vec<NodeIdx>)
Fill the path with the minimum cost (indices only). Attention: the path will be reversed (end to beginning) and will need to be traversed in the reverse order.
source§impl Lattice
impl Lattice
pub fn dump<W: Write>( &self, input: &InputBuffer, grammar: &Grammar<'_>, lexicon: &LexiconSet<'_>, out: &mut W, ) -> SudachiResult<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Lattice
impl RefUnwindSafe for Lattice
impl Send for Lattice
impl Sync for Lattice
impl Unpin for Lattice
impl UnwindSafe for Lattice
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more