pub trait CoreferenceResolver: Send + Sync {
// Required methods
fn resolve(&self, entities: &[Entity]) -> Vec<Entity>;
fn name(&self) -> &'static str;
// Provided method
fn resolve_to_chains(&self, entities: &[Entity]) -> Vec<CorefChain> { ... }
}Expand description
Trait for coreference resolution algorithms.
Implementors take a set of entity mentions and cluster them into coreference chains (groups of mentions referring to the same entity).
§Design Philosophy
This trait lives in anno::core because:
- It depends only on core types (
Entity,CorefChain) - Multiple crates need to implement it (backends, eval)
- Keeping it here prevents circular dependencies
§Relationship to the Grounded Pipeline
CoreferenceResolver operates on the evaluation/convenience layer (Entity),
not the canonical grounded pipeline (Signal → Track → Identity).
| Layer | Type | CoreferenceResolver role |
|---|---|---|
| Detection (L1) | Entity | Input: mentions to cluster |
| Coref (L2) | Entity.canonical_id | Output: cluster assignment |
| Linking (L3) | Identity | (not covered by this trait) |
For integration with GroundedDocument, use backends that produce
Signal + Track directly (e.g., anno::backends::MentionRankingCoref).
§Example Implementation
use anno_core::{CoreferenceResolver, Entity, CorefChain};
struct ExactMatchResolver;
impl CoreferenceResolver for ExactMatchResolver {
fn resolve(&self, entities: &[Entity]) -> Vec<Entity> {
// Cluster entities with identical text
// ... implementation ...
}
fn name(&self) -> &'static str {
"exact-match"
}
}Required Methods§
Sourcefn resolve(&self, entities: &[Entity]) -> Vec<Entity>
fn resolve(&self, entities: &[Entity]) -> Vec<Entity>
Resolve coreference, assigning canonical IDs to entities.
Each entity in the output will have a canonical_id field set.
Entities with the same canonical_id are coreferent (refer to the
same real-world entity).
§Invariants
- Every output entity has
canonical_id.is_some() - Coreferent entities share the same
canonical_id - Singleton mentions get unique
canonical_idvalues
Provided Methods§
Sourcefn resolve_to_chains(&self, entities: &[Entity]) -> Vec<CorefChain>
fn resolve_to_chains(&self, entities: &[Entity]) -> Vec<CorefChain>
Resolve directly to chains.
A chain groups all mentions of the same entity together. This is often the desired output format for evaluation and downstream tasks.