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

Function body_match_fraction

libatomic/src/daemon/services_agent.rs:169–179  ·  view source on GitHub ↗

Fraction of seed terms present as exact body tokens.

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

Source from the content-addressed store, hash-verified

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.

Callers 1

scan_memory_bodiesFunction · 0.70

Calls 8

search_termsFunction · 0.70
is_emptyMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45
countMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected