pub struct CorefDocument {
pub text: String,
pub doc_id: Option<String>,
pub chains: Vec<CorefChain>,
pub includes_singletons: bool,
}Expand description
A document with coreference annotations.
Contains the source text and all coreference chains.
Fields§
§text: StringDocument text.
doc_id: Option<String>Document identifier.
chains: Vec<CorefChain>Coreference chains (clusters).
includes_singletons: boolWhether singletons are included.
Implementations§
Source§impl CorefDocument
impl CorefDocument
Sourcepub fn new(text: impl Into<String>, chains: Vec<CorefChain>) -> CorefDocument
pub fn new(text: impl Into<String>, chains: Vec<CorefChain>) -> CorefDocument
Create a new document with chains.
use anno_core::core::coref::{CorefDocument, CorefChain, Mention};
let chain = CorefChain::new(vec![
Mention::new("John", 0, 4),
Mention::new("He", 24, 26),
]);
let doc = CorefDocument::new("John went to the store. He bought milk.", vec![chain]);
assert_eq!(doc.mention_count(), 2);
assert_eq!(doc.chain_count(), 1);Sourcepub fn with_id(
text: impl Into<String>,
doc_id: impl Into<String>,
chains: Vec<CorefChain>,
) -> CorefDocument
pub fn with_id( text: impl Into<String>, doc_id: impl Into<String>, chains: Vec<CorefChain>, ) -> CorefDocument
Create document with ID.
Sourcepub fn mention_count(&self) -> usize
pub fn mention_count(&self) -> usize
Total number of mentions across all chains.
Sourcepub fn chain_count(&self) -> usize
pub fn chain_count(&self) -> usize
Number of chains (clusters).
Sourcepub fn non_singleton_count(&self) -> usize
pub fn non_singleton_count(&self) -> usize
Number of non-singleton chains.
Sourcepub fn all_mentions(&self) -> Vec<&Mention>
pub fn all_mentions(&self) -> Vec<&Mention>
Get all mentions in document order.
Sourcepub fn find_chain(&self, start: usize, end: usize) -> Option<&CorefChain>
pub fn find_chain(&self, start: usize, end: usize) -> Option<&CorefChain>
Find which chain contains a mention span.
Sourcepub fn mention_to_chain_index(&self) -> HashMap<(usize, usize), usize>
pub fn mention_to_chain_index(&self) -> HashMap<(usize, usize), usize>
Build mention-to-chain index for fast lookup.
Sourcepub fn without_singletons(&self) -> CorefDocument
pub fn without_singletons(&self) -> CorefDocument
Filter to only non-singleton chains.
Trait Implementations§
Source§impl Clone for CorefDocument
impl Clone for CorefDocument
Source§fn clone(&self) -> CorefDocument
fn clone(&self) -> CorefDocument
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 CorefDocument
impl Debug for CorefDocument
Source§impl<'de> Deserialize<'de> for CorefDocument
impl<'de> Deserialize<'de> for CorefDocument
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CorefDocument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CorefDocument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for CorefDocument
impl Serialize for CorefDocument
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 CorefDocument
impl RefUnwindSafe for CorefDocument
impl Send for CorefDocument
impl Sync for CorefDocument
impl Unpin for CorefDocument
impl UnsafeUnpin for CorefDocument
impl UnwindSafe for CorefDocument
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,
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