Skip to main content
Spell checking results and system failures are represented by two separate hierarchies: Error subclasses (returned in Response.errors) for validation findings, and Python exceptions for configuration, resource, and processing failures. This page documents both.

Spell Checking Errors

These are returned in Response.errors when checking text.

Error Base Class

All spell checking errors inherit from Error:
from myspellchecker.core.response import Error

@dataclass
class Error:
    text: str           # The erroneous text
    position: int       # Character position (0-indexed)
    suggestions: List[str]  # Correction suggestions
    error_type: str     # Type identifier
    confidence: float   # 0.0 to 1.0

SyllableError

Invalid syllable detected (Layer 1 validation).
from myspellchecker.core.response import SyllableError

error = SyllableError(
    text="မျန်",
    position=0,
    suggestions=["မြန်", "မျန်း"],
    confidence=0.95
)

print(error.error_type)  # "invalid_syllable"
Error Types:
TypeDescription
invalid_syllableStandard syllable validation error
particle_typoKnown particle typo (e.g., တယ → တယ်)
medial_confusionYa-pin/Ra-yit confusion

WordError

Invalid word detected (Layer 2 validation).
from myspellchecker.core.response import WordError

error = WordError(
    text="မြန်စာ",
    position=0,
    suggestions=["မြန်မာ", "မြန်"],
    syllable_count=2,
    confidence=0.9
)

print(error.error_type)    # "invalid_word"
print(error.syllable_count)  # 2

ContextError

Unlikely word sequence detected (Layer 3 validation).
from myspellchecker.core.response import ContextError

error = ContextError(
    text="ဘယ်",
    position=3,
    suggestions=["သွား", "သည်"],
    probability=0.005,
    prev_word="သူ",
    confidence=0.7
)

print(error.error_type)  # "context_probability"
print(error.probability) # 0.005
print(error.prev_word)   # "သူ"
AI Detection Error Types:
TypeSourceDescription
ai_detectedErrorDetectionStrategyToken flagged by AI classifier
AI-detected errors have empty suggestions — the detector identifies errors but does not generate corrections. Other strategies (SymSpell, SemanticChecker) provide suggestions.

GrammarError

Grammar-related errors from grammar checkers.
from myspellchecker.core.response import GrammarError

error = GrammarError(
    text="ယေက်",
    position=2,
    suggestions=["ယောက်"],
    error_type="typo",  # ClassifierChecker uses "typo" for classifier typos
    confidence=0.95,
    reason="Classifier typo: ယေက် should be ယောက်"
)

Grammar Error Types:
TypeSourceDescription
aspect_typoAspectCheckerVerb aspect marker typo
incomplete_aspectAspectCheckerIncomplete aspect marking
invalid_sequenceAspectCheckerInvalid aspect sequence
typoClassifierCheckerClassifier typo (e.g., ယေက် → ယောက်)
agreementClassifierCheckerClassifier-noun agreement error
compound_typoCompoundCheckerCompound word typo
incomplete_reduplicationCompoundCheckerIncomplete reduplication
typoNegationCheckerNegation pattern typo
mixed_registerRegisterCheckerFormal/colloquial mixing

Response Object

The complete spell checking result:
from myspellchecker.core.response import Response

response = Response(
    text="မျနမ်ာ",           # Original input
    corrected_text="မြန်မာ",  # Auto-corrected
    has_errors=True,          # Quick check flag
    level="syllable",         # Validation level used
    errors=[...],             # List of Error objects
    metadata={                # Processing info
        "processing_time_ms": 15.2,
        "syllable_count": 4,
        "word_count": 1
    }
)

# Serialize
print(response.to_json())
print(response.to_dict())

Exceptions

System-level errors for configuration, resources, and processing.

Exception Hierarchy

MyanmarSpellcheckError (base)
├── ConfigurationError
│   └── InvalidConfigError
├── DataLoadingError
│   └── MissingDatabaseError
├── ProcessingError
│   ├── ValidationError
│   ├── TokenizationError
│   └── NormalizationError
├── ProviderError
│   └── ConnectionPoolError
├── PipelineError
│   ├── IngestionError
│   └── PackagingError
├── ModelError
│   ├── ModelLoadError
│   └── InferenceError
├── MissingDependencyError
├── InsufficientStorageError
└── CacheError

Common Exceptions

MyanmarSpellcheckError

Base exception for all library errors:
from myspellchecker.core.exceptions import MyanmarSpellcheckError

try:
    checker.check(text)
