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

Function body_match_fraction

atomic-cli/src/commands/vault/context.rs:568–578  ·  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

566
567/// Fraction of seed terms present as exact body tokens (case-insensitive).
568fn body_match_fraction(terms: &[String], body: &str) -> f64 {
569 if terms.is_empty() {
570 return 0.0;
571 }
572 let body_tokens: HashSet<String> = search_terms(body).into_iter().collect();
573 let matched = terms
574 .iter()
575 .filter(|term| body_tokens.contains(*term))
576 .count();
577 matched as f64 / terms.len() as f64
578}
579
580/// Recency component in [0, 1]: 1.0 for "just updated", halving every
581/// [`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