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>) -> Self
pub fn new(text: impl Into<String>, chains: Vec<CorefChain>) -> Self
Create a new document with chains.
Sourcepub fn with_id(
text: impl Into<String>,
doc_id: impl Into<String>,
chains: Vec<CorefChain>,
) -> Self
pub fn with_id( text: impl Into<String>, doc_id: impl Into<String>, chains: Vec<CorefChain>, ) -> Self
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) -> Self
pub fn without_singletons(&self) -> Self
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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