pub struct PrependableEncoder<'a> { /* private fields */ }
Expand description
Encoder which keeps track of the encoding length while prepending characters.
Implementations§
Source§impl<'a> PrependableEncoder<'a>
impl<'a> PrependableEncoder<'a>
pub fn new(bpe: &'a BytePairEncoding) -> PrependableEncoder<'a>
pub fn truncate(&mut self, len: usize)
Sourcepub fn extend(&mut self, iter: impl Iterator<Item = u8>)
pub fn extend(&mut self, iter: impl Iterator<Item = u8>)
Prepends multiple bytes to the input string.
Sourcepub fn push(&mut self, c: u8)
pub fn push(&mut self, c: u8)
Prepends a byte to the input string which should be tokenized. The operation is amortized O(1) (due to vector resizing).
Sourcepub fn token_count(&self) -> usize
pub fn token_count(&self) -> usize
Returns the number of tokens required to tokenize the input text. This operation is O(1) and can be called at any point in time.
pub fn len(&self) -> usize
Trait Implementations§
Source§impl<'a> Clone for PrependableEncoder<'a>
impl<'a> Clone for PrependableEncoder<'a>
Source§fn clone(&self) -> PrependableEncoder<'a>
fn clone(&self) -> PrependableEncoder<'a>
Returns a copy 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<'a> Freeze for PrependableEncoder<'a>
impl<'a> RefUnwindSafe for PrependableEncoder<'a>
impl<'a> Send for PrependableEncoder<'a>
impl<'a> Sync for PrependableEncoder<'a>
impl<'a> Unpin for PrependableEncoder<'a>
impl<'a> UnwindSafe for PrependableEncoder<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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