Fraction of seed terms present as exact body tokens.
(terms: &[String], body: &str)
| 167 | |
| 168 | /// Fraction of seed terms present as exact body tokens. |
| 169 | fn body_match_fraction(terms: &[String], body: &str) -> f64 { |
| 170 | if terms.is_empty() { |
| 171 | return 0.0; |
| 172 | } |
| 173 | let body_tokens: HashSet<String> = search_terms(body).into_iter().collect(); |
| 174 | let matched = terms |
| 175 | .iter() |
| 176 | .filter(|term| body_tokens.contains(*term)) |
| 177 | .count(); |
| 178 | matched as f64 / terms.len() as f64 |
| 179 | } |
| 180 | |
| 181 | /// Recency component in [0, 1]: 1.0 for "just updated", halving every |
| 182 | /// [`RECENCY_HALF_LIFE_DAYS`]. Unparseable timestamps score 0. |
no test coverage detected