Struct rust_tokenizers::Token[][src]

pub struct Token {
    pub text: String,
    pub offset: Offset,
    pub reference_offsets: Vec<OffsetSize>,
    pub mask: Mask,
}

Owned token that references the original text but stores its own string representation.

Fields

text: String

String representation

offset: Offset

Start and end positions of the token with respect to the original text

reference_offsets: Vec<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 Token[src]

pub fn new(text: String) -> Token[src]

Creates a new owned token from a String.

Parameters

  • text (String): text reference

Example

use rust_tokenizers::Token;
let text = "world".to_string();
let token = Token::new(text);

pub fn as_ref(&self) -> TokenRef<'_>[src]

Converts an owned token to a reference form

Example

use rust_tokenizers::Token;
let text = "world".to_string();
let token = Token::new(text);

let token_ref = token.as_ref();

Trait Implementations

impl Clone for Token[src]

impl ConsolidatableTokens<Token> for Vec<Token>[src]

impl Debug for Token[src]

impl From<&'_ str> for Token[src]

impl<'a> From<&'a Token> for TokenRef<'a>[src]

impl<'a> From<TokenRef<'a>> for Token[src]

impl PartialEq<Token> for Token[src]

impl StructuralPartialEq for Token[src]

impl TokenTrait for Token[src]

Auto Trait Implementations

impl RefUnwindSafe for Token

impl Send for Token

impl Sync for Token

impl Unpin for Token

impl UnwindSafe for Token

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.