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

Method bigrams

atomic-cli/src/commands/diff/helpers.rs:646–655  ·  view source on GitHub ↗

Helper: compute character bigrams for Jaccard similarity

(s: &str)

Source from the content-addressed store, hash-verified

644
645 // Helper: compute character bigrams for Jaccard similarity
646 fn bigrams(s: &str) -> HashSet<(u8, u8)> {
647 let bytes = s.trim().as_bytes();
648 let mut set = HashSet::new();
649 if bytes.len() >= 2 {
650 for w in bytes.windows(2) {
651 set.insert((w[0], w[1]));
652 }
653 }
654 set
655 }
656
657 fn jaccard(a: &HashSet<(u8, u8)>, b: &HashSet<(u8, u8)>) -> f64 {
658 if a.is_empty() && b.is_empty() {

Callers

nothing calls this directly

Calls 3

as_bytesMethod · 0.45
lenMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected