pub enum TokenFilter {
Lowercase,
Stop {
language: String,
custom_words: Vec<String>,
},
PorterStem,
ASCIIFolding,
Synonym {
synonyms: BTreeMap<String, Vec<String>>,
synonyms_path: Option<PathBuf>,
},
Ngram {
min_gram: usize,
max_gram: usize,
keep_short: bool,
},
EdgeNgram {
min_gram: usize,
max_gram: usize,
},
Length {
min_length: usize,
max_length: usize,
},
}Variants§
Lowercase
Stop
PorterStem
ASCIIFolding
Synonym
Fields
Ngram
EdgeNgram
Length
Implementations§
Source§impl TokenFilter
impl TokenFilter
Sourcepub fn validate(&self) -> AnalysisResult<()>
pub fn validate(&self) -> AnalysisResult<()>
Validate configuration without filtering tokens. File-backed synonym
filters are read here so registration rejects missing/unreadable paths;
Self::filter reads them again on every execution to detect later
deletion, permission changes, and edits.
Sourcepub fn synonym_from_path<P: AsRef<Path>>(
path: P,
) -> Result<Self, SynonymFileError>
pub fn synonym_from_path<P: AsRef<Path>>( path: P, ) -> Result<Self, SynonymFileError>
Build a Synonym filter from a Solr or Elasticsearch synonym file.
In this format,
blank lines and # comments are skipped, a => b, c defines a
one-way mapping, and a, b, c defines an equivalent group
where every term expands to the other group members.
Sourcepub fn parse_synonym_file(
path: &Path,
) -> Result<BTreeMap<String, Vec<String>>, SynonymFileError>
pub fn parse_synonym_file( path: &Path, ) -> Result<BTreeMap<String, Vec<String>>, SynonymFileError>
Parse a synonym file into the same shape Synonym::synonyms
uses. Public so engines can pre-resolve a path to an inline map.
Source§impl TokenFilter
impl TokenFilter
pub fn filter(&self, tokens: Vec<String>) -> AnalysisResult<Vec<String>>
Sourcepub fn filter_analyzed(
&self,
input: AnalyzedText,
) -> AnalysisResult<AnalyzedText>
pub fn filter_analyzed( &self, input: AnalyzedText, ) -> AnalysisResult<AnalyzedText>
Transform tokens while retaining their source spans and graph end state.
Sourcepub fn filter_analyzed_budgeted(
&self,
input: Budgeted<AnalyzedText>,
poll: impl FnMut() -> AnalysisResult<()>,
) -> AnalysisResult<Budgeted<AnalyzedText>>
pub fn filter_analyzed_budgeted( &self, input: Budgeted<AnalyzedText>, poll: impl FnMut() -> AnalysisResult<()>, ) -> AnalysisResult<Budgeted<AnalyzedText>>
Consume a reserved stream and retain its allowance through every common or Korean token filter.
The returned tokens retain their own terms, morphology, terminal state and vector reservations, and share existing source leases. Removed buffers release their reservations after destruction; replacements and copies reserve before allocation. Byte-limit and callback errors return no partial result. Immutable filter preparation and caller-owned configuration have separate ownership.
use uqa_analysis::{TokenFilter, Tokenizer};
use uqa_core::memory::MemoryBudget;
let budget = MemoryBudget::new(64 * 1024);
let tokens = Tokenizer::Whitespace.tokenize_with_offsets_budgeted(
"UQA AND", &budget, || Ok(()),
)?;
let output = TokenFilter::Lowercase.filter_analyzed_budgeted(tokens, || Ok(()))?;
assert_eq!(output.tokens()[0].term(), "uqa");
drop(output);
assert_eq!(budget.used(), 0);Trait Implementations§
Source§impl Clone for TokenFilter
impl Clone for TokenFilter
Source§fn clone(&self) -> TokenFilter
fn clone(&self) -> TokenFilter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more