Skip to main content
Beyond standard SymSpell suggestions, mySpellChecker includes two specialized suggestion strategies that target Myanmar-specific error patterns: morpheme-level correction for compound words, and medial consonant swap generation.

Morpheme Suggestion Strategy

When an OOV word is a near-miss compound (one morpheme has a typo) or near-miss reduplication, this strategy corrects the individual morpheme and reconstructs the valid word.

How It Works

  1. Split the OOV word into morphemes using CompoundResolver
  2. Identify which morpheme is invalid (exactly one must be OOV)
  3. Correct the invalid morpheme using SymSpell
  4. Reconstruct the compound with the corrected morpheme

Example

Input:  "ကျောင်ငသား"  (typo in first morpheme)
Split:  ["ကျောင်င", "သား"]
         ^^^^^^^^^ invalid

Step 1: SymSpell corrects "ကျောင်င" → "ကျောင်း"
Step 2: Reconstruct: "ကျောင်း" + "သား" → "ကျောင်းသား" (student)

Usage

The morpheme suggestion strategy is automatically included in the suggestion pipeline when compound resolution is enabled:
from myspellchecker.core import SpellCheckerBuilder

checker = (
    SpellCheckerBuilder()
    .with_compound_resolver(True)
    .build()
)

# Typo in compound word — morpheme strategy finds the correction
result = checker.check("ကျောင်ငသား")
# Suggests: ကျောင်းသား

Configuration

from myspellchecker.algorithms.morpheme_suggestion_strategy import MorphemeSuggestionStrategy

strategy = MorphemeSuggestionStrategy(
    compound_resolver=resolver,
    reduplication_engine=engine,
    symspell=symspell,
    dictionary_check=provider.is_valid_word,
    max_suggestions=3,
)

Medial Swap Strategy

Myanmar’s most common error type is ya-pin/ya-yit confusion (ျ ↔ ြ). SymSpell’s delete-distance model cannot reliably generate medial swaps as edit-distance-1 candidates. This strategy directly generates orthographic variants by swapping, inserting, or deleting Myanmar medial consonants.

Myanmar Medials

MedialUnicodeNameExample
U+103BYa-pinကျ
U+103CYa-yitကြ
U+103DWa-hsweကွ
U+103EHa-htoeကှ

Operations

The strategy generates candidates through three operations:
  1. Swap: Replace one medial with another (e.g., ျ → ြ)
  2. Insert: Add a medial where none exists
  3. Delete: Remove an existing medial
All generated candidates are validated against the dictionary before being returned as suggestions.

Medial Swap Pairs

Common swap pairs are defined in rules/medial_swap_pairs.yaml:
medial_swap_pairs:
  - ["ကျောင်း", "ကြောင်း"]   # school ↔ cat/reason
  - ["ကျွန်", "ကြွန်"]         # servant ↔ (confusion)

Usage

The medial swap strategy is automatically included in the suggestion pipeline:
from myspellchecker.core import SpellCheckerBuilder

checker = (
    SpellCheckerBuilder()
    .build()
)

# Ya-pin/ya-yit confusion — medial swap strategy generates the correction
result = checker.check("ကြောင်းသွားတယ်")
# May suggest: ကျောင်းသွားတယ် (depending on context)

Direct Usage

from myspellchecker.algorithms.medial_swap_strategy import MedialSwapStrategy

strategy = MedialSwapStrategy(
    dictionary_check=provider.is_valid_word,
    pairs_path="rules/medial_swap_pairs.yaml",
)

context = SuggestionContext(
    error_text="ကြောင်း",
    sentence="ကြောင်းသွားတယ်",
)

results = list(strategy.suggest(context))
# Returns SuggestionResult with "ကျောင်း" as candidate

Integration

Both strategies are part of the multi-strategy suggestion pipeline:
SymSpell (primary)

Medial Swap Strategy (medial-specific candidates)

Morpheme Suggestion Strategy (compound word corrections)

Ranking → Neural Reranker → Final suggestions

See Also