Handles text cleaning operations for different datasets. This utility class provides dataset-specific text normalization and cleaning operations to ensure consistent transcript processing across different evaluation datasets, particularly for specialized corpora like CORAAL. Method
| 214 | |
| 215 | |
| 216 | class TextCleaner: |
| 217 | """Handles text cleaning operations for different datasets. |
| 218 | |
| 219 | This utility class provides dataset-specific text normalization and cleaning |
| 220 | operations to ensure consistent transcript processing across different evaluation |
| 221 | datasets, particularly for specialized corpora like CORAAL. |
| 222 | |
| 223 | Methods: |
| 224 | clean_coraal_text: Specialized text cleaning for CORAAL dialect corpus |
| 225 | """ |
| 226 | |
| 227 | @staticmethod |
| 228 | def clean_coraal_text(text: str) -> str: |
| 229 | """Clean CORAAL dataset text according to corpus conventions. |
| 230 | |
| 231 | Applies CORAAL-specific text normalization including dialect word mapping, |
| 232 | marker removal, and unintelligible segment handling. This ensures fair |
| 233 | evaluation by standardizing transcript format. |
| 234 | |
| 235 | Args: |
| 236 | text (str): Raw CORAAL transcript text with corpus-specific markup |
| 237 | |
| 238 | Returns: |
| 239 | str: Cleaned transcript text ready for evaluation |
| 240 | |
| 241 | Note: |
| 242 | CORAAL (Corpus of Regional African American Language) uses specific |
| 243 | markup conventions for dialectal features, background noise, and |
| 244 | unintelligible segments that need standardized handling. |
| 245 | |
| 246 | Example: |
| 247 | >>> raw_text = "We(BR) aksed for [unintelligible] busses" |
| 248 | >>> clean_text = TextCleaner.clean_coraal_text(raw_text) |
| 249 | >>> print(clean_text) |
| 250 | "We asked for buses" |
| 251 | """ |
| 252 | text = text.replace("[", "{").replace("]", "}") |
| 253 | |
| 254 | # Relabel CORAAL words |
| 255 | replacements = { |
| 256 | "busses": "buses", |
| 257 | "aks": "ask", |
| 258 | "aksing": "asking", |
| 259 | "aksed": "asked", |
| 260 | } |
| 261 | words = text.split() |
| 262 | words = [replacements.get(word, word) for word in words] |
| 263 | text = " ".join(words) |
| 264 | |
| 265 | # Remove CORAAL flags and markers |
| 266 | patterns_to_remove = [ |
| 267 | r"(?i)\/unintelligible\/", |
| 268 | r"(?i)\/inaudible\/", |
| 269 | r"\/RD(.*?)\/", |
| 270 | r"\/(\?)\1*\/", |
| 271 | ] |
| 272 | for pattern in patterns_to_remove: |
| 273 | text = re.sub(pattern, "", text) |
nothing calls this directly
no outgoing calls
no test coverage detected