Struct instant_segment::Segmenter
source · pub struct Segmenter { /* private fields */ }
Expand description
Central data structure used to calculate word probabilities
Implementations§
source§impl Segmenter
impl Segmenter
sourcepub fn new<U, B>(unigrams: U, bigrams: B) -> Selfwhere
U: IntoIterator<Item = (String, f64)>,
B: IntoIterator<Item = ((String, String), f64)>,
pub fn new<U, B>(unigrams: U, bigrams: B) -> Selfwhere U: IntoIterator<Item = (String, f64)>, B: IntoIterator<Item = ((String, String), f64)>,
Create Segmenter
from the given unigram and bigram counts.
Note: the String
types used in this API are defined in the smartstring
crate. Any
&str
or String
can be converted into the String
used here by calling into()
on it.
sourcepub fn segment<'a>(
&self,
input: &str,
search: &'a mut Search
) -> Result<impl Iterator<Item = &'a str> + ExactSizeIterator, InvalidCharacter>
pub fn segment<'a>( &self, input: &str, search: &'a mut Search ) -> Result<impl Iterator<Item = &'a str> + ExactSizeIterator, InvalidCharacter>
Segment the text in input
Requires that the input text
consists of lowercase ASCII characters only. Otherwise,
returns Err(InvalidCharacter)
. The search
parameter contains caches that are used
segmentation; passing it in allows the callers to reuse the cache allocations.
Auto Trait Implementations§
impl RefUnwindSafe for Segmenter
impl Send for Segmenter
impl Sync for Segmenter
impl Unpin for Segmenter
impl UnwindSafe for Segmenter
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