Fraction of seed terms present as exact body tokens (case-insensitive).
(terms: &[String], body: &str)
| 525 | |
| 526 | /// Fraction of seed terms present as exact body tokens (case-insensitive). |
| 527 | fn body_match_fraction(terms: &[String], body: &str) -> f64 { |
| 528 | if terms.is_empty() { |
| 529 | return 0.0; |
| 530 | } |
| 531 | let body_tokens: HashSet<String> = search_terms(body).into_iter().collect(); |
| 532 | let matched = terms |
| 533 | .iter() |
| 534 | .filter(|term| body_tokens.contains(*term)) |
| 535 | .count(); |
| 536 | matched as f64 / terms.len() as f64 |
| 537 | } |
| 538 | |
| 539 | /// Recency component in [0, 1]: 1.0 for "just updated", halving every |
| 540 | /// [`RECENCY_HALF_LIFE_DAYS`]. Unparseable timestamps score 0. |
no test coverage detected