[][src]Struct rust_tokenizers::tokenizer::AlbertTokenizer

pub struct AlbertTokenizer { /* fields omitted */ }

ALBERT tokenizer

ALBERT tokenizer performing:

  • splitting on special characters
  • text cleaning
  • NFKC decomposition
  • (optional) lower casing
  • (optional) accent stripping
  • SentencePiece decomposition

Implementations

impl AlbertTokenizer[src]

pub fn from_file(
    path: &str,
    lower_case: bool,
    strip_accents: bool
) -> Result<AlbertTokenizer, TokenizerError>
[src]

Create a new instance of a AlbertTokenizer Expects a SentencePiece protobuf file as an input.

Parameters

  • path (&str): path to the SentencePiece model file
  • lower_case (bool): flag indicating if the text should be lower-cased as part of the tokenization
  • strip_accents (bool): flag indicating if accents should be stripped from the text

Example

use rust_tokenizers::tokenizer::{AlbertTokenizer, Tokenizer};
let strip_accents = false;
let lower_case = false;
let tokenizer =
    AlbertTokenizer::from_file("path/to/vocab/file", lower_case, strip_accents).unwrap();

pub fn from_existing_vocab_and_model(
    vocab: AlbertVocab,
    model: SentencePieceModel,
    lower_case: bool,
    strip_accents: bool
) -> AlbertTokenizer
[src]

Create a new instance of a AlbertTokenizer from an existing vocabulary and model

Parameters

  • vocab (AlbertVocab): vocabulary
  • model (SentencePieceModel): SentencePiece model
  • lower_case (bool): flag indicating if the text should be lower-cased as part of the tokenization
  • strip_accents (bool): flag indicating if accents should be stripped from the text

Example

use rust_tokenizers::tokenizer::{AlbertTokenizer, Tokenizer};
use rust_tokenizers::vocab::{AlbertVocab, SentencePieceModel, Vocab};
let strip_accents = false;
let lower_case = false;
let vocab = AlbertVocab::from_file("path/to/vocab/file").unwrap();
let model = SentencePieceModel::from_file("path/to/model/file").unwrap();

let tokenizer =
    AlbertTokenizer::from_existing_vocab_and_model(vocab, model, lower_case, strip_accents);

Trait Implementations

impl MultiThreadedTokenizer<AlbertVocab> for AlbertTokenizer[src]

impl Tokenizer<AlbertVocab> for AlbertTokenizer[src]

Auto Trait Implementations

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, 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.