pub struct Tokenizer { /* private fields */ }Expand description
A tokenizer that can count tokens in text.
Implementations§
Source§impl Tokenizer
impl Tokenizer
Sourcepub fn new(kind: TokenizerKind) -> Self
pub fn new(kind: TokenizerKind) -> Self
Create a new tokenizer of the given kind. Falls back to heuristic if the BPE model fails to load.
Sourcepub fn count_tokens(&self, content: &str, is_prose: bool) -> usize
pub fn count_tokens(&self, content: &str, is_prose: bool) -> usize
Count tokens in the given text.
Sourcepub fn kind(&self) -> &TokenizerKind
pub fn kind(&self) -> &TokenizerKind
Return the kind of this tokenizer.
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