Struct rust_tokenizers::tokenizer::BertTokenizer[][src]

pub struct BertTokenizer { /* fields omitted */ }

BERT tokenizer

BERT tokenizer performing:

  • BaseTokenizer tokenization (see BaseTokenizer for more details)
  • WordPiece tokenization

Implementations

impl BertTokenizer[src]

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

Create a new instance of a BertTokenizer Expects a vocabulary flat-file as an input.

Parameters

  • path (&str): path to the vocabulary 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::{BertTokenizer, Tokenizer};
let strip_accents = false;
let lower_case = false;
let tokenizer =
    BertTokenizer::from_file("path/to/vocab/file", lower_case, strip_accents).unwrap();

pub fn from_existing_vocab(
    vocab: BertVocab,
    lower_case: bool,
    strip_accents: bool
) -> BertTokenizer
[src]

Create a new instance of a BertTokenizer from an existing vocabulary

Parameters

  • vocab (BertVocab): Thread-safe reference to a BERT vocabulary
  • 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::{BertTokenizer, Tokenizer};
use rust_tokenizers::vocab::{BertVocab, Vocab};
let strip_accents = false;
let lower_case = false;
let vocab = BertVocab::from_file("path/to/vocab/file").unwrap();

let tokenizer = BertTokenizer::from_existing_vocab(vocab, lower_case, strip_accents);

Trait Implementations

impl MultiThreadedTokenizer<BertVocab> for BertTokenizer[src]

impl Tokenizer<BertVocab> for BertTokenizer[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.