except MyanmarSpellcheckError as e:
    print(f"Spell check error: {e}")

MissingDatabaseError

Database not found:
from myspellchecker.core.exceptions import MissingDatabaseError

try:
    checker = SpellChecker()
except MissingDatabaseError as e:
    print(f"Database not found: {e}")
    print(f"Searched: {e.searched_paths}")
    print(f"Solution: {e.suggestion}")

MissingDependencyError

Optional dependency not installed:
from myspellchecker.core.exceptions import MissingDependencyError

try:
    from myspellchecker.algorithms import TransformerPOSTagger
except MissingDependencyError as e:
    print(f"Missing dependency: {e}")
    # Install: pip install myspellchecker[transformers]

ConfigurationError

Invalid configuration:
from myspellchecker.core.exceptions import ConfigurationError, InvalidConfigError

try:
    config = SpellCheckerConfig(max_edit_distance=10)  # Invalid
except InvalidConfigError as e:
    print(f"Invalid config: {e}")

ProcessingError

Text processing failure:
from myspellchecker.core.exceptions import (
    ProcessingError,
    ValidationError,
    TokenizationError,
    NormalizationError
)

try:
    result = checker.check(text)
except ValidationError as e:
    print(f"Invalid text: {e}")
except TokenizationError as e:
    print(f"Segmentation failed: {e}")
except NormalizationError as e:
    print(f"Normalization failed: {e}")
except ProcessingError as e:
    print(f"Processing failed: {e}")

ProviderError

Database provider failure:
from myspellchecker.core.exceptions import ProviderError, ConnectionPoolError

try:
    result = checker.check(text)
except ConnectionPoolError as e:
    print(f"Connection pool exhausted: {e}")
except ProviderError as e:
    print(f"Provider error: {e}")

PipelineError

Data pipeline failure:
from myspellchecker.core.exceptions import PipelineError, IngestionError, PackagingError

try:
    pipeline.run()
except IngestionError as e:
    print(f"Ingestion failed: {e}")
    print(f"Missing files: {e.missing_files}")
    print(f"Failed files: {e.failed_files}")
except PackagingError as e:
    print(f"Packaging failed: {e}")
except PipelineError as e:
    print(f"Pipeline error: {e}")

ModelError

ML model failure:
from myspellchecker.core.exceptions import ModelError, ModelLoadError, InferenceError

try:
    tagger.tag(text)
except ModelLoadError as e:
    print(f"Model load failed: {e}")
except InferenceError as e:
    print(f"Inference failed: {e}")
except ModelError as e:
    print(f"Model error: {e}")

Exception Tuples

Pre-defined tuples for consistent error handling:
from myspellchecker.core.exceptions import (
    CRITICAL_OPERATION_EXCEPTIONS,
    DATABASE_EXCEPTIONS,
    PROCESSING_EXCEPTIONS,
    VALIDATION_EXCEPTIONS,
    INFERENCE_EXCEPTIONS,
    CACHE_EXCEPTIONS
)

# Use in try/except
try:
    result = process_text(text)
except PROCESSING_EXCEPTIONS as e:
    logger.error(f"Processing failed: {e}")

Error Type Constants

from myspellchecker.core.constants import ErrorType

# --- Core validation errors ---
ErrorType.SYLLABLE                  # "invalid_syllable"
ErrorType.WORD                      # "invalid_word"
ErrorType.CONTEXT_PROBABILITY       # "context_probability"
ErrorType.GRAMMAR                   # "grammar_error"

# --- Syllable-level specific errors ---
ErrorType.PARTICLE_TYPO             # "particle_typo"
ErrorType.MEDIAL_CONFUSION          # "medial_confusion"

# --- Colloquial variant errors ---
ErrorType.COLLOQUIAL_VARIANT        # "colloquial_variant"  (strict mode)
ErrorType.COLLOQUIAL_INFO           # "colloquial_info"     (lenient mode)

# --- Validation strategy errors ---
ErrorType.QUESTION_STRUCTURE        # "question_structure"
ErrorType.SYNTAX_ERROR              # "syntax_error"
ErrorType.HOMOPHONE_ERROR           # "homophone_error"
ErrorType.TONE_AMBIGUITY            # "tone_ambiguity"
ErrorType.POS_SEQUENCE_ERROR        # "pos_sequence_error"
ErrorType.SEMANTIC_ERROR            # "semantic_error"

# --- Encoding errors ---
ErrorType.ZAWGYI_ENCODING           # "zawgyi_encoding"

