pub struct TemporalBox {
pub base: BoxEmbedding,
pub velocity: BoxVelocity,
pub time_range: (f64, f64),
}Expand description
A temporal box embedding that evolves over time.
Based on BoxTE (Messner et al., 2022), this models entities that change over time. For example, “The President” refers to Obama in 2012 but Trump in 2017 - they should not corefer despite the same surface form.
§Example
ⓘ
use anno::backends::box_embeddings::{BoxEmbedding, TemporalBox, BoxVelocity};
// "The President" in 2012 (Obama)
let base = BoxEmbedding::new(vec![0.0, 0.0], vec![1.0, 1.0]);
let velocity = BoxVelocity::new(vec![0.0, 0.0], vec![0.0, 0.0]); // Static
let obama_presidency = TemporalBox::new(base, velocity, (2012.0, 2016.0));
// "The President" in 2017 (Trump)
let trump_base = BoxEmbedding::new(vec![5.0, 5.0], vec![6.0, 6.0]);
let trump_presidency = TemporalBox::new(trump_base, velocity, (2017.0, 2021.0));
// Should not corefer (different time ranges)
assert_eq!(obama_presidency.coreference_at_time(&trump_presidency, 2015.0), 0.0);Fields§
§base: BoxEmbeddingBase box at time t=0 (or reference time)
velocity: BoxVelocityVelocity: how box moves/resizes per time unit
time_range: (f64, f64)Time range where this box is valid [start, end)
Implementations§
Source§impl TemporalBox
impl TemporalBox
Sourcepub fn new(
base: BoxEmbedding,
velocity: BoxVelocity,
time_range: (f64, f64),
) -> TemporalBox
pub fn new( base: BoxEmbedding, velocity: BoxVelocity, time_range: (f64, f64), ) -> TemporalBox
Create a new temporal box.
§Arguments
base- Base box at reference timevelocity- How box evolves per time unittime_range- (start, end) time range where box is valid
Sourcepub fn at_time(&self, time: f64) -> Option<BoxEmbedding>
pub fn at_time(&self, time: f64) -> Option<BoxEmbedding>
Get the box at a specific time.
Returns None if time is outside the valid range.
Sourcepub fn coreference_at_time(&self, other: &TemporalBox, time: f64) -> f32
pub fn coreference_at_time(&self, other: &TemporalBox, time: f64) -> f32
Compute coreference score at a specific time.
Returns 0.0 if either box is invalid at the given time.
Sourcepub fn is_valid_at(&self, time: f64) -> bool
pub fn is_valid_at(&self, time: f64) -> bool
Check if this temporal box is valid at the given time.
Trait Implementations§
Source§impl Clone for TemporalBox
impl Clone for TemporalBox
Source§fn clone(&self) -> TemporalBox
fn clone(&self) -> TemporalBox
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TemporalBox
impl Debug for TemporalBox
Source§impl PartialEq for TemporalBox
impl PartialEq for TemporalBox
impl StructuralPartialEq for TemporalBox
Auto Trait Implementations§
impl Freeze for TemporalBox
impl RefUnwindSafe for TemporalBox
impl Send for TemporalBox
impl Sync for TemporalBox
impl Unpin for TemporalBox
impl UnsafeUnpin for TemporalBox
impl UnwindSafe for TemporalBox
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