pub struct TemporalValidity {
pub from: Option<HistoricalDate>,
pub until: Option<HistoricalDate>,
}Expand description
Temporal validity range for an entity.
Represents the time period during which an entity reference is valid. Essential for historical document disambiguation.
§Use Cases
- People: birth to death dates
- Organizations: founding to dissolution
- Positions: term start to term end
- Events: start to end time
§Examples
use anno_core::types::{HistoricalDate, TemporalValidity};
// Julius Caesar: 100 BCE - 44 BCE
let caesar = TemporalValidity {
from: Some(HistoricalDate::bce(100, 7, 12)),
until: Some(HistoricalDate::bce(44, 3, 15)),
};
// Check if entity was valid at a given date
let query = HistoricalDate::bce(50, 1, 1);
assert!(caesar.is_valid_at(&query));Fields§
§from: Option<HistoricalDate>Start of validity (None = unknown/always)
until: Option<HistoricalDate>End of validity (None = still valid/unknown)
Implementations§
Source§impl TemporalValidity
impl TemporalValidity
Sourcepub fn new(
from: Option<HistoricalDate>,
until: Option<HistoricalDate>,
) -> TemporalValidity
pub fn new( from: Option<HistoricalDate>, until: Option<HistoricalDate>, ) -> TemporalValidity
Create a validity range.
Sourcepub fn always() -> TemporalValidity
pub fn always() -> TemporalValidity
Create an always-valid range (no temporal constraints).
Sourcepub fn from_date(date: HistoricalDate) -> TemporalValidity
pub fn from_date(date: HistoricalDate) -> TemporalValidity
Create a range that started at a date and is still valid.
Sourcepub fn until_date(date: HistoricalDate) -> TemporalValidity
pub fn until_date(date: HistoricalDate) -> TemporalValidity
Create a range that ended at a date.
Sourcepub fn is_valid_at(&self, date: &HistoricalDate) -> bool
pub fn is_valid_at(&self, date: &HistoricalDate) -> bool
Check if the entity is valid at a given date.
Returns true if the date falls within the validity range. Unknown bounds (None) are treated as unbounded.
Sourcepub fn overlaps(&self, other: &TemporalValidity) -> bool
pub fn overlaps(&self, other: &TemporalValidity) -> bool
Check if this range overlaps with another.
Sourcepub fn is_current(&self) -> bool
pub fn is_current(&self) -> bool
Check if this entity is currently valid (no end date).
Sourcepub fn compatibility_score(&self, document_date: &HistoricalDate) -> f64
pub fn compatibility_score(&self, document_date: &HistoricalDate) -> f64
Compute temporal compatibility score for entity linking.
Returns a score in [0.0, 1.0] based on how well the document date matches the entity’s validity period.
- 1.0: Document date is within validity period
- 0.5-0.9: Document date is close to validity period
- 0.1-0.5: Document date is far from validity period
Trait Implementations§
Source§impl Clone for TemporalValidity
impl Clone for TemporalValidity
Source§fn clone(&self) -> TemporalValidity
fn clone(&self) -> TemporalValidity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TemporalValidity
impl Debug for TemporalValidity
Source§impl Default for TemporalValidity
impl Default for TemporalValidity
Source§fn default() -> TemporalValidity
fn default() -> TemporalValidity
Source§impl<'de> Deserialize<'de> for TemporalValidity
impl<'de> Deserialize<'de> for TemporalValidity
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TemporalValidity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TemporalValidity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for TemporalValidity
impl Display for TemporalValidity
Source§impl Hash for TemporalValidity
impl Hash for TemporalValidity
Source§impl PartialEq for TemporalValidity
impl PartialEq for TemporalValidity
Source§impl Serialize for TemporalValidity
impl Serialize for TemporalValidity
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 Eq for TemporalValidity
impl StructuralPartialEq for TemporalValidity
Auto Trait Implementations§
impl Freeze for TemporalValidity
impl RefUnwindSafe for TemporalValidity
impl Send for TemporalValidity
impl Sync for TemporalValidity
impl Unpin for TemporalValidity
impl UnsafeUnpin for TemporalValidity
impl UnwindSafe for TemporalValidity
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.