#[derive(Clone, Copy, Debug, PartialEq)]
pub struct DomainProfile {
pub name: &'static str,
pub ahc_threshold: f32,
pub as_norm_threshold: Option<f32>,
pub as_norm_top_n: usize,
}
pub const VOXCONVERSE: DomainProfile = DomainProfile {
name: "voxconverse",
ahc_threshold: 0.45,
as_norm_threshold: Some(4.0),
as_norm_top_n: 100,
};
pub const AMI: DomainProfile = DomainProfile {
name: "ami",
ahc_threshold: 0.55,
as_norm_threshold: Some(5.0),
as_norm_top_n: 100,
};
pub const CALLHOME: DomainProfile = DomainProfile {
name: "callhome",
ahc_threshold: 0.5,
as_norm_threshold: None,
as_norm_top_n: 100,
};
pub const DOMAIN_PROFILES: &[DomainProfile] = &[VOXCONVERSE, AMI, CALLHOME];
pub const DEFAULT_DOMAIN_PROFILE: DomainProfile = VOXCONVERSE;
pub fn domain_profile(name: &str) -> Option<DomainProfile> {
DOMAIN_PROFILES.iter().copied().find(|p| p.name == name)
}
#[allow(clippy::unwrap_used)]
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn lookup_resolves_every_shipped_profile() {
for p in DOMAIN_PROFILES {
assert_eq!(domain_profile(p.name), Some(*p), "{}", p.name);
}
}
#[test]
fn lookup_is_deterministic_and_rejects_unknown_names() {
assert_eq!(domain_profile("ami"), domain_profile("ami"));
assert_eq!(domain_profile("voxconverse"), Some(DEFAULT_DOMAIN_PROFILE));
for bogus in ["", "AMI", "vox", "switchboard", "voxconverse-test"] {
assert_eq!(domain_profile(bogus), None, "{bogus}");
}
}
#[test]
fn profiles_carry_distinct_thresholds() {
let v = VOXCONVERSE.ahc_threshold;
let a = AMI.ahc_threshold;
let c = CALLHOME.ahc_threshold;
assert_ne!(v, a);
assert_ne!(v, c);
assert_ne!(a, c);
}
}