pub struct Candidate {Show 13 fields
pub kb_id: String,
pub source: CandidateSource,
pub label: String,
pub aliases: Vec<String>,
pub description: Option<String>,
pub kb_type: Option<String>,
pub sitelinks: Option<u32>,
pub prior: f64,
pub string_sim: f64,
pub type_score: f64,
pub score: f64,
pub valid_from: Option<String>,
pub valid_until: Option<String>,
}Expand description
A candidate KB entry for a mention.
Fields§
§kb_id: StringKB identifier (e.g., “Q937” for Wikidata)
source: CandidateSourceSource knowledge base
label: StringCanonical name/label
aliases: Vec<String>Aliases/alternate names
description: Option<String>Description/gloss
kb_type: Option<String>Entity type from KB (e.g., “human”, “organization”)
sitelinks: Option<u32>Wikipedia sitelink count (popularity proxy)
prior: f64Prior probability (if known)
string_sim: f64String similarity to mention
type_score: f64Type compatibility score
score: f64Overall candidate score (for ranking)
valid_from: Option<String>Temporal validity start (ISO 8601 date string).
For people: birth date. For organizations: founding date. Critical for historical document disambiguation where “President Bush” could refer to different people depending on the document date (Arora et al. 2024).
valid_until: Option<String>Temporal validity end (ISO 8601 date string).
For people: death date. For organizations: dissolution date.
Implementations§
Source§impl Candidate
impl Candidate
Sourcepub fn new(kb_id: &str, source: CandidateSource, label: &str) -> Self
pub fn new(kb_id: &str, source: CandidateSource, label: &str) -> Self
Create a new candidate.
Sourcepub fn with_valid_from(self, date: &str) -> Self
pub fn with_valid_from(self, date: &str) -> Self
Set temporal validity start.
Sourcepub fn with_valid_until(self, date: &str) -> Self
pub fn with_valid_until(self, date: &str) -> Self
Set temporal validity end.
Sourcepub fn with_alias(self, alias: &str) -> Self
pub fn with_alias(self, alias: &str) -> Self
Add an alias.
Sourcepub fn with_description(self, desc: &str) -> Self
pub fn with_description(self, desc: &str) -> Self
Set description.
Sourcepub fn with_kb_type(self, kb_type: &str) -> Self
pub fn with_kb_type(self, kb_type: &str) -> Self
Set KB type.
Sourcepub fn with_prior(self, prior: f64) -> Self
pub fn with_prior(self, prior: f64) -> Self
Set prior.
Sourcepub fn compute_score(&mut self)
pub fn compute_score(&mut self)
Compute overall score.
Sourcepub fn compute_score_with_temporal(&mut self, document_date: Option<&str>)
pub fn compute_score_with_temporal(&mut self, document_date: Option<&str>)
Compute score with temporal context.
For historical documents, temporal compatibility is critical for disambiguation. “President Bush” in 1990 refers to George H.W. Bush, while in 2005 it refers to George W. Bush.
§Arguments
document_date- ISO 8601 date string (e.g., “1990-01-15”)
Sourcepub fn temporal_compatibility(&self, document_date: &str) -> f64
pub fn temporal_compatibility(&self, document_date: &str) -> f64
Check temporal compatibility with a document date.
Returns 1.0 if the candidate is valid at the document date, 0.0 if clearly invalid, and intermediate values for uncertainty.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Candidate
impl<'de> Deserialize<'de> for Candidate
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>,
Source§impl From<&Candidate> for CandidateSummary
impl From<&Candidate> for CandidateSummary
Auto Trait Implementations§
impl Freeze for Candidate
impl RefUnwindSafe for Candidate
impl Send for Candidate
impl Sync for Candidate
impl Unpin for Candidate
impl UnsafeUnpin for Candidate
impl UnwindSafe for Candidate
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,
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