pub struct AbstractTemporalExpression {
pub text: String,
pub expression_type: TemporalExpressionType,
pub granularity: TemporalGranularity,
pub grounded_range: Option<(DateTime<Utc>, DateTime<Utc>)>,
pub grounding_confidence: f64,
pub requires_context: bool,
}Expand description
An abstract temporal expression with full metadata.
This is the temporal analog to abstract entities in a hierarchical clustering layer - it captures not just when something happened, but how precisely we know when, and what kind of temporal reference it is.
Fields§
§text: StringOriginal text of the temporal expression
expression_type: TemporalExpressionTypeType of temporal expression
granularity: TemporalGranularityGranularity level
grounded_range: Option<(DateTime<Utc>, DateTime<Utc>)>Grounded time range (if resolvable) For “January 2024”, this would be (2024-01-01, 2024-01-31)
grounding_confidence: f64Confidence in the grounding (0.0 to 1.0)
requires_context: boolWhether this requires external context to resolve
Implementations§
Source§impl AbstractTemporalExpression
impl AbstractTemporalExpression
Sourcepub fn absolute(
text: impl Into<String>,
granularity: TemporalGranularity,
) -> AbstractTemporalExpression
pub fn absolute( text: impl Into<String>, granularity: TemporalGranularity, ) -> AbstractTemporalExpression
Create a new absolute temporal expression.
Sourcepub fn relative(
text: impl Into<String>,
offset_days: i32,
) -> AbstractTemporalExpression
pub fn relative( text: impl Into<String>, offset_days: i32, ) -> AbstractTemporalExpression
Create a relative temporal expression.
Sourcepub fn fuzzy(
text: impl Into<String>,
direction: FuzzyDirection,
) -> AbstractTemporalExpression
pub fn fuzzy( text: impl Into<String>, direction: FuzzyDirection, ) -> AbstractTemporalExpression
Create a fuzzy temporal expression.
Sourcepub fn ground(
&self,
document_date: &DateTime<Utc>,
) -> Option<AbstractTemporalExpression>
pub fn ground( &self, document_date: &DateTime<Utc>, ) -> Option<AbstractTemporalExpression>
Ground this expression relative to a document date.
For relative expressions like “yesterday”, this resolves to an absolute time.
Sourcepub fn overlaps(&self, other: &AbstractTemporalExpression) -> bool
pub fn overlaps(&self, other: &AbstractTemporalExpression) -> bool
Check if this expression overlaps with another.
Trait Implementations§
Source§impl Clone for AbstractTemporalExpression
impl Clone for AbstractTemporalExpression
Source§fn clone(&self) -> AbstractTemporalExpression
fn clone(&self) -> AbstractTemporalExpression
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AbstractTemporalExpression
impl Debug for AbstractTemporalExpression
Source§impl<'de> Deserialize<'de> for AbstractTemporalExpression
impl<'de> Deserialize<'de> for AbstractTemporalExpression
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AbstractTemporalExpression, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AbstractTemporalExpression, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for AbstractTemporalExpression
impl Serialize for AbstractTemporalExpression
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 AbstractTemporalExpression
impl RefUnwindSafe for AbstractTemporalExpression
impl Send for AbstractTemporalExpression
impl Sync for AbstractTemporalExpression
impl Unpin for AbstractTemporalExpression
impl UnsafeUnpin for AbstractTemporalExpression
impl UnwindSafe for AbstractTemporalExpression
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