import SprachmittlerText /// Family-neutral same-language check used by the pipeline. The canonical-code mapping stays in /// Engines, next to the catalogue that defines it. public enum LanguageMatching { /// True when detection is confident and every alternative resolves to the target language. public static func isSameLanguage(_ detection: LanguageDetection, target: ModelLanguage) -> Bool { guard detection.confidence >= 0.5, !detection.alternatives.isEmpty else { return false } let targetCode = HyMT3Languages.resolve(target.code)?.code ?? target.code var agreed = false for code in detection.alternatives { guard let language = HyMT3Languages.resolve(code), language.code.caseInsensitiveCompare(targetCode) == .orderedSame else { return false } agreed = true } return agreed } }