Architecture

Quick Start
Syllable Segmentation
RegexSegmenter
All syllable segmentation in mySpellChecker usesRegexSegmenter, a pure-Python, rule-based segmenter with zero external dependencies and no network downloads.
- Pure Python with optional Cython acceleration
- No downloads, no model, no dictionary needed
- Fork-safe for multiprocessing
- Handles stacked consonants (Virama ္), Kinzi sequences, and non-Myanmar text
RegexSegmenter only supports syllable and sentence segmentation. It raises NotImplementedError for segment_words(). Use DefaultSegmenter for word segmentation.Sylbreak Algorithm
The segmenter uses an adapted Sylbreak algorithm:Cython Acceleration
RegexSegmenter automatically uses a Cython-compiled implementation when available:Word Segmentation
Word segmentation is handled byDefaultSegmenter, which delegates to one of three word engines. Both myword and crf download resources from HuggingFace on first use.
Word Engines
Engine Selection
HuggingFace Resource Downloads
Themyword and crf engines download their resources from the thettwe/myspellchecker-resources HuggingFace dataset repository on first use:
Resources are cached at
~/.cache/myspellchecker/resources/ and only downloaded once.
Word segmenters use lazy initialization, so no download occurs when you create a
DefaultSegmenter or SpellChecker. The download happens on the first call to segment_words().myword Engine
The default word segmentation engine, based on myWord by Ye Kyaw Thu. Uses a Viterbi algorithm with unigram and bigram probabilities from a memory-mapped dictionary.CRF Engine
CRF-based sequence tagger trained on myPOS corpus by Ye Kyaw Thu. Requirespycrfsuite.
Transformer Engine
XLM-RoBERTa model fine-tuned for Myanmar word boundary detection by Chuu Htet Naing. Uses B/I (Begin/Inside) token classification.Segmenter Interface
All segmenters implement theSegmenter abstract base class:
DefaultSegmenter
The production segmenter that combines RegexSegmenter (syllables) with a configurable word engine:Usage with SpellChecker
Via Configuration
Custom Segmenter
Via Builder
Performance Comparison
Sentence Boundaries
All segmenters split on Myanmar sentence separator (။):DefaultSegmenter also detects sentence-final particles (SFPs) as implicit sentence boundaries in longer texts.
See Also
- Segmentation Algorithm - Segmentation internals
- Syllable Segmentation - Sylbreak algorithm details
- Text Normalization - Pre-processing before segmentation
- Joint Segmentation and Tagging - Unified Viterbi segmentation + POS
- Cython Guide - Performance optimization