pub struct Tokenizer { /* private fields */ }Expand description
A tokenizer that automatically determines the appropriate tokenizer.
Implementations§
Trait Implementations§
Source§impl Tokenizer for Tokenizer
impl Tokenizer for Tokenizer
Source§fn encode(&self, input: &str) -> Result<Vec<String>>
fn encode(&self, input: &str) -> Result<Vec<String>>
Encodes a given string into a sequence of tokens.
This function takes a reference to a string and returns a vector of token strings resulting from the tokenization process.
§Arguments
input- A reference to the string to be tokenized.
§Returns
A Result containing either the vector of tokens if successful or an error if the
tokenization fails.
Source§fn decode(&self, tokens: Vec<String>) -> Result<String>
fn decode(&self, tokens: Vec<String>) -> Result<String>
Decodes a given sequence of tokens back into a single string.
This function takes a vector of token strings and reconstructs the original string.
§Arguments
tokens- A vector of strings representing the tokens to be decoded.
§Returns
A Result containing either the reconstructed string if successful or an error if the
decoding fails.
Auto Trait Implementations§
impl Freeze for Tokenizer
impl !RefUnwindSafe for Tokenizer
impl Send for Tokenizer
impl Sync for Tokenizer
impl Unpin for Tokenizer
impl !UnwindSafe for Tokenizer
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