Skip to main content

Tokenizer

Trait Tokenizer 

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

    // Provided method
    fn tokenize_with(
        &self,
        text: &str,
        hint: Option<&str>,
        purpose: Purpose,
    ) -> Vec<Token> { ... }
}
Expand description

Trait for tokenizers

Required Methods§

Source

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

Tokenize the input text into a vector of tokens

Provided Methods§

Source

fn tokenize_with( &self, text: &str, hint: Option<&str>, purpose: Purpose, ) -> Vec<Token>

Tokenize with a caller-supplied hint and a purpose.

Static tokenizers ignore both and have a single form. A LexTokenizer reads the hint as a comma-separated list of language codes (a sibling document field at index time, tokenizer_hint on the query) and emits the forms the purpose asks for (see Purpose).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§