MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / body_match_fraction

Function body_match_fraction

atomic-cli/src/commands/vault/context.rs:572–582  ·  view source on GitHub ↗

Fraction of seed terms present as exact body tokens (case-insensitive).

(terms: &[String], body: &str)

Source from the content-addressed store, hash-verified

570
571/// Fraction of seed terms present as exact body tokens (case-insensitive).
572fn 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.

Callers 1

scan_memory_bodiesMethod · 0.85

Calls 7

search_termsFunction · 0.85
is_emptyMethod · 0.45
into_iterMethod · 0.45
countMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected