Skip to main content

Tokenizer

Trait Tokenizer 

Source
pub trait Tokenizer: Send + Sync {
    // Required method
    fn tokenize(&self, text: &str) -> Vec<String>;

    // Provided method
    fn name(&self) -> &'static str { ... }
}
Expand description

Trait for text tokenization

Implementers provide different tokenization strategies:

  • SimpleTokenizer: Basic whitespace + punctuation splitting
  • LanguageTokenizer: Stopword removal + optional stemming
  • WhitespaceTokenizer: Split on whitespace only
  • NGramTokenizer: Character or word n-grams

Required Methods§

Source

fn tokenize(&self, text: &str) -> Vec<String>

Tokenize text into a vector of tokens

Provided Methods§

Source

fn name(&self) -> &'static str

Get a description of this tokenizer

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§