""" Badini Kurdish text normalizer — companion module for computeram/badini-w2v-bert-normalized. Applies the same normalization used to evaluate this model (punctuation handling, Badini number-word expansion, character/word-variant unification) to raw CTC decoder output, so predictions match the quality reported for the "normalized" evaluation numbers rather than the raw greedy-decode numbers. Usage: from badini_normalize import normalize_transcript clean_text = normalize_transcript(raw_model_output) """ import re import unicodedata as ud USE_BADINI_FORMS = True def number2word(text): """Convert numerals in `text` into spoken (Sorani) Kurdish words.""" unify = [ ("٠|۰", "0"), ("١|۱", "1"), ("٢|۲", "2"), ("٣|۳", "3"), ("٤|۴", "4"), ("٥|۵", "5"), ("٦|۶", "6"), ("٧|۷", "7"), ("٨|۸", "8"), ("٩|۹", "9"), ] for pat, rep in unify: text = re.sub(pat, rep, text) text = re.sub(r"([0-9]{1,3})[,،](?=[0-9]{3})", r"\1", text) text = re.sub(r"(?