pub struct TemporalScorer { /* private fields */ }Expand description
Temporal decay scorer
Implementations§
Source§impl TemporalScorer
impl TemporalScorer
Sourcepub fn new(config: TemporalDecayConfig) -> Self
pub fn new(config: TemporalDecayConfig) -> Self
Create a new temporal scorer with current time as reference
Sourcepub fn with_reference_time(
config: TemporalDecayConfig,
reference_time: f64,
) -> Self
pub fn with_reference_time( config: TemporalDecayConfig, reference_time: f64, ) -> Self
Create with specific reference time
Sourcepub fn default_scorer() -> Self
pub fn default_scorer() -> Self
Create with default config
Sourcepub fn decay_score(&self, timestamp_secs: f64) -> f32
pub fn decay_score(&self, timestamp_secs: f64) -> f32
Calculate decay score for a given timestamp
Returns a value between min_decay and 1.0
Sourcepub fn decay_score_duration(&self, age: Duration) -> f32
pub fn decay_score_duration(&self, age: Duration) -> f32
Calculate decay score from Duration
Sourcepub fn blend_scores(&self, semantic_score: f32, decay_score: f32) -> f32
pub fn blend_scores(&self, semantic_score: f32, decay_score: f32) -> f32
Blend semantic and decay scores
final = α × semantic + (1-α) × decay
Sourcepub fn final_score(&self, semantic_score: f32, timestamp_secs: f64) -> f32
pub fn final_score(&self, semantic_score: f32, timestamp_secs: f64) -> f32
Calculate final score from semantic score and timestamp
Sourcepub fn apply_decay<I>(&self, results: I) -> Vec<(String, f32)>
pub fn apply_decay<I>(&self, results: I) -> Vec<(String, f32)>
Apply temporal decay to a list of scored results
Each result is (id, semantic_score, timestamp) Returns (id, final_score) sorted by final_score descending
Sourcepub fn apply_decay_typed<T, F>(
&self,
results: &mut [T],
get_score: impl Fn(&T) -> f32,
get_timestamp: impl Fn(&T) -> f64,
set_score: F,
)
pub fn apply_decay_typed<T, F>( &self, results: &mut [T], get_score: impl Fn(&T) -> f32, get_timestamp: impl Fn(&T) -> f64, set_score: F, )
Apply decay to typed results
Sourcepub fn half_life_display(&self) -> String
pub fn half_life_display(&self) -> String
Get the half-life in human-readable format
Trait Implementations§
Source§impl Clone for TemporalScorer
impl Clone for TemporalScorer
Source§fn clone(&self) -> TemporalScorer
fn clone(&self) -> TemporalScorer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TemporalScorer
impl RefUnwindSafe for TemporalScorer
impl Send for TemporalScorer
impl Sync for TemporalScorer
impl Unpin for TemporalScorer
impl UnsafeUnpin for TemporalScorer
impl UnwindSafe for TemporalScorer
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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