pub struct Reference {
pub text: String,
pub start: usize,
pub end: usize,
pub reference_type: ReferenceType,
pub url: Option<String>,
pub entity_id: Option<String>,
pub title: Option<String>,
pub antecedent: Option<String>,
pub is_resolved: bool,
}Expand description
A detected reference in text.
Fields§
§text: StringThe reference text as it appears in the document
start: usizeStart offset in the document
end: usizeEnd offset in the document
reference_type: ReferenceTypeType of reference
url: Option<String>Resolved URL (if applicable)
entity_id: Option<String>Entity ID if this is a KB link (e.g., Wikidata Q-number)
title: Option<String>Title/name of the referenced resource (if known)
antecedent: Option<String>The antecedent text this reference relates to (if any)
is_resolved: boolWhether this reference has been resolved
Implementations§
Source§impl Reference
impl Reference
Sourcepub fn new(
text: &str,
start: usize,
end: usize,
ref_type: ReferenceType,
) -> Self
pub fn new( text: &str, start: usize, end: usize, ref_type: ReferenceType, ) -> Self
Create a new reference.
Sourcepub fn with_entity_id(self, id: &str) -> Self
pub fn with_entity_id(self, id: &str) -> Self
Set the entity ID.
Sourcepub fn with_antecedent(self, antecedent: &str) -> Self
pub fn with_antecedent(self, antecedent: &str) -> Self
Set the antecedent.
Sourcepub fn mark_resolved(self) -> Self
pub fn mark_resolved(self) -> Self
Mark as resolved.
Sourcepub fn wikidata_qid(&self) -> Option<&str>
pub fn wikidata_qid(&self) -> Option<&str>
Get the Wikidata Q-number if this is a Wikidata reference.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Reference
impl<'de> Deserialize<'de> for Reference
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 Reference
impl RefUnwindSafe for Reference
impl Send for Reference
impl Sync for Reference
impl Unpin for Reference
impl UnsafeUnpin for Reference
impl UnwindSafe for Reference
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