Skip to main content
Myanmar text segmentation operates at two levels, syllable and word, because Myanmar script has no spaces between words. mySpellChecker separates these concerns: a fast regex-based segmenter handles syllables, while a configurable word engine (myword, CRF, or transformer) handles word boundaries.

Architecture

Segmentation architecture: Raw Myanmar Text forks into Syllable Segmentation (RegexSegmenter, rule-based) and Word Segmentation (DefaultSegmenter with myword/CRF/transformer engine)

Quick Start


Syllable Segmentation

RegexSegmenter

All syllable segmentation in mySpellChecker uses RegexSegmenter, a pure-Python, rule-based segmenter with zero external dependencies and no network downloads.
Characteristics:
  • 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 by DefaultSegmenter, 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

The myword 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. Requires pycrfsuite.

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 the Segmenter 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