pub struct QueryAnalysis {
pub focal_entities: Vec<FocalEntity>,
pub discriminative_modifiers: Vec<Modifier>,
pub relational_context: Vec<Relation>,
pub compound_nouns: Vec<String>,
pub original_query: String,
pub has_negation: bool,
pub intent: QueryIntent,
}Expand description
Complete linguistic analysis of a query
Fields§
§focal_entities: Vec<FocalEntity>Focal entities (nouns) - primary search targets
discriminative_modifiers: Vec<Modifier>Discriminative modifiers (adjectives) - quality refiners
relational_context: Vec<Relation>Relational context (verbs) - graph traversal guides
compound_nouns: Vec<String>Compound nouns detected (e.g., “machine learning”, “neural network”)
original_query: StringOriginal query text (retained for logging/debugging)
has_negation: boolTrue if query contains negation
intent: QueryIntentDetected query intent for retrieval strategy selection (SHO-D6)
Implementations§
Source§impl QueryAnalysis
impl QueryAnalysis
Sourcepub fn total_weight(&self) -> f32
pub fn total_weight(&self) -> f32
Calculate weighted importance of this query (for ranking)
Sourcepub fn positive_entity_stems(&self) -> Vec<&str>
pub fn positive_entity_stems(&self) -> Vec<&str>
Get non-negated entity stems (for positive matching)
Sourcepub fn negated_entity_stems(&self) -> Vec<&str>
pub fn negated_entity_stems(&self) -> Vec<&str>
Get negated entity stems (for exclusion)
Sourcepub fn to_ic_weights(&self) -> HashMap<String, f32>
pub fn to_ic_weights(&self) -> HashMap<String, f32>
Convert analysis to IC weights HashMap for BM25 term boosting
Returns a mapping of lowercase terms to their IC weights:
- Nouns (focal entities): IC_NOUN = 1.5
- Adjectives (modifiers): IC_ADJECTIVE = 0.9
- Verbs (relations): IC_VERB = 0.7
Based on Lioma & Ounis (2006) - nouns carry more information content.
Sourcepub fn to_ic_weights_with_yake(&self, use_yake: bool) -> HashMap<String, f32>
pub fn to_ic_weights_with_yake(&self, use_yake: bool) -> HashMap<String, f32>
Convert analysis to IC weights with optional YAKE boosting
When use_yake=true, extracts discriminative keywords using YAKE algorithm and boosts their weights. This is critical for multi-hop queries where discriminative terms like “sunrise” must outweigh common terms like “Melanie”.
Sourcepub fn keyword_discriminativeness(&self) -> (f32, Vec<String>)
pub fn keyword_discriminativeness(&self) -> (f32, Vec<String>)
Get maximum YAKE keyword discriminativeness score for dynamic weight adjustment
Returns (max_importance, discriminative_keywords) where:
- max_importance: 0.0-1.0, higher means more discriminative keywords found
- discriminative_keywords: keywords with importance > 0.5 (for logging)
Use this to dynamically adjust BM25/vector weights in hybrid search:
- High discriminativeness (>0.6) → boost BM25 weight (keyword matching critical)
- Low discriminativeness (<0.3) → trust vector more (semantic similarity better)
Sourcepub fn to_phrase_boosts(&self) -> Vec<(String, f32)>
pub fn to_phrase_boosts(&self) -> Vec<(String, f32)>
Get phrase boosts for BM25 exact phrase matching
Returns compound nouns and adjacent noun pairs as phrases with boost weights. Phrase matching significantly improves retrieval for multi-word concepts like “support group”, “machine learning”, “LGBTQ community”.
Trait Implementations§
Source§impl Clone for QueryAnalysis
impl Clone for QueryAnalysis
Source§fn clone(&self) -> QueryAnalysis
fn clone(&self) -> QueryAnalysis
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for QueryAnalysis
impl RefUnwindSafe for QueryAnalysis
impl Send for QueryAnalysis
impl Sync for QueryAnalysis
impl Unpin for QueryAnalysis
impl UnsafeUnpin for QueryAnalysis
impl UnwindSafe for QueryAnalysis
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 more