pub struct SemanticQueryExpander {
pub registry: Vec<TermEntry>,
pub max_expansions: usize,
pub total_expansions: u64,
pub total_variants_generated: u64,
}Expand description
Expands semantic search queries using a registry of term relations.
The expander maintains a list of TermEntry records that encode relations
(synonym, hypernym, hyponym, antonym) between pairs of terms. Given a raw
query string and an ExpansionStrategy, SemanticQueryExpander::expand
produces an ExpandedQuery with up to max_expansions variants.
Fields§
§registry: Vec<TermEntry>All known term-relation entries.
max_expansions: usizeMaximum number of expansion variants returned per call (default 5).
total_expansions: u64Cumulative count of successful expand() calls.
total_variants_generated: u64Cumulative count of expansion variants generated (not counting the original).
Implementations§
Source§impl SemanticQueryExpander
impl SemanticQueryExpander
Sourcepub fn new(max_expansions: usize) -> Self
pub fn new(max_expansions: usize) -> Self
Create a new expander with an empty registry.
§Arguments
max_expansions– maximum number of variant strings returned by eachSemanticQueryExpander::expandcall. Must be ≥ 1; a value of 0 means no variants are ever produced.
Sourcepub fn register_term(&mut self, entry: TermEntry)
pub fn register_term(&mut self, entry: TermEntry)
Append a new TermEntry to the registry.
Sourcepub fn expand(
&mut self,
query: &str,
strategy: ExpansionStrategy,
) -> ExpandedQuery
pub fn expand( &mut self, query: &str, strategy: ExpansionStrategy, ) -> ExpandedQuery
Expand query according to strategy, returning an ExpandedQuery.
Internally, the method:
- Looks up matching entries in the registry (case-insensitive term match).
- Formats candidate strings according to the strategy.
- Sorts candidates by weight (descending), then deduplicates.
- Caps the result at
SemanticQueryExpander::max_expansions. - Updates cumulative statistics.
Sourcepub fn stats(&self) -> ExpanderStats
pub fn stats(&self) -> ExpanderStats
Return a snapshot of the current runtime statistics.
Auto Trait Implementations§
impl Freeze for SemanticQueryExpander
impl RefUnwindSafe for SemanticQueryExpander
impl Send for SemanticQueryExpander
impl Sync for SemanticQueryExpander
impl Unpin for SemanticQueryExpander
impl UnsafeUnpin for SemanticQueryExpander
impl UnwindSafe for SemanticQueryExpander
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.