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
Trait Implementations§
Source§impl Clone for EntityResolver
impl Clone for EntityResolver
Source§fn clone(&self) -> EntityResolver
fn clone(&self) -> EntityResolver
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EntityResolver
impl Debug for EntityResolver
Auto Trait Implementations§
impl Freeze for EntityResolver
impl RefUnwindSafe for EntityResolver
impl Send for EntityResolver
impl Sync for EntityResolver
impl Unpin for EntityResolver
impl UnsafeUnpin for EntityResolver
impl UnwindSafe for EntityResolver
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