Skip to main content
Before any validation can occur, continuous Myanmar text must be split into meaningful units — syllables, words, and sentences. This page covers the pluggable segmenter interface, the default hybrid implementation, joint segmentation-tagging mode, and how to bring your own segmentation logic.

The Segmenter Interface

mySpellChecker uses a pluggable Segmenter abstract base class (src/myspellchecker/segmenters/base.py).

Default Implementation

The default implementation (DefaultSegmenter) uses a Hybrid Approach combining rule-based speed with ML-powered accuracy.

1. Syllable Segmentation (Optimized)

  • Algorithm: Uses a Cython-optimized C++ implementation of syllable breaking rules (adapted from Sylbreak) for maximum performance. Falls back to Regex matching if the extension is unavailable.
  • Noise Reduction:
    • Unicode Normalization: Automatically applies NFC normalization and reorders diacritics (e.g., Medial Ra after Virama) using fast C++ routines.
    • Validity Filtering: Checks against strict linguistical rules to discard “junk” syllables (e.g., floating diacritics, impossible stacks).
  • Performance: Fast (<1ms/sentence typical).

2. Sentence & Word Segmentation (Pluggable Engines)

The segmenter supports multiple engines for word segmentation:
  • myWord (Default & Recommended): Uses a Viterbi algorithm with unigram/bigram probabilities. It provides the best balance of speed and accuracy, especially for particle handling.
  • CRF: Uses Conditional Random Fields (via python-crfsuite). Good for general text but slower than myWord.
Fallback: If dependencies are missing, it degrades to basic whitespace/punctuation splitting.

Joint Segmentation and POS Tagging

For advanced use cases, mySpellChecker offers joint segmentation-tagging - a unified Viterbi decoder that simultaneously optimizes word boundaries AND POS tags in a single pass.

Benefits Over Sequential Processing

The traditional pipeline segments text first, then tags the resulting words. This can lead to suboptimal results when:
  • Segmentation ambiguity depends on POS context (e.g., particle boundaries)
  • Multiple valid segmentations exist with different tag sequences
Joint mode solves this by considering both objectives together:

Enabling Joint Mode

Direct Usage

You can also use the JointSegmentTagger class directly:

Configuration Options

Custom Segmenters

You can bring your own segmentation logic by subclassing Segmenter and passing it to SpellChecker.