Struct rust_tokenizers::TokenRef[][src]

pub struct TokenRef<'a> {
    pub text: &'a str,
    pub offset: Offset,
    pub reference_offsets: &'a [OffsetSize],
    pub mask: Mask,
}

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

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.