# --- Grammar checker specific errors ---
ErrorType.MIXED_REGISTER            # "mixed_register"
ErrorType.ASPECT_TYPO               # "aspect_typo"
ErrorType.INVALID_SEQUENCE          # "invalid_sequence"
ErrorType.INCOMPLETE_ASPECT         # "incomplete_aspect"
ErrorType.TYPO                      # "typo"
ErrorType.AGREEMENT                 # "agreement"
ErrorType.COMPOUND_TYPO             # "compound_typo"
ErrorType.INCOMPLETE_REDUPLICATION  # "incomplete_reduplication"
ErrorType.CLASSIFIER_TYPO           # "classifier_typo"

# --- Text-level detector errors (spellchecker.py) ---
ErrorType.COLLOQUIAL_CONTRACTION    # "colloquial_contraction"
ErrorType.PARTICLE_CONFUSION        # "particle_confusion"
ErrorType.HA_HTOE_CONFUSION         # "ha_htoe_confusion"
ErrorType.DANGLING_PARTICLE         # "dangling_particle"
ErrorType.DANGLING_WORD             # "dangling_word"
ErrorType.MISSING_CONJUNCTION       # "missing_conjunction"
ErrorType.TENSE_MISMATCH            # "tense_mismatch"
ErrorType.REGISTER_MIXING           # "register_mixing"

# --- Grammar checker class-level errors ---
ErrorType.NEGATION_ERROR            # "negation_error"
ErrorType.REGISTER_ERROR            # "register_error"
ErrorType.MERGED_WORD               # "merged_word"
ErrorType.ASPECT_ERROR              # "aspect_error"
ErrorType.CLASSIFIER_ERROR          # "classifier_error"
ErrorType.COMPOUND_ERROR            # "compound_error"

# --- Orthography errors ---
ErrorType.MEDIAL_ORDER_ERROR        # "medial_order_error"
ErrorType.MEDIAL_COMPATIBILITY_ERROR  # "medial_compatibility_error"

# --- AI error detection ---
ErrorType.AI_DETECTED               # "ai_detected"

Best Practices

1. Catch Specific Exceptions

try:
    result = checker.check(text)
except MissingDatabaseError:
    # Handle missing database specifically
    build_sample_database()
except MyanmarSpellcheckError:
    # Handle other library errors
    log_error()

2. Check Error Types

for error in result.errors:
    if error.error_type == "invalid_syllable":
        # Handle syllable error
        pass
    elif error.error_type.startswith("classifier"):
        # Handle classifier errors
        pass

3. Use Confidence Scores

HIGH_CONFIDENCE = 0.8

for error in result.errors:
    if error.confidence >= HIGH_CONFIDENCE:
        # Auto-correct high confidence errors
        apply_correction(error)
    else:
        # Show suggestions for low confidence
        show_suggestions(error)

Common Myanmar Spelling Errors

Error Frequency by Category

Based on corpus analysis:
Error TypeFrequencyDetection LayerExample
Medial ြ/ျ confusion35%Syllableကြောင်/ကျောင်
Missing asat20%Syllableအိမ/အိမ်
Vowel length15%Syllable/Wordသု/သူ
Particle errors12%Grammarမှာ/မှ
Context (real-word)10%Contextထမင်းသွား/ထမင်းစား
Stacking errors5%SyllableKinzi errors
Other3%Various-

Detection by Validation Layer

Layer 1 - Syllable Validation:
result = checker.check("ကွြ")   # Invalid medial order → Suggestion: ကြွ
result = checker.check("ကိီ")   # Incompatible vowels
Layer 2 - Word Validation:
result = checker.check("မယ်နမာ")  # Unknown word → Suggestions: ["မြန်မာ", ...]
Layer 2.5 - Grammar Checking:
result = checker.check("သွားကို")  # Verb with object particle → GrammarError
Layer 3 - Context Validation:
result = checker.check("ထမင်းသွား")  # Low probability bigram → Suggestion: ထမင်းစား

Medial-Consonant Compatibility

Not all medials are compatible with all consonants:
MedialCompatible WithIncompatible With
Ha-htoe (ှ)Sonorants (န, မ, လ, etc.)Stops (က, ခ, ဂ, etc.)
Ya-pin (ြ)Ka-group, Pa-groupTha (သ)

Stacking Errors

Correct: မင်္ဂလာ (blessing)     |  Error: မင်ဂလာ (missing stack)
Correct: ဗုဒ္ဓ (Buddha)          |  Error: ဗုဒ (incomplete)

See Also