Struct tokenizers::models::unigram::Lattice
source · pub struct Lattice<'a> { /* private fields */ }
Expand description
Structure to implement Viterbi algorithm to find the best encoding, or sample from all possible encodings of a given sentence.
Implementations§
source§impl<'a> Lattice<'a>
impl<'a> Lattice<'a>
pub fn from(sentence: &'a str, bos_id: usize, eos_id: usize) -> Self
pub fn insert(&mut self, pos: usize, length: usize, score: f64, id: usize)
pub fn viterbi(&mut self) -> Vec<Rc<RefCell<Node>>>
pub fn piece(&self, node: &Node) -> String
pub fn tokens(&mut self) -> Vec<String>
pub fn nbest(&mut self, n: usize) -> Vec<Vec<Rc<RefCell<Node>>>>
pub fn nbest_tokens(&mut self, n: usize) -> Vec<Vec<String>>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn bos_node(&self) -> Rc<RefCell<Node>>
pub fn eos_node(&self) -> Rc<RefCell<Node>>
pub fn surface(&self, n: usize) -> &str
pub fn sentence(&self) -> &str
pub fn populate_marginal(&self, freq: f64, expected: &mut [f64]) -> f64
pub fn sample(&self, theta: f64) -> Vec<Rc<RefCell<Node>>>
pub fn sample_token(&self, theta: f64) -> Vec<String>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Lattice<'a>
impl<'a> !RefUnwindSafe for Lattice<'a>
impl<'a> !Send for Lattice<'a>
impl<'a> !Sync for Lattice<'a>
impl<'a> Unpin for Lattice<'a>
impl<'a> !UnwindSafe for Lattice<'a>
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
Mutably borrows from an owned value. Read more