pub struct Tokenizer { /* private fields */ }Expand description
A configured tokenizer that normalizes and filters text into terms.
Implementations§
Source§impl Tokenizer
impl Tokenizer
Sourcepub fn new(config: &TokenizerConfig) -> Self
pub fn new(config: &TokenizerConfig) -> Self
Create a new tokenizer with the given configuration.
Loads the default English stopword list from stop-words crate
unless config.custom_only is true. Merges extra_stopwords.
Sourcepub fn tokenize(&self, text: &str) -> Vec<String>
pub fn tokenize(&self, text: &str) -> Vec<String>
Tokenize text into a list of normalized terms.
- Lowercase the entire input (ASCII only)
- Split on ASCII whitespace
- Strip non-alphanumeric characters from each token (keep only a-z, 0-9)
- Remove empty tokens
- Remove stopwords
Note: Input is treated as ASCII; non-ASCII characters are silently dropped.
Sourcepub fn is_stopword(&self, term: &str) -> bool
pub fn is_stopword(&self, term: &str) -> bool
Return true if the given term is a stopword.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tokenizer
impl RefUnwindSafe for Tokenizer
impl Send for Tokenizer
impl Sync for Tokenizer
impl Unpin for Tokenizer
impl UnsafeUnpin for Tokenizer
impl UnwindSafe for Tokenizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more