pub struct TokenVisualizer { /* private fields */ }Expand description
Token visualizer implementation
Implementations§
Source§impl TokenVisualizer
impl TokenVisualizer
Sourcepub fn new(config: VisualizationConfig) -> Self
pub fn new(config: VisualizationConfig) -> Self
Create a new token visualizer
Sourcepub fn with_special_tokens(self, special_tokens: HashMap<String, u32>) -> Self
pub fn with_special_tokens(self, special_tokens: HashMap<String, u32>) -> Self
Add special tokens for recognition
Sourcepub fn visualize<T: Tokenizer>(
&self,
tokenizer: &T,
text: &str,
) -> Result<TokenVisualization>
pub fn visualize<T: Tokenizer>( &self, tokenizer: &T, text: &str, ) -> Result<TokenVisualization>
Visualize tokenization from any tokenizer
Sourcepub fn compare_tokenizers<T: Tokenizer>(
&self,
tokenizers: HashMap<String, &T>,
text: &str,
) -> Result<TokenizerComparison>
pub fn compare_tokenizers<T: Tokenizer>( &self, tokenizers: HashMap<String, &T>, text: &str, ) -> Result<TokenizerComparison>
Compare multiple tokenizers
Sourcepub fn to_html(&self, visualization: &TokenVisualization) -> String
pub fn to_html(&self, visualization: &TokenVisualization) -> String
Generate HTML visualization
Sourcepub fn to_text(&self, visualization: &TokenVisualization) -> String
pub fn to_text(&self, visualization: &TokenVisualization) -> String
Generate plain text visualization
Sourcepub fn to_json(&self, visualization: &TokenVisualization) -> Result<String>
pub fn to_json(&self, visualization: &TokenVisualization) -> Result<String>
Export visualization to JSON
Sourcepub fn comparison_report(&self, comparison: &TokenizerComparison) -> String
pub fn comparison_report(&self, comparison: &TokenizerComparison) -> String
Generate comparison report
Auto Trait Implementations§
impl Freeze for TokenVisualizer
impl RefUnwindSafe for TokenVisualizer
impl Send for TokenVisualizer
impl Sync for TokenVisualizer
impl Unpin for TokenVisualizer
impl UnsafeUnpin for TokenVisualizer
impl UnwindSafe for TokenVisualizer
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