Fraction of seed terms present as exact body tokens (case-insensitive).
(terms: &[String], body: &str)
| 570 | |
| 571 | /// Fraction of seed terms present as exact body tokens (case-insensitive). |
| 572 | fn body_match_fraction(terms: &[String], body: &str) -> f64 { |
| 573 | if terms.is_empty() { |
| 574 | return 0.0; |
| 575 | } |
| 576 | let body_tokens: HashSet<String> = search_terms(body).into_iter().collect(); |
| 577 | let matched = terms |
| 578 | .iter() |
| 579 | .filter(|term| body_tokens.contains(*term)) |
| 580 | .count(); |
| 581 | matched as f64 / terms.len() as f64 |
| 582 | } |
| 583 | |
| 584 | /// Recency component in [0, 1]: 1.0 for "just updated", halving every |
| 585 | /// [`RECENCY_HALF_LIFE_DAYS`]. Unparseable timestamps score 0. |
no test coverage detected