calculateRecency($documentDate); return (self::WEIGHT_SIMILARITY * $vectorScore) + (self::WEIGHT_RECENCY * $recencyScore) + (self::WEIGHT_AUTHORITY * $authorityScore); } /** * Calculate recency score based on document age. * * Returns 1.0 for today, linearly decreasing to 0.0 at 365 days old. * * @param DateTimeInterface $date The document date * * @return float Recency score (0.0-1.0) */ private function calculateRecency(DateTimeInterface $date): float { $now = new \DateTime(); $interval = $now->diff($date); $daysOld = $interval->days; // Documents older than 1 year get minimum recency score return max(0.0, 1.0 - ($daysOld / 365)); } /** * Get the weight configuration for transparency. * * @return array{similarity: float, recency: float, authority: float} */ public function getWeights(): array { return [ 'similarity' => self::WEIGHT_SIMILARITY, 'recency' => self::WEIGHT_RECENCY, 'authority' => self::WEIGHT_AUTHORITY, ]; } }