Skip to main content

CoreferenceResolver

Trait CoreferenceResolver 

Source
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:

  1. It depends only on core types (Entity, CorefChain)
  2. Multiple crates need to implement it (backends, eval)
  3. Keeping it here prevents circular dependencies

§Relationship to the Grounded Pipeline

CoreferenceResolver operates on the evaluation/convenience layer (Entity), not the canonical grounded pipeline (SignalTrackIdentity).

LayerTypeCoreferenceResolver role
Detection (L1)EntityInput: mentions to cluster
Coref (L2)Entity.canonical_idOutput: 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§

Source

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_id values
Source

fn name(&self) -> &'static str

Get resolver name.

Used for logging, metrics, and result attribution.

Provided Methods§

Source

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.

Implementors§