pub struct ReferenceCandidate {
pub entity_id: u64,
pub description: String,
pub weight: f64,
pub source: CandidateSource,
pub satisfied_constraints: Vec<String>,
pub violated_constraints: Vec<String>,
}Expand description
A candidate referent for uncertain reference resolution.
Each candidate represents a possible antecedent with an associated weight (in log-odds space for numerical stability) and metadata about how it was identified and which constraints it satisfies or violates.
§Example
use anno::discourse::uncertain_reference::{ReferenceCandidate, CandidateSource};
let candidate = ReferenceCandidate::new(1, "John Smith", 0.8)
.with_source(CandidateSource::Discourse)
.satisfies("gender:masculine")
.satisfies("number:singular");
// Check for hard constraint violations
let bad_candidate = ReferenceCandidate::new(2, "they", 0.6)
.violates("number:singular"); // "they" violates singular constraint
assert!(!candidate.has_violations());
assert!(bad_candidate.has_violations());Fields§
§entity_id: u64Entity/cluster ID (links to coreference cluster).
description: StringSurface form or description (e.g., “John”, “the CEO”).
weight: f64Weight in log-odds space. Higher = more likely. Use update_evidence
to adjust, and probabilities to
convert to probabilities via softmax.
source: CandidateSourceHow this candidate was identified (discourse, bridging, world knowledge).
satisfied_constraints: Vec<String>Constraints this candidate satisfies (e.g., “gender:masculine”).
violated_constraints: Vec<String>Constraints this candidate violates. Hard constraint violations can be
pruned via UncertainReference::prune_violations.
Implementations§
Source§impl ReferenceCandidate
impl ReferenceCandidate
Sourcepub fn new(
entity_id: u64,
description: impl Into<String>,
weight: f64,
) -> ReferenceCandidate
pub fn new( entity_id: u64, description: impl Into<String>, weight: f64, ) -> ReferenceCandidate
Create a new candidate.
Sourcepub fn with_source(self, source: CandidateSource) -> ReferenceCandidate
pub fn with_source(self, source: CandidateSource) -> ReferenceCandidate
Set the source of this candidate.
Sourcepub fn satisfies(self, constraint: impl Into<String>) -> ReferenceCandidate
pub fn satisfies(self, constraint: impl Into<String>) -> ReferenceCandidate
Add a satisfied constraint.
Sourcepub fn violates(self, constraint: impl Into<String>) -> ReferenceCandidate
pub fn violates(self, constraint: impl Into<String>) -> ReferenceCandidate
Add a violated constraint.
Sourcepub fn has_violations(&self) -> bool
pub fn has_violations(&self) -> bool
Check if this candidate has violations.
Trait Implementations§
Source§impl Clone for ReferenceCandidate
impl Clone for ReferenceCandidate
Source§fn clone(&self) -> ReferenceCandidate
fn clone(&self) -> ReferenceCandidate
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 ReferenceCandidate
impl Debug for ReferenceCandidate
Source§impl<'de> Deserialize<'de> for ReferenceCandidate
impl<'de> Deserialize<'de> for ReferenceCandidate
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ReferenceCandidate, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ReferenceCandidate, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ReferenceCandidate
impl PartialEq for ReferenceCandidate
Source§fn eq(&self, other: &ReferenceCandidate) -> bool
fn eq(&self, other: &ReferenceCandidate) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ReferenceCandidate
impl Serialize for ReferenceCandidate
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,
impl StructuralPartialEq for ReferenceCandidate
Auto Trait Implementations§
impl Freeze for ReferenceCandidate
impl RefUnwindSafe for ReferenceCandidate
impl Send for ReferenceCandidate
impl Sync for ReferenceCandidate
impl Unpin for ReferenceCandidate
impl UnsafeUnpin for ReferenceCandidate
impl UnwindSafe for ReferenceCandidate
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