Fraction of seed terms present as exact body tokens (case-insensitive).
(terms: &[String], body: &str)
| 598 | |
| 599 | /// Fraction of seed terms present as exact body tokens (case-insensitive). |
| 600 | fn body_match_fraction(terms: &[String], body: &str) -> f64 { |
| 601 | if terms.is_empty() { |
| 602 | return 0.0; |
| 603 | } |
| 604 | let body_tokens: HashSet<String> = search_terms(body).into_iter().collect(); |
| 605 | let matched = terms |
| 606 | .iter() |
| 607 | .filter(|term| body_tokens.contains(*term)) |
| 608 | .count(); |
| 609 | matched as f64 / terms.len() as f64 |
| 610 | } |
| 611 | |
| 612 | /// Recency component in [0, 1]: 1.0 for "just updated", halving every |
| 613 | /// [`RECENCY_HALF_LIFE_DAYS`]. Unparseable timestamps score 0. |
no test coverage detected