pub struct TextVocabulary { /* private fields */ }Expand description
Character vocabulary for text generation tasks.
Maps characters to indices and vice versa.
Implementations§
Source§impl TextVocabulary
impl TextVocabulary
Sourcepub fn from_text(text: &str) -> Self
pub fn from_text(text: &str) -> Self
Create vocabulary from text, extracting unique characters.
Sourcepub fn from_chars(chars: &[char]) -> Self
pub fn from_chars(chars: &[char]) -> Self
Create vocabulary from explicit character list.
Sourcepub fn char_to_index(&self, ch: char) -> Option<usize>
pub fn char_to_index(&self, ch: char) -> Option<usize>
Get index for a character.
Sourcepub fn index_to_char(&self, idx: usize) -> Option<char>
pub fn index_to_char(&self, idx: usize) -> Option<char>
Get character for an index.
Trait Implementations§
Source§impl Clone for TextVocabulary
impl Clone for TextVocabulary
Source§fn clone(&self) -> TextVocabulary
fn clone(&self) -> TextVocabulary
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TextVocabulary
impl RefUnwindSafe for TextVocabulary
impl Send for TextVocabulary
impl Sync for TextVocabulary
impl Unpin for TextVocabulary
impl UnwindSafe for TextVocabulary
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