Struct instant_segment::Segmenter[][src]

pub struct Segmenter { /* fields omitted */ }
Expand description

Central data structure used to calculate word probabilities

Implementations

impl Segmenter[src]

pub fn from_iters<U, B>(unigrams: U, bigrams: B) -> Self where
    U: Iterator<Item = (String, f64)>,
    B: Iterator<Item = ((String, String), f64)>, 
[src]

Create Segmenter from the given iterators

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.

pub fn from_maps(
    unigrams: HashMap<String, f64, RandomState>,
    bigrams: HashMap<(String, String), f64, RandomState>
) -> Self
[src]

Create Segmenter from the given hashmaps (using ahash)

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. The HashMap type here refers to std::collections::HashMap parametrized with the ahash::RandomState.

pub fn segment<'a>(
    &self,
    input: &str,
    search: &'a mut Search
) -> Result<impl Iterator<Item = &'a str> + ExactSizeIterator, InvalidCharacter>
[src]

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.

pub fn score_sentence<'a>(
    &self,
    words: impl Iterator<Item = &'a str>
) -> Option<f64>
[src]

Returns the sentence’s score

Returns the relative probability for the given sentence in the the corpus represented by this Segmenter. Will return None iff given an empty iterator argument.

pub fn set_limit(&mut self, limit: usize)[src]

Customize the word length limit

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.