pub struct WordPieceTokenizer { /* private fields */ }Implementations§
Source§impl WordPieceTokenizer
impl WordPieceTokenizer
Sourcepub fn from_file(path: &Path) -> Result<Self>
pub fn from_file(path: &Path) -> Result<Self>
Load vocabulary from a standard vocab.txt file (one token per line).
Sourcepub fn from_vocab_str(vocab_str: &str) -> Result<Self>
pub fn from_vocab_str(vocab_str: &str) -> Result<Self>
Build tokenizer from vocabulary string (one token per line).
Sourcepub fn encode(&self, text: &str, max_len: usize) -> TokenizedInput
pub fn encode(&self, text: &str, max_len: usize) -> TokenizedInput
Encode text into token IDs with [CLS] prefix and [SEP] suffix.
pub fn pad_id(&self) -> i32
pub fn vocab_size(&self) -> usize
Auto Trait Implementations§
impl Freeze for WordPieceTokenizer
impl RefUnwindSafe for WordPieceTokenizer
impl Send for WordPieceTokenizer
impl Sync for WordPieceTokenizer
impl Unpin for WordPieceTokenizer
impl UnsafeUnpin for WordPieceTokenizer
impl UnwindSafe for WordPieceTokenizer
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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