pub struct Ngrams { /* private fields */ }Expand description
An n-gram counter for counting n-gram frequencies.
Accumulates n-gram counts from sequences of elements. N-grams do not cross sequence boundaries.
For Python, use [PyNgrams].
Implementations§
Trait Implementations§
Source§impl BaseNgrams for Ngrams
impl BaseNgrams for Ngrams
fn order(&self) -> usize
fn min_order(&self) -> usize
fn counts(&self) -> &CountTrie<String>
fn counts_mut(&mut self) -> &mut CountTrie<String>
fn totals(&self) -> &Vec<u64>
fn totals_mut(&mut self) -> &mut Vec<u64>
fn from_parts( order: usize, min_order: usize, counts: CountTrie<String>, totals: Vec<u64>, ) -> Self
Source§fn validate_order(&self, order: Option<usize>) -> Result<(), ModelError>
fn validate_order(&self, order: Option<usize>) -> Result<(), ModelError>
Validate that an order is within the valid range.
Source§fn most_common_items(
&self,
n: Option<usize>,
order: Option<usize>,
) -> Result<Vec<(Vec<String>, u64)>, ModelError>
fn most_common_items( &self, n: Option<usize>, order: Option<usize>, ) -> Result<Vec<(Vec<String>, u64)>, ModelError>
Return the n most common n-grams with their counts.
Source§fn items_list(
&self,
order: Option<usize>,
) -> Result<Vec<(Vec<String>, u64)>, ModelError>
fn items_list( &self, order: Option<usize>, ) -> Result<Vec<(Vec<String>, u64)>, ModelError>
Return all (n-gram, count) pairs.
Source§fn total(&self, order: Option<usize>) -> Result<u64, ModelError>
fn total(&self, order: Option<usize>) -> Result<u64, ModelError>
Return the total number of n-gram tokens counted.
Source§fn repr_string(&self) -> String
fn repr_string(&self) -> String
Return a string representation.
Source§fn add(&self, other: &Self) -> Result<Self, ModelError>
fn add(&self, other: &Self) -> Result<Self, ModelError>
Add two n-gram counters together, returning a new counter.
Auto Trait Implementations§
impl Freeze for Ngrams
impl RefUnwindSafe for Ngrams
impl Send for Ngrams
impl Sync for Ngrams
impl Unpin for Ngrams
impl UnsafeUnpin for Ngrams
impl UnwindSafe for Ngrams
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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