Struct rust_tokenizers::TokenRef [−][src]
pub struct TokenRef<'a> {
pub text: &'a str,
pub offset: Offset,
pub reference_offsets: &'a [OffsetSize],
pub mask: Mask,
}
Expand description
Reference token that references the original text, with a string slice representation
Fields
text: &'a str
String representation
offset: Offset
Start 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: Mask
Mask indicating the type of the token
Implementations
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);
Trait Implementations
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];
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];
Notable traits for ConsolidatedTokenIterator<'a, T>
impl<'a, T> Iterator for ConsolidatedTokenIterator<'a, T> where
T: TokenTrait, type Item = &'a [T];
Creates an iterator from a sequence of ConsolidatableTokens
.
Auto Trait Implementations
impl<'a> RefUnwindSafe for TokenRef<'a>
impl<'a> UnwindSafe for TokenRef<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more