Skip to main content

Analyzer

Struct Analyzer 

Source
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

Source

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"]);
Source

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

Source

pub fn uses_morphology_stages(&self) -> bool

Identify components requiring immutable morphology and token-graph revisions.

Source

pub fn uses_japanese_stages(&self) -> bool

Identify Japanese token stages independently of optional normalization profiles.

Source

pub fn uses_korean_stages(&self) -> bool

Identify Korean components for storage-format and catalog capability preflight.

Source

pub fn new( tokenizer: Tokenizer, token_filters: Vec<TokenFilter>, char_filters: Vec<CharFilter>, ) -> Self

Source

pub fn with_normalization(self, normalization: NormalizationConfig) -> Self

Select normalization independently of tokenization and analysis filters.

Source

pub fn analyze(&self, text: &str) -> AnalysisResult<Vec<String>>

Source

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);
Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Analyzer

Source§

fn clone(&self) -> Analyzer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Analyzer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Analyzer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Analyzer

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Analyzer

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.