pub struct TextAnalyzer { /* private fields */ }
Expand description
TextAnalyzer
tokenizes an input text into tokens and modifies the resulting TokenStream
.
It simply wraps a Tokenizer
and a list of TokenFilter
that are applied sequentially.
Implementations§
Source§impl TextAnalyzer
impl TextAnalyzer
Sourcepub fn new<T: Tokenizer>(
tokenizer: T,
token_filters: Vec<BoxTokenFilter>,
) -> TextAnalyzer
pub fn new<T: Tokenizer>( tokenizer: T, token_filters: Vec<BoxTokenFilter>, ) -> TextAnalyzer
Creates a new TextAnalyzer
given a tokenizer and a vector of BoxTokenFilter
.
When creating a TextAnalyzer
from a Tokenizer
alone, prefer using
TextAnalyzer::from(tokenizer)
.
Sourcepub fn filter<F: Into<BoxTokenFilter>>(self, token_filter: F) -> Self
pub fn filter<F: Into<BoxTokenFilter>>(self, token_filter: F) -> Self
Appends a token filter to the current tokenizer.
The method consumes the current TokenStream
and returns a
new one.
§Example
use tantivy::tokenizer::*;
let en_stem = TextAnalyzer::from(SimpleTokenizer)
.filter(RemoveLongFilter::limit(40))
.filter(LowerCaser)
.filter(Stemmer::default());
Sourcepub fn token_stream<'a>(&self, text: &'a str) -> BoxTokenStream<'a>
pub fn token_stream<'a>(&self, text: &'a str) -> BoxTokenStream<'a>
Creates a token stream for a given str
.
Trait Implementations§
Source§impl Clone for TextAnalyzer
impl Clone for TextAnalyzer
Source§impl Default for TextAnalyzer
impl Default for TextAnalyzer
Source§fn default() -> TextAnalyzer
fn default() -> TextAnalyzer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TextAnalyzer
impl !RefUnwindSafe for TextAnalyzer
impl Send for TextAnalyzer
impl Sync for TextAnalyzer
impl Unpin for TextAnalyzer
impl !UnwindSafe for TextAnalyzer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more