Skip to main content

SemanticEngine

Struct SemanticEngine 

Source
pub struct SemanticEngine {
    pub ngram: CharNgramIndex,
    pub cooccurrence: CoOccurrenceIndex,
    pub synonym: SynonymExpander,
    pub weights: SemanticWeights,
}
Expand description

Combined semantic matching: 0.4ngram + 0.4cooccurrence + 0.2synonym. Two-phase query_fast: phase 1 ngram+synonym (0.6/0.4), phase 2 re-rank top 3K with cooccurrence. Replaces: semantic_v2.py SemanticEngine

Fields§

§ngram: CharNgramIndex§cooccurrence: CoOccurrenceIndex§synonym: SynonymExpander§weights: SemanticWeights

Implementations§

Source§

impl SemanticEngine

Source

pub fn build(graph: &Graph, weights: SemanticWeights) -> M1ndResult<Self>

Build all three indexes from the graph. Replaces: semantic_v2.py SemanticEngine.init()

Source

pub fn query( &self, graph: &Graph, query: &str, top_k: usize, ) -> M1ndResult<Vec<(NodeId, FiniteF32)>>

Full query: score all nodes, return top_k. Weight: ngram0.4 + cooccurrence0.4 + synonym*0.2. Replaces: semantic_v2.py SemanticEngine.query()

Source

pub fn query_fast( &self, graph: &Graph, query: &str, top_k: usize, ) -> M1ndResult<Vec<(NodeId, FiniteF32)>>

Fast two-phase query. Phase 1: ngram+synonym (0.6/0.4) -> candidates (3*top_k). Phase 2: re-rank candidates with cooccurrence. Replaces: semantic_v2.py SemanticEngine.query_fast()

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.