Struct rust_tokenizers::TokenRef [−][src]
Reference token that references the original text, with a string slice representation
Fields
text: &'a strString representation
offset: OffsetStart and end positions of the token with respect to the original text
reference_offsets: &'a [OffsetSize]Sequence of positions with respect to the original text contained in the token.
For example, if the token offset is start: 4, end: 10, corresponding reference_offsets are [4, 5, 6, 7, 8, 9]
mask: MaskMask indicating the type of the token
Implementations
impl<'a> TokenRef<'a>[src]
pub fn new(text: &'a str, offsets: &'a [OffsetSize]) -> TokenRef<'a>[src]
Creates a new token reference from a text and list of offsets.
Parameters
- text (
&str): text reference - offsets (
&[OffsetSize]): reference positions with respect to the original text
Example
use rust_tokenizers::TokenRef; let _original_text = "Hello, world"; let text = "world"; let offsets = &[7, 8, 9, 10, 11]; let token_ref = TokenRef::new(text, offsets);
pub fn to_owned(self) -> Token[src]
Converts a token reference to an owned form.
Example
use rust_tokenizers::TokenRef; let _original_text = "Hello, world"; let text = "world"; let offsets = &[7, 8, 9, 10, 11]; let token_ref = TokenRef::new(text, offsets); let owned_token = token_ref.to_owned();
Trait Implementations
impl<'a> Clone for TokenRef<'a>[src]
impl<'a> ConsolidatableTokens<TokenRef<'a>> for Vec<TokenRef<'a>>[src]
fn iter_consolidate_tokens(&self) -> ConsolidatedTokenIterator<'_, TokenRef<'a>>ⓘNotable traits for ConsolidatedTokenIterator<'a, T>
impl<'a, T> Iterator for ConsolidatedTokenIterator<'a, T> where
T: TokenTrait, type Item = &'a [T];[src]
Notable traits for ConsolidatedTokenIterator<'a, T>
impl<'a, T> Iterator for ConsolidatedTokenIterator<'a, T> where
T: TokenTrait, type Item = &'a [T];impl<'a> Copy for TokenRef<'a>[src]
impl<'a> Debug for TokenRef<'a>[src]
impl<'a> From<&'a Token> for TokenRef<'a>[src]
impl<'a> From<TokenRef<'a>> for Token[src]
impl<'a> PartialEq<TokenRef<'a>> for TokenRef<'a>[src]
impl<'a> StructuralPartialEq for TokenRef<'a>[src]
impl<'a> TokenTrait for TokenRef<'a>[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for TokenRef<'a>
impl<'a> Send for TokenRef<'a>
impl<'a> Sync for TokenRef<'a>
impl<'a> Unpin for TokenRef<'a>
impl<'a> UnwindSafe for TokenRef<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,