normalize
normalize makes text comparable. Use it before hashing, caching keys, deduplication or comparing model outputs across runs.
normalize(text, *, form="NFKC", strip_accents=False, lowercase=False, remove_control=True, remove_zero_width=True, collapse_whitespace=True, preserve_newlines=False, strip=True) -> str>>> normalize("Hello World\n\n")'Hello World'>>> normalize("Café", strip_accents=True)'Cafe'>>> normalize("file ①")'file 1'Try it
Section titled “Try it”Canonical text for comparing, hashing and deduplicating. Fixed step order, locale-independent.
Output
Loading beacon's Rust core (WebAssembly)…
IdleSame Rust core as the Python package, compiled to WebAssembly
Steps, in a fixed order
Section titled “Steps, in a fixed order”- Unicode normalization:
form="NFC","NFD","NFKC"(default),"NFKD"orNone. strip_accents: decompose, drop combining marks (General Category M), re-applyform. Meant for Latin-script text; it also removes vowel signs in scripts such as Devanagari.lowercase: full Unicode default case mapping, locale-independent (İ→i̇, final sigma handled).remove_control: drop category Cc, except whitespace.remove_zero_width: drop U+200B, U+2060 and U+FEFF. ZWJ/ZWNJ (emoji sequences, Indic scripts) and bidi marks are kept.collapse_whitespace: each run of Unicode whitespace becomes one space. Withpreserve_newlines, a run containing a line break becomes\n.strip: trim leading and trailing whitespace.
Normalization is idempotent: normalize(normalize(x)) == normalize(x) for any options.
Unicode version
Section titled “Unicode version”beacon.UNICODE_VERSION reports the Unicode version of the tables. It only changes in a minor release and is recorded in the changelog, so normalize output is stable within a minor series.