pub struct Worker<'t> { /* private fields */ }
Expand description
Provider of a routine for tokenization.
It holds the internal data structures used in tokenization, which can be reused to avoid unnecessary memory reallocation.
Implementations§
source§impl<'t> Worker<'t>
impl<'t> Worker<'t>
sourcepub fn reset_sentence<S>(&mut self, input: S)where
S: AsRef<str>,
pub fn reset_sentence<S>(&mut self, input: S)where S: AsRef<str>,
Resets the input sentence to be tokenized.
sourcepub fn tokenize(&mut self)
pub fn tokenize(&mut self)
Tokenizes the input sentence set in state
,
returning the result through state
.
sourcepub fn num_tokens(&self) -> usize
pub fn num_tokens(&self) -> usize
Gets the number of resultant tokens.
sourcepub const fn token_iter<'w>(&'w self) -> TokenIter<'w, 't> ⓘ
pub const fn token_iter<'w>(&'w self) -> TokenIter<'w, 't> ⓘ
Creates an iterator of resultant tokens.
sourcepub fn init_connid_counter(&mut self)
pub fn init_connid_counter(&mut self)
Initializes a counter to compute occurrence probabilities of connection ids.
sourcepub fn update_connid_counts(&mut self)
pub fn update_connid_counts(&mut self)
Updates frequencies of connection ids at the last tokenization.
Panics
It will panic when Self::init_connid_counter()
has never been called.
sourcepub fn compute_connid_probs(&self) -> (Vec<(usize, f64)>, Vec<(usize, f64)>)
pub fn compute_connid_probs(&self) -> (Vec<(usize, f64)>, Vec<(usize, f64)>)
Computes the computed occurrence probabilities of connection ids, returning those for left- and right-ids.
Panics
It will panic when Self::init_connid_counter()
has never been called.
Auto Trait Implementations§
impl<'t> RefUnwindSafe for Worker<'t>
impl<'t> Send for Worker<'t>
impl<'t> Sync for Worker<'t>
impl<'t> Unpin for Worker<'t>
impl<'t> UnwindSafe for Worker<'t>
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