pub struct Analyzer {
pub tokenizer: Tokenizer,
pub token_filters: Vec<TokenFilter>,
pub char_filters: Vec<CharFilter>,
pub normalization: Option<NormalizationConfig>,
}Fields§
§tokenizer: Tokenizer§token_filters: Vec<TokenFilter>§char_filters: Vec<CharFilter>§normalization: Option<NormalizationConfig>Implementations§
Source§impl Analyzer
impl Analyzer
Sourcepub fn compile(&self) -> AnalysisResult<Arc<CompiledAnalyzer>>
pub fn compile(&self) -> AnalysisResult<Arc<CompiledAnalyzer>>
Resolve immutable inputs and reuse prepared stages with the default resource owner.
Each file-backed synonym stage resolves its map during compilation. The existing uncompiled analysis methods continue to reload it on every call.
use uqa_analysis::standard_analyzer;
let compiled = standard_analyzer("english").compile()?;
let result = compiled.analyze_tokens("The cats and")?;
assert_eq!(result.tokens()[0].term(), "cat");
assert_eq!(result.tokens()[0].offsets().unwrap().utf8, 4..8);
assert_eq!(result.tokens()[0].position_increment(), 2);
assert_eq!(result.final_position_increment(), 1);
assert_eq!(compiled.analyze("Dogs")?, ["dog"]);Sourcepub fn compile_with_resources(
&self,
resources: &AnalyzerResources,
) -> AnalysisResult<Arc<CompiledAnalyzer>>
pub fn compile_with_resources( &self, resources: &AnalyzerResources, ) -> AnalysisResult<Arc<CompiledAnalyzer>>
Resolve and compile this configuration with an explicit bounded resource owner.
Source§impl Analyzer
impl Analyzer
Sourcepub fn uses_morphology_stages(&self) -> bool
pub fn uses_morphology_stages(&self) -> bool
Identify components requiring immutable morphology and token-graph revisions.
Sourcepub fn uses_japanese_stages(&self) -> bool
pub fn uses_japanese_stages(&self) -> bool
Identify Japanese token stages independently of optional normalization profiles.
Sourcepub fn uses_korean_stages(&self) -> bool
pub fn uses_korean_stages(&self) -> bool
Identify Korean components for storage-format and catalog capability preflight.
pub fn new( tokenizer: Tokenizer, token_filters: Vec<TokenFilter>, char_filters: Vec<CharFilter>, ) -> Self
Sourcepub fn with_normalization(self, normalization: NormalizationConfig) -> Self
pub fn with_normalization(self, normalization: NormalizationConfig) -> Self
Select normalization independently of tokenization and analysis filters.
pub fn analyze(&self, text: &str) -> AnalysisResult<Vec<String>>
Sourcepub fn analyze_tokens(&self, text: &str) -> AnalysisResult<AnalyzedText>
pub fn analyze_tokens(&self, text: &str) -> AnalysisResult<AnalyzedText>
Analyze complete input without discarding token graph or original source metadata.
use uqa_analysis::standard_analyzer;
let analyzed = standard_analyzer("english").analyze_tokens("The cats and")?;
let token = &analyzed.tokens()[0];
assert_eq!(token.term(), "cat");
assert_eq!(token.offsets().unwrap().utf8, 4..8);
assert_eq!(token.position_increment(), 2);
assert_eq!(analyzed.final_position_increment(), 1);
assert_eq!(analyzed.final_offsets().utf8, 12..12);Sourcepub fn analyze_tokens_budgeted(
&self,
text: &str,
budget: &MemoryBudget,
poll: impl FnMut() -> AnalysisResult<()>,
) -> AnalysisResult<Budgeted<AnalyzedText>>
pub fn analyze_tokens_budgeted( &self, text: &str, budget: &MemoryBudget, poll: impl FnMut() -> AnalysisResult<()>, ) -> AnalysisResult<Budgeted<AnalyzedText>>
Analyze with one runtime allowance while retaining the uncompiled API’s resource reload behavior.
Filter preparation and caller configuration have separate ownership. Use a compiled analyzer to resolve immutable resources before execution and reuse them across calls.
Sourcepub fn validate(&self) -> AnalysisResult<()>
pub fn validate(&self) -> AnalysisResult<()>
Validate every configured stage without consuming input.
Registration paths should call this to fail before persistence. Each execution method remains independently fallible because analyzer values can come from legacy persisted data and external synonym files can become unreadable after validation.