sudachi::analysis::lattice

Struct Lattice

source
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

source

pub fn reset(&mut self, length: usize)

Prepare lattice for the next analysis of a sentence with the specified length (in codepoints)

source

pub fn connect_eos(&mut self, conn: &ConnectionMatrix<'_>) -> SudachiResult<()>

Find EOS node – finish the lattice construction

source

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

source

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

source

pub fn has_previous_node(&self, i: usize) -> bool

Checks if there exist at least one at the word end boundary

source

pub fn node(&self, id: NodeIdx) -> (&Node, i32)

Lookup a node for the index

source

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

source

pub fn dump<W: Write>( &self, input: &InputBuffer, grammar: &Grammar<'_>, lexicon: &LexiconSet<'_>, out: &mut W, ) -> SudachiResult<()>

Trait Implementations§

source§

impl Default for Lattice

source§

fn default() -> Lattice

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.