pub struct Vocabulary { /* private fields */ }Expand description
Vocabulary with frequency counts and subsampling
Implementations§
Source§impl Vocabulary
impl Vocabulary
Sourcepub fn build_from_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
pub fn build_from_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Build vocabulary from corpus file (space-separated word_ids per line)
Sourcepub fn total_words(&self) -> u64
pub fn total_words(&self) -> u64
Get total word count
Sourcepub fn max_word_id(&self) -> u32
pub fn max_word_id(&self) -> u32
Get maximum word_id in vocabulary
Sourcepub fn get_word_id(&self, remapped_id: u32) -> Option<u32>
pub fn get_word_id(&self, remapped_id: u32) -> Option<u32>
Get word_id from remapped_id
Sourcepub fn get_remapped_id(&self, word_id: u32) -> Option<u32>
pub fn get_remapped_id(&self, word_id: u32) -> Option<u32>
Fast lookup: word_id → remapped_id (O(1), for training hot path)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Vocabulary
impl RefUnwindSafe for Vocabulary
impl Send for Vocabulary
impl Sync for Vocabulary
impl Unpin for Vocabulary
impl UnwindSafe for Vocabulary
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> 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