pub struct DiscourseReferent {
pub referent_type: ReferentType,
pub start: usize,
pub end: usize,
pub label: Option<String>,
pub text: Option<String>,
pub event: Option<EventMention>,
pub canonical_id: Option<CanonicalId>,
pub confidence: Confidence,
pub depth: u32,
}Expand description
A discourse referent - something that can be referred to by an anaphor.
This is the key data structure for abstract anaphora resolution.
Unlike Entity which captures noun phrases, DiscourseReferent can
represent entire clauses, events, propositions, etc.
§Example
use anno::discourse::{DiscourseReferent, ReferentType, EventMention};
// "Russia invaded Ukraine in 2022. This caused inflation."
let event = EventMention::new("invaded", 7, 14);
let referent = DiscourseReferent::new(ReferentType::Event, 0, 30)
.with_event(event)
.with_label("Russian invasion");
assert_eq!(referent.span(), (0, 30));
assert!(referent.is_abstract());Fields§
§referent_type: ReferentTypeWhat kind of referent this is
start: usizeStart character offset (of the full discourse segment)
end: usizeEnd character offset (of the full discourse segment)
label: Option<String>Human-readable label for this referent
text: Option<String>The full text of this referent (optional, for debugging)
event: Option<EventMention>If this is an event, the event mention details
canonical_id: Option<CanonicalId>Coreference cluster ID (shared with entities that refer to this)
confidence: ConfidenceConfidence that this is a valid discourse referent
depth: u32Discourse depth (how nested this referent is) 0 = main clause, 1 = subordinate, 2 = embedded subordinate, etc.
Implementations§
Source§impl DiscourseReferent
impl DiscourseReferent
Sourcepub fn new(
referent_type: ReferentType,
start: usize,
end: usize,
) -> DiscourseReferent
pub fn new( referent_type: ReferentType, start: usize, end: usize, ) -> DiscourseReferent
Create a new discourse referent.
Sourcepub fn from_entity(entity: &Entity) -> DiscourseReferent
pub fn from_entity(entity: &Entity) -> DiscourseReferent
Create a nominal referent from an Entity.
Sourcepub fn with_label(self, label: impl Into<String>) -> DiscourseReferent
pub fn with_label(self, label: impl Into<String>) -> DiscourseReferent
Set a human-readable label.
Sourcepub fn with_text(self, text: impl Into<String>) -> DiscourseReferent
pub fn with_text(self, text: impl Into<String>) -> DiscourseReferent
Set the text.
Sourcepub fn with_event(self, event: EventMention) -> DiscourseReferent
pub fn with_event(self, event: EventMention) -> DiscourseReferent
Attach an event mention.
Sourcepub fn with_canonical_id(self, id: impl Into<CanonicalId>) -> DiscourseReferent
pub fn with_canonical_id(self, id: impl Into<CanonicalId>) -> DiscourseReferent
Set the canonical ID.
Sourcepub fn with_confidence(self, confidence: f64) -> DiscourseReferent
pub fn with_confidence(self, confidence: f64) -> DiscourseReferent
Set confidence.
Sourcepub fn with_depth(self, depth: u32) -> DiscourseReferent
pub fn with_depth(self, depth: u32) -> DiscourseReferent
Set discourse depth.
Sourcepub const fn is_abstract(&self) -> bool
pub const fn is_abstract(&self) -> bool
Is this an abstract referent (not a nominal entity)?
Sourcepub fn display_text(&self) -> &str
pub fn display_text(&self) -> &str
Get the display text (label or text or type name).
Trait Implementations§
Source§impl Clone for DiscourseReferent
impl Clone for DiscourseReferent
Source§fn clone(&self) -> DiscourseReferent
fn clone(&self) -> DiscourseReferent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DiscourseReferent
impl Debug for DiscourseReferent
Source§impl<'de> Deserialize<'de> for DiscourseReferent
impl<'de> Deserialize<'de> for DiscourseReferent
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DiscourseReferent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DiscourseReferent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for DiscourseReferent
impl Serialize for DiscourseReferent
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,
Auto Trait Implementations§
impl Freeze for DiscourseReferent
impl RefUnwindSafe for DiscourseReferent
impl Send for DiscourseReferent
impl Sync for DiscourseReferent
impl Unpin for DiscourseReferent
impl UnsafeUnpin for DiscourseReferent
impl UnwindSafe for DiscourseReferent
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
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>
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>
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