pub struct GraphCoref { /* private fields */ }Expand description
Graph-based coreference resolver.
Implementations§
Source§impl GraphCoref
impl GraphCoref
Sourcepub fn with_config(config: GraphCorefConfig) -> Self
pub fn with_config(config: GraphCorefConfig) -> Self
Create with custom configuration.
Sourcepub fn resolve(&self, mentions: &[Mention]) -> Vec<CorefChain>
pub fn resolve(&self, mentions: &[Mention]) -> Vec<CorefChain>
Resolve coreferences among mentions using iterative graph refinement.
§Arguments
mentions- Pre-detected mentions (from NER or mention detector). For best results, setmention_typeon each mention.
§Returns
Coreference chains (clusters) where each chain contains mentions
referring to the same entity. By default, singletons are filtered;
set config.include_singletons = true to include them.
§Panics
Does not panic. Empty input returns empty output.
§Example
use anno::backends::graph_coref::GraphCoref;
use anno::{Mention, MentionType};
let coref = GraphCoref::new();
let mut john = Mention::new("John", 0, 4);
john.mention_type = Some(MentionType::Proper);
let mut he = Mention::new("he", 20, 22);
he.mention_type = Some(MentionType::Pronominal);
let chains = coref.resolve(&[john, he]);Sourcepub fn config(&self) -> &GraphCorefConfig
pub fn config(&self) -> &GraphCorefConfig
Get configuration.
Source§impl GraphCoref
impl GraphCoref
Sourcepub fn resolve_with_stats(
&self,
mentions: &[Mention],
) -> (Vec<CorefChain>, GraphCorefStats)
pub fn resolve_with_stats( &self, mentions: &[Mention], ) -> (Vec<CorefChain>, GraphCorefStats)
Resolve coreferences and return detailed statistics.
Useful for debugging, tuning parameters, and understanding convergence.
§Example
use anno::backends::graph_coref::GraphCoref;
use anno::Mention;
let coref = GraphCoref::new();
let mentions = vec![
Mention::new("John", 0, 4),
Mention::new("John", 50, 54),
];
let (chains, stats) = coref.resolve_with_stats(&mentions);
println!("Converged in {} iterations", stats.iterations);
println!("Edge history: {:?}", stats.edge_history);Trait Implementations§
Auto Trait Implementations§
impl Freeze for GraphCoref
impl RefUnwindSafe for GraphCoref
impl Send for GraphCoref
impl Sync for GraphCoref
impl Unpin for GraphCoref
impl UnsafeUnpin for GraphCoref
impl UnwindSafe for GraphCoref
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more