pub struct ICUTransformTokenFilter { /* private fields */ }
Available on crate feature
icu
only.Expand description
This TokenFilter allow to transform text into another, for example, to performe transliteration. See ICU documentation
use tantivy_analysis_contrib::icu::{Direction, ICUTransformTokenFilter};
let token_filter = ICUTransformTokenFilter::new(
"Any-Latin; NFD; [:Nonspacing Mark:] Remove; Lower; NFC".to_string(),
None,
Direction::Forward
)?;
§Example
Here is an example of transform that converts greek letters into latin letters
use tantivy::tokenizer::{RawTokenizer, TextAnalyzer, Token};
use tantivy_analysis_contrib::icu::{Direction, ICUTransformTokenFilter};
let mut tmp = TextAnalyzer::builder(RawTokenizer::default())
.filter(ICUTransformTokenFilter::new(
"Greek-Latin".to_string(),
None,
Direction::Forward
)?)
.build();
let mut token_stream = tmp.token_stream("Αλφαβητικός Κατάλογος");
let token = token_stream.next().expect("A token should be present.");
assert_eq!(token.text, "Alphabētikós Katálogos".to_string());
assert_eq!(None, token_stream.next());
Implementations§
Trait Implementations§
source§impl Clone for ICUTransformTokenFilter
impl Clone for ICUTransformTokenFilter
source§fn clone(&self) -> ICUTransformTokenFilter
fn clone(&self) -> ICUTransformTokenFilter
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 ICUTransformTokenFilter
impl Debug for ICUTransformTokenFilter
Auto Trait Implementations§
impl Freeze for ICUTransformTokenFilter
impl RefUnwindSafe for ICUTransformTokenFilter
impl Send for ICUTransformTokenFilter
impl Sync for ICUTransformTokenFilter
impl Unpin for ICUTransformTokenFilter
impl UnwindSafe for ICUTransformTokenFilter
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