pub struct LimitTokenCountFilter { /* private fields */ }
Available on crate feature
commons
only.Expand description
TokenFilter that limit the number of tokens
use tantivy_analysis_contrib::commons::LimitTokenCountFilter;
let filter:LimitTokenCountFilter = LimitTokenCountFilter::new(5);
§Example
use tantivy::tokenizer::{WhitespaceTokenizer, TextAnalyzer, Token};
use tantivy_analysis_contrib::commons::LimitTokenCountFilter;
let mut tmp = TextAnalyzer::builder(WhitespaceTokenizer::default())
.filter(LimitTokenCountFilter::from(3))
.build();
let mut token_stream = tmp.token_stream("There will be 3 tokens in the end");
let token = token_stream.next().expect("A token should be present.");
assert_eq!(token.text, "There".to_string());
let token = token_stream.next().expect("A token should be present.");
assert_eq!(token.text, "will".to_string());
let token = token_stream.next().expect("A token should be present.");
assert_eq!(token.text, "be".to_string());
assert_eq!(None, token_stream.next());
Implementations§
source§impl LimitTokenCountFilter
impl LimitTokenCountFilter
sourcepub fn new(max_tokens: usize) -> Self
pub fn new(max_tokens: usize) -> Self
Create a new LimitTokenCountFilter.
§Parameters :
- max_tokens : maximum number of tokens that will be indexed
Trait Implementations§
source§impl Clone for LimitTokenCountFilter
impl Clone for LimitTokenCountFilter
source§fn clone(&self) -> LimitTokenCountFilter
fn clone(&self) -> LimitTokenCountFilter
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for LimitTokenCountFilter
impl Debug for LimitTokenCountFilter
source§impl From<usize> for LimitTokenCountFilter
impl From<usize> for LimitTokenCountFilter
source§impl TokenFilter for LimitTokenCountFilter
impl TokenFilter for LimitTokenCountFilter
impl Copy for LimitTokenCountFilter
Auto Trait Implementations§
impl Freeze for LimitTokenCountFilter
impl RefUnwindSafe for LimitTokenCountFilter
impl Send for LimitTokenCountFilter
impl Sync for LimitTokenCountFilter
impl Unpin for LimitTokenCountFilter
impl UnwindSafe for LimitTokenCountFilter
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