Normalize & Zawgyi¶
burmesenlp.normalize.normalize ¶
Normalize Myanmar text for segmentation.
- Validates the input type (raises
TypeErrorfor non-str). - Strips zero-width space/joiner/non-joiner, word-joiner and BOM.
- Applies Unicode NFC (e.g. composes U+1025 U+102E into U+1026).
- Logs a warning if the text looks Zawgyi-encoded; conversion to
Unicode must be done by the caller. Pass
warn_zawgyi=Falsewhen normalizing dictionary keys in bulk (avoids noisy false positives).
NFC does not canonicalize Myanmar syllable-mark order: every
medial/vowel/anusvara/visarga sign has Canonical_Combining_Class 0
(only asat and dot below are non-zero), so Unicode's canonical
reordering algorithm never touches their relative order. Two
different input-method key orders for the same syllable stay
distinct strings through NFC forever. Call :func:canonical_order
separately (opt-in; not applied here) if that matters for your data.
Source code in src/burmesenlp/normalize/__init__.py
burmesenlp.normalize.looks_like_zawgyi ¶
Heuristically detect Zawgyi-encoded text.
This is a lightweight rule-based check, not a trained detector. Use a dedicated converter (e.g. ICU transliteration, myanmar-tools) for authoritative detection and conversion.
Source code in src/burmesenlp/normalize/__init__.py
burmesenlp.zawgyi.zg2uni ¶
Convert Zawgyi-encoded text to standard Unicode Myanmar.
burmesenlp.zawgyi.uni2zg ¶
Convert standard Unicode Myanmar text to Zawgyi encoding.
burmesenlp.zawgyi.to_unicode ¶
Ensure text is standard Unicode Myanmar.
Detects Zawgyi and converts only if needed, then applies NFC by default. Safe to call on text of unknown encoding.
Source code in src/burmesenlp/zawgyi/zawgyi.py
burmesenlp.zawgyi.is_zawgyi ¶
Heuristic check for whether text is Zawgyi-encoded.