pub struct EntityResolver { /* private fields */ }Expand description
Resolves entity references to canonical names using a three-tier strategy:
- Learned cache — instant lookup from alias table (no LLM call)
- Rule-based — case normalization, substring matching
- LLM-powered — CognitiveLlmService.resolve_entities() for ambiguous cases
The alias table persists across sessions so the LLM is only consulted for genuinely new entity references.
Implementations§
Source§impl EntityResolver
impl EntityResolver
pub fn new() -> Self
Sourcepub fn resolve(&self, name: &str) -> ResolvedEntity
pub fn resolve(&self, name: &str) -> ResolvedEntity
Resolve an entity reference using the learned cache and rule-based matching.
Does not call the LLM — use resolve_with_llm for the full pipeline.
Sourcepub async fn resolve_batch_with_llm<J: LlmJudge>(
&mut self,
names: &[String],
contexts: &[Option<String>],
llm: &CognitiveLlmService<J>,
) -> Vec<ResolvedEntity>
pub async fn resolve_batch_with_llm<J: LlmJudge>( &mut self, names: &[String], contexts: &[Option<String>], llm: &CognitiveLlmService<J>, ) -> Vec<ResolvedEntity>
Full three-tier resolution: cache → rules → LLM.
Resolves a batch of entity references. Any LLM-confirmed merges are automatically added to the alias table for future cache hits.
Sourcepub fn learn_group(&mut self, group: &EntityMergeGroup)
pub fn learn_group(&mut self, group: &EntityMergeGroup)
Learn a merge group from the LLM, adding all aliases to the cache.
Sourcepub fn add_alias(&mut self, alias: &str, canonical: &str, confidence: f32)
pub fn add_alias(&mut self, alias: &str, canonical: &str, confidence: f32)
Manually register an alias mapping.
Sourcepub fn get_canonical(&self, name: &str) -> Option<&String>
pub fn get_canonical(&self, name: &str) -> Option<&String>
Get the canonical name for an alias, if known.
Sourcepub fn known_entities(&self) -> Vec<String>
pub fn known_entities(&self) -> Vec<String>
Returns all known canonical entity names.
pub fn alias_count(&self) -> usize
Sourcepub fn is_known_different(&self, a: &str, b: &str) -> bool
pub fn is_known_different(&self, a: &str, b: &str) -> bool
Check if two entity names are known to be different (negative cache).
Sourcepub fn mark_different(&mut self, a: &str, b: &str)
pub fn mark_different(&mut self, a: &str, b: &str)
Mark two entity names as confirmed different (negative cache).
Sourcepub fn unresolved_names(&self, names: &[String]) -> Vec<String>
pub fn unresolved_names(&self, names: &[String]) -> Vec<String>
Returns the set of entity names that are NOT yet resolved (no cache hit, no rule-based match). These need LLM resolution.
Sourcepub fn negative_count(&self) -> usize
pub fn negative_count(&self) -> usize
Number of negative-cached pairs.
Trait Implementations§
Source§impl Clone for EntityResolver
impl Clone for EntityResolver
Source§fn clone(&self) -> EntityResolver
fn clone(&self) -> EntityResolver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more