BlueGit

ict rusty-teams

fix(call-report): scrub name parts only as whole names

- skip common dictionary words, month/day abbreviations, numeric and short parts as name parts
- full display name still matched; single-word common names are not replaced everywhere
- tests with synthetic names for common words, word boundaries, short parts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-04 · 3 weeks ago

Hash
4fc8e2b267fd68f284d9c3b36b4c1a23a0b728ff
Parent
e8f283b3
3 files changed +85 −6
crates/app-call-model/src/report/common_words.rs added +34 −0
@@ -0,0 +1,34 @@
1 const COMMON_WORDS: &[&str] = &[
2 "a", "about", "account", "active", "admin", "after", "agent", "alert", "all", "also", "and", "answer", "any", "app",
3 "are", "art", "at", "audio", "auto", "away", "back", "bad", "band", "bank", "bass", "be", "bell", "best", "big",
4 "bird", "black", "block", "blue", "board", "bot", "box", "brown", "bug", "build", "busy", "but", "by", "call",
5 "camera", "can", "case", "cast", "center", "change", "channel", "chat", "check", "city", "class", "clear", "client",
6 "close", "code", "cold", "come", "conference", "connect", "connected", "contact", "cook", "core", "cost", "count",
7 "cross", "data", "date", "day", "de", "del", "demo", "den", "der", "des", "desk", "device", "die", "das",
8 "do", "door", "down", "drop", "du", "early", "east", "echo", "end", "error", "event", "fall", "fast", "field",
9 "file", "fine", "first", "fish", "for", "fox", "frame", "free", "from", "front", "full", "game", "gate",
10 "general", "get", "go", "gold", "good", "gray", "green", "grey", "group", "guest", "hall", "hand", "hard", "has",
11 "have", "head", "heat", "help", "here", "high", "hill", "hold", "home", "host", "hot", "house", "hub", "ice", "id",
12 "in", "info", "input", "is", "it", "join", "joined", "just", "key", "king", "lab", "lake", "land", "lane", "last",
13 "le", "lead", "left", "level", "light", "line", "link", "little", "live", "lobby", "local", "lock", "log", "long",
14 "loss", "low", "main", "major", "man", "mark", "master", "may", "media", "meet", "meeting", "member", "mic",
15 "mill", "mobile", "mode", "more", "moss", "mute", "muted", "my", "name", "net", "network", "new", "news",
16 "next", "night", "no", "none", "north", "not", "note", "now", "null", "of", "off", "office", "ok", "old", "on",
17 "one", "online", "only", "open", "or", "out", "output", "owner", "page", "park", "path", "peer", "phone", "pine",
18 "play", "pool", "port", "post", "power", "price", "pro", "queue", "quick", "rain", "ready", "red", "relay", "remote",
19 "reply", "report", "rich", "ring", "river", "road", "rock", "room", "rose", "rule", "run", "sales", "same", "screen",
20 "see", "self", "send", "server", "service", "session", "set", "share", "shared", "short", "side", "sign", "silver",
21 "small", "smart", "snow", "so", "sound", "south", "speaker", "speed", "spring", "staff", "stage", "star",
22 "start", "state", "status", "stone", "stop", "storm", "stream", "street", "strong", "summer", "support",
23 "system", "team", "teams", "tech", "test", "tester", "the", "time", "to", "top", "track", "true", "turn", "up",
24 "user", "van", "video", "view", "voice", "von", "wait", "wall", "ward", "water", "way", "web", "well", "west",
25 "white", "will", "win", "winter", "with", "wood", "word", "work", "world", "young", "your", "zu", "zum", "zur",
26 "max", "min", "rob", "ray", "pat", "eve", "jan", "feb", "mar", "apr", "jun", "jul", "aug", "sep",
27 "oct", "nov", "dec",
28 "mon", "tue", "wed", "thu", "fri", "sat", "sun", "am", "an", "auf", "aus", "bei", "ein", "eine", "im", "ist", "mit", "nach", "neu", "und", "vom",
29 ];
30
31 pub fn is_common_word(word: &str) -> bool {
32 let lowered = word.to_lowercase();
33 COMMON_WORDS.contains(&lowered.as_str())
34 }
@@ -0,0 +1,34 @@
1const COMMON_WORDS: &[&str] = &[
2 "a", "about", "account", "active", "admin", "after", "agent", "alert", "all", "also", "and", "answer", "any", "app",
3 "are", "art", "at", "audio", "auto", "away", "back", "bad", "band", "bank", "bass", "be", "bell", "best", "big",
4 "bird", "black", "block", "blue", "board", "bot", "box", "brown", "bug", "build", "busy", "but", "by", "call",
5 "camera", "can", "case", "cast", "center", "change", "channel", "chat", "check", "city", "class", "clear", "client",
6 "close", "code", "cold", "come", "conference", "connect", "connected", "contact", "cook", "core", "cost", "count",
7 "cross", "data", "date", "day", "de", "del", "demo", "den", "der", "des", "desk", "device", "die", "das",
8 "do", "door", "down", "drop", "du", "early", "east", "echo", "end", "error", "event", "fall", "fast", "field",
9 "file", "fine", "first", "fish", "for", "fox", "frame", "free", "from", "front", "full", "game", "gate",
10 "general", "get", "go", "gold", "good", "gray", "green", "grey", "group", "guest", "hall", "hand", "hard", "has",
11 "have", "head", "heat", "help", "here", "high", "hill", "hold", "home", "host", "hot", "house", "hub", "ice", "id",
12 "in", "info", "input", "is", "it", "join", "joined", "just", "key", "king", "lab", "lake", "land", "lane", "last",
13 "le", "lead", "left", "level", "light", "line", "link", "little", "live", "lobby", "local", "lock", "log", "long",
14 "loss", "low", "main", "major", "man", "mark", "master", "may", "media", "meet", "meeting", "member", "mic",
15 "mill", "mobile", "mode", "more", "moss", "mute", "muted", "my", "name", "net", "network", "new", "news",
16 "next", "night", "no", "none", "north", "not", "note", "now", "null", "of", "off", "office", "ok", "old", "on",
17 "one", "online", "only", "open", "or", "out", "output", "owner", "page", "park", "path", "peer", "phone", "pine",
18 "play", "pool", "port", "post", "power", "price", "pro", "queue", "quick", "rain", "ready", "red", "relay", "remote",
19 "reply", "report", "rich", "ring", "river", "road", "rock", "room", "rose", "rule", "run", "sales", "same", "screen",
20 "see", "self", "send", "server", "service", "session", "set", "share", "shared", "short", "side", "sign", "silver",
21 "small", "smart", "snow", "so", "sound", "south", "speaker", "speed", "spring", "staff", "stage", "star",
22 "start", "state", "status", "stone", "stop", "storm", "stream", "street", "strong", "summer", "support",
23 "system", "team", "teams", "tech", "test", "tester", "the", "time", "to", "top", "track", "true", "turn", "up",
24 "user", "van", "video", "view", "voice", "von", "wait", "wall", "ward", "water", "way", "web", "well", "west",
25 "white", "will", "win", "winter", "with", "wood", "word", "work", "world", "young", "your", "zu", "zum", "zur",
26 "max", "min", "rob", "ray", "pat", "eve", "jan", "feb", "mar", "apr", "jun", "jul", "aug", "sep",
27 "oct", "nov", "dec",
28 "mon", "tue", "wed", "thu", "fri", "sat", "sun", "am", "an", "auf", "aus", "bei", "ein", "eine", "im", "ist", "mit", "nach", "neu", "und", "vom",
29];
30
31pub fn is_common_word(word: &str) -> bool {
32 let lowered = word.to_lowercase();
33 COMMON_WORDS.contains(&lowered.as_str())
34}
crates/app-call-model/src/report/mod.rs +1 −0
@@ -1,3 +1,4 @@
1 mod common_words;
1 2 mod document;
2 3 mod markdown;
3 4 mod scrub;
@@ -1,3 +1,4 @@
1mod common_words;
1mod document;
2mod document;
2mod markdown;
3mod markdown;
3mod scrub;
4mod scrub;
crates/app-call-model/src/report/scrub.rs +50 −6
@@ -3,6 +3,8 @@ use std::sync::LazyLock;
3 3
4 4 use regex::{Captures, Regex, escape};
5 5
6 use super::common_words::is_common_word;
7
6 8 pub const SELF_PLACEHOLDER: &str = "self";
7 9 pub const ECHO_PLACEHOLDER: &str = "echo-bot";
8 10 const ORGID_PREFIX: &str = "8:orgid:";
@@ -103,12 +105,13 @@ impl Scrubber {
103 105 if name.trim().is_empty() {
104 106 return;
105 107 }
106 let mut candidates = vec![name.to_owned()];
107 candidates.extend(
108 name.split(|character: char| !character.is_alphanumeric())
109 .filter(|part| part.chars().count() >= MIN_NAME_PART)
110 .map(str::to_owned),
111 );
108 let parts: Vec<&str> =
109 name.split(|character: char| !character.is_alphanumeric()).filter(|part| !part.is_empty()).collect();
110 let mut candidates: Vec<String> = parts.iter().copied().filter(|part| is_name_part(part)).map(str::to_owned).collect();
111 let full_name = name.trim();
112 if parts.len() > 1 || (full_name.chars().count() > 1 && !is_common_word(full_name)) {
113 candidates.insert(0, full_name.to_owned());
114 }
112 115 for candidate in candidates {
113 116 if !self.names.iter().any(|(known, _)| known.eq_ignore_ascii_case(&candidate)) {
114 117 self.names.push((candidate, placeholder.to_owned()));
@@ -173,6 +176,12 @@ impl Scrubber {
173 176 }
174 177 }
175 178
179 fn is_name_part(part: &str) -> bool {
180 part.chars().count() >= MIN_NAME_PART
181 && !part.chars().all(|character| character.is_ascii_digit())
182 && !is_common_word(part)
183 }
184
176 185 fn normalize(key: &str) -> String {
177 186 key.trim().to_lowercase()
178 187 }
@@ -278,6 +287,41 @@ meeting id 12345678-aaaa-bbbb-cccc-1234567890ab at 12:30:45.";
278 287 assert_eq!(scrubber.scrub(text), text);
279 288 }
280 289
290 #[test]
291 fn common_words_in_a_name_are_only_replaced_as_the_full_name() {
292 let mut scrubber = Scrubber::new();
293 scrubber.register_person("8:orgid:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Check Testperson");
294 scrubber.register_person("8:orgid:99999999-8888-7777-6666-555555555555", "Max Video");
295 assert_eq!(
296 scrubber.scrub("check video max bitrate, Check Testperson and Max Video joined, testperson left"),
297 "check video max bitrate, person-1 and person-2 joined, person-1 left"
298 );
299 }
300
301 #[test]
302 fn name_parts_match_only_whole_words() {
303 let mut scrubber = Scrubber::new();
304 scrubber.register_person("8:orgid:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Quilla Brandtmoor");
305 assert_eq!(
306 scrubber.scrub("Quillay quilla Brandtmoorish BRANDTMOOR"),
307 "Quillay person-1 Brandtmoorish person-1"
308 );
309 }
310
311 #[test]
312 fn short_and_numeric_name_parts_are_ignored() {
313 let mut scrubber = Scrubber::new();
314 scrubber.register_person("8:orgid:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Yu Zentrel 2024");
315 assert_eq!(scrubber.scrub("yu 2024 Zentrel Yu Zentrel 2024"), "yu 2024 person-1 person-1");
316 }
317
318 #[test]
319 fn a_single_word_common_name_is_not_replaced_everywhere() {
320 let mut scrubber = Scrubber::new();
321 scrubber.register_person("8:orgid:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Test");
322 assert_eq!(scrubber.scrub("test call Test"), "test call Test");
323 }
324
281 325 #[test]
282 326 fn the_echo_bot_is_named_not_numbered() {
283 327 let mut scrubber = Scrubber::new();
@@ -3,6 +3,8 @@ use std::sync::LazyLock;
3
3
4use regex::{Captures, Regex, escape};
4use regex::{Captures, Regex, escape};
5
5
6use super::common_words::is_common_word;
7
6pub const SELF_PLACEHOLDER: &str = "self";
8pub const SELF_PLACEHOLDER: &str = "self";
7pub const ECHO_PLACEHOLDER: &str = "echo-bot";
9pub const ECHO_PLACEHOLDER: &str = "echo-bot";
8const ORGID_PREFIX: &str = "8:orgid:";
10const ORGID_PREFIX: &str = "8:orgid:";
@@ -103,12 +105,13 @@ impl Scrubber {
103 if name.trim().is_empty() {
105 if name.trim().is_empty() {
104 return;
106 return;
105 }
107 }
106 let mut candidates = vec![name.to_owned()];
108 let parts: Vec<&str> =
107 candidates.extend(
109 name.split(|character: char| !character.is_alphanumeric()).filter(|part| !part.is_empty()).collect();
108 name.split(|character: char| !character.is_alphanumeric())
110 let mut candidates: Vec<String> = parts.iter().copied().filter(|part| is_name_part(part)).map(str::to_owned).collect();
109 .filter(|part| part.chars().count() >= MIN_NAME_PART)
111 let full_name = name.trim();
110 .map(str::to_owned),
112 if parts.len() > 1 || (full_name.chars().count() > 1 && !is_common_word(full_name)) {
111 );
113 candidates.insert(0, full_name.to_owned());
114 }
112 for candidate in candidates {
115 for candidate in candidates {
113 if !self.names.iter().any(|(known, _)| known.eq_ignore_ascii_case(&candidate)) {
116 if !self.names.iter().any(|(known, _)| known.eq_ignore_ascii_case(&candidate)) {
114 self.names.push((candidate, placeholder.to_owned()));
117 self.names.push((candidate, placeholder.to_owned()));
@@ -173,6 +176,12 @@ impl Scrubber {
173 }
176 }
174}
177}
175
178
179fn is_name_part(part: &str) -> bool {
180 part.chars().count() >= MIN_NAME_PART
181 && !part.chars().all(|character| character.is_ascii_digit())
182 && !is_common_word(part)
183}
184
176fn normalize(key: &str) -> String {
185fn normalize(key: &str) -> String {
177 key.trim().to_lowercase()
186 key.trim().to_lowercase()
178}
187}
@@ -278,6 +287,41 @@ meeting id 12345678-aaaa-bbbb-cccc-1234567890ab at 12:30:45.";
278 assert_eq!(scrubber.scrub(text), text);
287 assert_eq!(scrubber.scrub(text), text);
279 }
288 }
280
289
290 #[test]
291 fn common_words_in_a_name_are_only_replaced_as_the_full_name() {
292 let mut scrubber = Scrubber::new();
293 scrubber.register_person("8:orgid:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Check Testperson");
294 scrubber.register_person("8:orgid:99999999-8888-7777-6666-555555555555", "Max Video");
295 assert_eq!(
296 scrubber.scrub("check video max bitrate, Check Testperson and Max Video joined, testperson left"),
297 "check video max bitrate, person-1 and person-2 joined, person-1 left"
298 );
299 }
300
301 #[test]
302 fn name_parts_match_only_whole_words() {
303 let mut scrubber = Scrubber::new();
304 scrubber.register_person("8:orgid:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Quilla Brandtmoor");
305 assert_eq!(
306 scrubber.scrub("Quillay quilla Brandtmoorish BRANDTMOOR"),
307 "Quillay person-1 Brandtmoorish person-1"
308 );
309 }
310
311 #[test]
312 fn short_and_numeric_name_parts_are_ignored() {
313 let mut scrubber = Scrubber::new();
314 scrubber.register_person("8:orgid:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Yu Zentrel 2024");
315 assert_eq!(scrubber.scrub("yu 2024 Zentrel Yu Zentrel 2024"), "yu 2024 person-1 person-1");
316 }
317
318 #[test]
319 fn a_single_word_common_name_is_not_replaced_everywhere() {
320 let mut scrubber = Scrubber::new();
321 scrubber.register_person("8:orgid:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Test");
322 assert_eq!(scrubber.scrub("test call Test"), "test call Test");
323 }
324
281 #[test]
325 #[test]
282 fn the_echo_bot_is_named_not_numbered() {
326 fn the_echo_bot_is_named_not_numbered() {
283 let mut scrubber = Scrubber::new();
327 let mut scrubber = Scrubber::new();