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);

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Creates an iterator from a sequence of ConsolidatableTokens.

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Returns the offset of the token with respect to the original string

Returns the token mask

Returns a string representation for the token

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.