[][src]Struct rust_tokenizers::tokenizer::MarianTokenizer

pub struct MarianTokenizer { /* fields omitted */ }

Marian tokenizer

Marian tokenizer performing:

  • splitting on language codes
  • text cleaning
  • NFKC decomposition
  • (optional) lower casing
  • SentencePiece decomposition

Implementations

impl MarianTokenizer[src]

pub fn from_files(
    vocab_path: &str,
    model_path: &str,
    lower_case: bool
) -> Result<MarianTokenizer, TokenizerError>
[src]

Create a new instance of a MarianTokenizer Expects a json vocab file and a SentencePiece protobuf file as an input.

Parameters

  • vocab_path (&str): path to the JSON vocab file
  • model_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

Example

use rust_tokenizers::tokenizer::{MarianTokenizer, Tokenizer};
let lower_case = false;
let tokenizer =
    MarianTokenizer::from_files("path/to/vocab/file", "path/to/model/file", lower_case)
        .unwrap();

pub fn from_existing_vocab_and_model(
    vocab: MarianVocab,
    model: SentencePieceModel,
    lower_case: bool
) -> MarianTokenizer
[src]

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

Parameters

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

Example

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

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

Trait Implementations

impl MultiThreadedTokenizer<MarianVocab> for MarianTokenizer[src]

impl Tokenizer<MarianVocab> for MarianTokenizer[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.