BasicTextNormalizer
Basic text normalizer that lowercases text, removes brackets/parentheses content, and optionally removes diacritics.Initialization
bool
default:"False"
If True, removes diacritical marks from characters (e.g., “café” → “cafe”)
bool
default:"False"
If True, splits text into individual Unicode grapheme clusters (useful for character-level analysis)
Normalization Process
TheBasicTextNormalizer performs the following operations:
- Converts text to lowercase
- Removes content within angle brackets or square brackets:
<...>,[...] - Removes content within parentheses:
(...) - Optionally removes diacritics and symbols (if
remove_diacritics=True) - Optionally splits into individual letters/graphemes (if
split_letters=True) - Collapses multiple whitespace characters into single spaces
Examples
Basic Usage
With Diacritics Removal
With Letter Splitting
EnglishTextNormalizer
Comprehensive English text normalizer that expands contractions, standardizes numbers, and normalizes spellings.Normalization Process
TheEnglishTextNormalizer performs extensive normalization:
- Converts text to lowercase
- Removes content in brackets/parentheses:
<...>,[...],(...) - Removes filler words: “hmm”, “mm”, “mhm”, “uh”, “um”
- Expands contractions: “can’t” → “can not”, “won’t” → “will not”
- Expands titles and abbreviations: “Mr.” → “mister”, “Dr.” → “doctor”
- Standardizes numbers: converts spelled-out numbers to digits
- Normalizes spellings: British to American English
- Removes symbols and punctuation (keeping numeric symbols during processing)
- Collapses whitespace
Examples
Contraction Expansion
Title and Abbreviation Expansion
Number Normalization
Spelling Normalization
Complete Example
EnglishNumberNormalizer
Specialized normalizer for converting spelled-out numbers to Arabic numerals.Features
- Converts spelled-out numbers to digits
- Removes commas from numbers
- Preserves suffixes: “1960s”, “21st”, “32nd”
- Handles currency symbols: “$20 million” → “20000000 dollars”
- Interprets successive single digits: “one oh one” → “101”
- Supports special patterns: “double three” → “33”, “triple five” → “555”
Examples
Basic Number Conversion
Ordinals and Cardinals
Currency and Symbols
Special Patterns
Signs and Prefixes
EnglishSpellingNormalizer
Normalizes British English spellings to American English.Examples
Utility Functions
remove_symbols_and_diacritics()
Removes symbols, punctuation, and diacritical marks from text.str
required
Input text to process
str
default:"\"\""
String of characters to preserve (e.g., ”.$” to keep dollar signs and periods)
str
Text with symbols and diacritics removed (replaced with spaces), except for characters in
keepremove_symbols()
Removes symbols and punctuation while preserving diacritics.str
required
Input text to process
str
Text with symbols and punctuation removed (replaced with spaces), but diacritics preserved
Use Cases
Comparing Transcriptions
Calculating Word Error Rate (WER)
Multilingual Text Cleaning
Preprocessing for Search/Indexing
Diacritics Mapping
The following special characters are mapped whenremove_diacritics=True:
Additionally, all Unicode characters with the “Mn” (Mark, nonspacing) category are removed.