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

Function bigrams

atomic-repository/src/diff_engine.rs:1101–1110  ·  view source on GitHub ↗

Helper: compute character bigrams for Jaccard similarity

(s: &str)

Source from the content-addressed store, hash-verified

1099
1100 // Helper: compute character bigrams for Jaccard similarity
1101 fn bigrams(s: &str) -> HashSet<(u8, u8)> {
1102 let bytes = s.trim().as_bytes();
1103 let mut set = HashSet::new();
1104 if bytes.len() >= 2 {
1105 for w in bytes.windows(2) {
1106 set.insert((w[0], w[1]));
1107 }
1108 }
1109 set
1110 }
1111
1112 fn jaccard(a: &HashSet<(u8, u8)>, b: &HashSet<(u8, u8)>) -> f64 {
1113 if a.is_empty() && b.is_empty() {

Callers 2

repair_diff_linesMethod · 0.85
repair_diff_linesFunction · 0.85

Calls 3

as_bytesMethod · 0.45
lenMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected