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: SemanticWeightsImplementations§
Source§impl SemanticEngine
impl SemanticEngine
Sourcepub fn build(graph: &Graph, weights: SemanticWeights) -> M1ndResult<Self>
pub fn build(graph: &Graph, weights: SemanticWeights) -> M1ndResult<Self>
Build all three indexes from the graph. Replaces: semantic_v2.py SemanticEngine.init()
Sourcepub fn query(
&self,
graph: &Graph,
query: &str,
top_k: usize,
) -> M1ndResult<Vec<(NodeId, FiniteF32)>>
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()
Sourcepub fn query_fast(
&self,
graph: &Graph,
query: &str,
top_k: usize,
) -> M1ndResult<Vec<(NodeId, FiniteF32)>>
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§
impl Freeze for SemanticEngine
impl RefUnwindSafe for SemanticEngine
impl Send for SemanticEngine
impl Sync for SemanticEngine
impl Unpin for SemanticEngine
impl UnsafeUnpin for SemanticEngine
impl UnwindSafe for SemanticEngine
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
Mutably borrows from an owned value. Read more