pub struct CorefChainStats {
pub long_chain_count: usize,
pub short_chain_count: usize,
pub singleton_count: usize,
pub long_chain_f1: f64,
pub short_chain_f1: f64,
pub singleton_f1: f64,
}Expand description
Statistics for stratified coreference evaluation.
§Why Chain Length Matters: A Narrative
Imagine analyzing “Pride and Prejudice”:
┌─────────────────────────────────────────────────────────────────────────┐
│ COREFERENCE IN A NOVEL │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ LONG CHAINS (>10 mentions) - THE PROTAGONISTS │
│ ───────────────────────────────────────────── │
│ │
│ "Elizabeth" ─── "she" ─── "Lizzy" ─── "her" ─── "Miss Bennet" ───... │
│ │ │ │ │ │ │
│ └────────────┴──────────┴──────────┴────────────┘ │
│ 800+ mentions │
│ │
│ Getting these right = understanding the PLOT. │
│ Who did what to whom? What's Elizabeth's arc? │
│ │
│ SHORT CHAINS (2-10 mentions) - SECONDARY CHARACTERS │
│ ─────────────────────────────────────────────────── │
│ │
│ "Mr. Collins" ─── "he" ─── "the clergyman" │
│ │ │ │ │
│ └──────────────┴─────────────┘ │
│ 15 mentions │
│ │
│ Important for context, but errors here are less catastrophic. │
│ │
│ SINGLETONS (1 mention) - BACKGROUND │
│ ─────────────────────────────────────── │
│ │
│ "a tall man" ─── (no other mentions) │
│ "the servant" ─── (no other mentions) │
│ │
│ These are closer to entity detection than coreference. │
│ Including them in CoNLL F1 can change the interpretation of the score. │
└─────────────────────────────────────────────────────────────────────────┘§The Problem with Averaged Metrics
Model Performance:
A single averaged metric can hide systematic differences across chain sizes.
Prefer reporting stratified metrics by chain length (and be explicit about
whether singletons are included).§Research Context (arXiv:2401.00238)
“How to Evaluate Coreference in Literary Texts?”
- A single CoNLL F1 score is “uninformative, or even misleading.”
- Stratify by chain length for interpretable results.
§Example
use anno_eval::eval::CorefChainStats;
let stats = CorefChainStats {
long_chain_count: 3, // Main characters
short_chain_count: 15, // Secondary
singleton_count: 42, // Isolated
long_chain_f1: 0.92, // Good on main characters
short_chain_f1: 0.71, // Weaker on secondary
singleton_f1: 0.45, // Poor on singletons
};
// Report metrics separately, not averaged
println!("Main characters: {:.1}% F1", stats.long_chain_f1 * 100.0);Chain-length stratified statistics for coreference evaluation.
Fields§
§long_chain_count: usizeNumber of long chains (>10 mentions).
short_chain_count: usizeNumber of short chains (2-10 mentions).
singleton_count: usizeNumber of singletons (1 mention).
long_chain_f1: f64F1 score on long chains only.
short_chain_f1: f64F1 score on short chains only.
singleton_f1: f64F1 score on singletons (if evaluated).
Implementations§
Source§impl CorefChainStats
impl CorefChainStats
Sourcepub fn total_chains(&self) -> usize
pub fn total_chains(&self) -> usize
Total chain count.
Sourcepub fn weighted_f1(&self) -> f64
pub fn weighted_f1(&self) -> f64
Weighted F1 (by chain count).
Note: this is not CoNLL F1; it is a diagnostic aggregation over chain strata.
Trait Implementations§
Source§impl Clone for CorefChainStats
impl Clone for CorefChainStats
Source§fn clone(&self) -> CorefChainStats
fn clone(&self) -> CorefChainStats
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for CorefChainStats
Source§impl Debug for CorefChainStats
impl Debug for CorefChainStats
Source§impl Default for CorefChainStats
impl Default for CorefChainStats
Source§fn default() -> CorefChainStats
fn default() -> CorefChainStats
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CorefChainStats
impl<'de> Deserialize<'de> for CorefChainStats
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CorefChainStats, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CorefChainStats, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for CorefChainStats
impl Serialize for CorefChainStats
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for CorefChainStats
impl RefUnwindSafe for CorefChainStats
impl Send for CorefChainStats
impl Sync for CorefChainStats
impl Unpin for CorefChainStats
impl UnsafeUnpin for CorefChainStats
impl UnwindSafe for CorefChainStats
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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