Skip to main content
Each error detected by the validation pipeline carries a string error_type that identifies the category of issue. Use these codes to filter, route, or display errors differently in your application.

Overview

mySpellChecker uses an ErrorType enum to categorize detected errors. Each error type is a string value that describes the nature of the spelling or grammar issue.

Error Type Format

Error types are string constants defined in myspellchecker.core.constants.ErrorType. Use them for filtering and handling specific error categories:
from myspellchecker.core.constants import ErrorType

# Check for specific error types
if error.error_type == ErrorType.SYLLABLE.value:
    print("Invalid syllable detected")

Core Error Types

invalid_syllable

Enum: ErrorType.SYLLABLE Layer: Syllable (Layer 1) The syllable does not follow valid Myanmar syllable structure rules or is not found in the syllable dictionary.
result = checker.check("ကွြ")  # Wrong medial order
for error in result.errors:
    if error.error_type == "invalid_syllable":
        print(f"Invalid syllable: {error.text}")
        print(f"Suggestions: {error.suggestions}")
Common Causes:
  • Incorrect medial ordering (ွ before ြ)
  • Missing consonant at start
  • Invalid character combinations
  • Unknown syllable not in dictionary

invalid_word

Enum: ErrorType.WORD Layer: Word (Layer 2) The word is not found in the dictionary, though its syllables may be individually valid.
result = checker.check("မယ်နမာ")
for error in result.errors:
    if error.error_type == "invalid_word":
        print(f"Invalid word: {error.text}")
        print(f"Suggestions: {error.suggestions}")
        # WordError has syllable_count attribute
        if hasattr(error, 'syllable_count'):
            print(f"Syllable count: {error.syllable_count}")

grammar_error

Enum: ErrorType.GRAMMAR Layer: Grammar (Layer 2.5) General grammar rule violation detected by the grammar checking system.
for error in result.errors:
    if error.error_type == "grammar_error":
        print(f"Grammar error: {error.text}")
        # GrammarError has reason attribute
        if hasattr(error, 'reason'):
            print(f"Reason: {error.reason}")

Context Error Types

context_probability

Enum: ErrorType.CONTEXT_PROBABILITY Layer: Context (Layer 3) The word sequence has unusually low N-gram probability, indicating an unlikely or nonsensical combination.
result = checker.check("ထမင်းသွား")  # rice go (nonsensical)
for error in result.errors:
    if error.error_type == "context_probability":
        print(f"Context error: {error.text}")
        # ContextError has probability and prev_word attributes
        print(f"Probability: {error.probability}")
        print(f"Previous word: {error.prev_word}")

semantic_error

Enum: ErrorType.SEMANTIC_ERROR Layer: Context (Layer 3) Semantic validation failure detected by the semantic checker (requires AI model).

Specific Error Types

particle_typo

Enum: ErrorType.PARTICLE_TYPO Known particle typo pattern detected (e.g., တယ → တယ်).
for error in result.errors:
    if error.error_type == "particle_typo":
        print(f"Particle typo: {error.text}{error.suggestions[0]}")

medial_confusion

Enum: ErrorType.MEDIAL_CONFUSION Likely confusion between similar-looking medials (ျ Ya-yit vs ြ Ya-pin).
result = checker.check("ကျြောင်")
for error in result.errors:
    if error.error_type == "medial_confusion":
        print(f"Medial confusion: {error.text}")
        print(f"Suggestions: {error.suggestions}")
        # Suggestions: ["ကြောင်", "ကျောင်း"]

colloquial_variant

Enum: ErrorType.COLLOQUIAL_VARIANT Colloquial (informal) spelling detected in strict mode.
# In strict mode, colloquial forms are flagged as errors
for error in result.errors:
    if error.error_type == "colloquial_variant":
        print(f"Colloquial: {error.text}")
        print(f"Standard form: {error.suggestions}")

colloquial_info

Enum: ErrorType.COLLOQUIAL_INFO Colloquial spelling detected in lenient mode (informational note, not an error).

question_structure

Enum: ErrorType.QUESTION_STRUCTURE Question structure error detected (e.g., missing question particle).

syntax_error

Enum: ErrorType.SYNTAX_ERROR General syntactic error detected by validation strategies.

homophone_error

Enum: ErrorType.HOMOPHONE_ERROR Homophone-related error - words that sound alike but have different spellings.

tone_ambiguity

Enum: ErrorType.TONE_AMBIGUITY Ambiguous tone mark usage detected.

pos_sequence_error

Enum: ErrorType.POS_SEQUENCE_ERROR Invalid Part-of-Speech sequence detected (e.g., verb directly followed by verb without particle).

Grammar Checker Error Types

These error types are returned by specific grammar checkers:

mixed_register

Enum: ErrorType.MIXED_REGISTER Mixed formal/informal register detected (e.g., formal and colloquial forms mixed).

aspect_typo

Enum: ErrorType.ASPECT_TYPO Aspect marker typo detected (e.g., ပြီ, ခဲ့, နေ).

invalid_sequence

Enum: ErrorType.INVALID_SEQUENCE Invalid character sequence detected.

incomplete_aspect

Enum: ErrorType.INCOMPLETE_ASPECT Incomplete aspect marking detected.

typo

Enum: ErrorType.TYPO General typo detected by grammar rules.

agreement

Enum: ErrorType.AGREEMENT Agreement error (e.g., subject-verb agreement).

compound_typo

Enum: ErrorType.COMPOUND_TYPO Compound word typo detected.

incomplete_reduplication

Enum: ErrorType.INCOMPLETE_REDUPLICATION Incomplete reduplication pattern detected.

classifier_typo

Enum: ErrorType.CLASSIFIER_TYPO Classifier typo detected (e.g., ယေက် → ယောက်).

zawgyi_encoding

Enum: ErrorType.ZAWGYI_ENCODING Zawgyi encoding detected in the input text. The text should be converted to Unicode before spell checking.

Text-Level Detector Error Types

These error types are detected at the text level by the spell checker’s built-in detectors:

colloquial_contraction

Enum: ErrorType.COLLOQUIAL_CONTRACTION Colloquial contraction detected (informal shortening of words).

particle_confusion

Enum: ErrorType.PARTICLE_CONFUSION Particle confusion detected (wrong particle used in context).

ha_htoe_confusion

Enum: ErrorType.HA_HTOE_CONFUSION Ha-htoe (ှ) confusion detected (incorrect use of the aspirated ha-htoe marker).

dangling_particle

Enum: ErrorType.DANGLING_PARTICLE Dangling particle detected (particle without an associated content word).

dangling_word

Enum: ErrorType.DANGLING_WORD Dangling word detected (content word missing required particle or connector).

missing_conjunction

Enum: ErrorType.MISSING_CONJUNCTION Missing conjunction detected between clauses.

tense_mismatch

Enum: ErrorType.TENSE_MISMATCH Tense mismatch detected (inconsistent tense markers within a sentence).

register_mixing

Enum: ErrorType.REGISTER_MIXING Register mixing detected (formal and informal forms mixed inappropriately).

Grammar Checker Class-Level Error Types

These error types are returned by specific grammar checker classes:

negation_error

Enum: ErrorType.NEGATION_ERROR Negation structure error detected (incorrect negation pattern).

register_error

Enum: ErrorType.REGISTER_ERROR Register error detected (incorrect register usage for context).

merged_word

Enum: ErrorType.MERGED_WORD Merged word detected (two words incorrectly written as one).

aspect_error

Enum: ErrorType.ASPECT_ERROR Aspect marker error detected (incorrect aspect marking on verb).

classifier_error

Enum: ErrorType.CLASSIFIER_ERROR Classifier error detected (incorrect classifier used with noun).

compound_error

Enum: ErrorType.COMPOUND_ERROR Compound word error detected (incorrect compound word formation).

Orthography Error Types

These error types relate to Myanmar script orthography violations:

medial_order_error

Enum: ErrorType.MEDIAL_ORDER_ERROR Medial consonants are in the wrong order (e.g., ွ before ြ instead of ြ before ွ).

medial_compatibility_error

Enum: ErrorType.MEDIAL_COMPATIBILITY_ERROR Incompatible medial consonant combination detected.

vowel_after_asat

Enum: ErrorType.VOWEL_AFTER_ASAT Vowel sign placed after asat (virama), which is invalid in Myanmar script.

broken_virama

Enum: ErrorType.BROKEN_VIRAMA Broken virama (stacking marker) detected.

broken_stacking

Enum: ErrorType.BROKEN_STACKING Asat used instead of virama before a stacked consonant.

broken_compound

Enum: ErrorType.BROKEN_COMPOUND Compound word incorrectly split into separate parts.

leading_vowel_e

Enum: ErrorType.LEADING_VOWEL_E Zawgyi-style leading vowel-e (ေ) placed before consonant instead of after.

incomplete_stacking

Enum: ErrorType.INCOMPLETE_STACKING Virama is present but the expected stacked consonant is missing.

Syntactic/Semantic Error Types

confusable_error

Enum: ErrorType.CONFUSABLE_ERROR Confusable variant detected (a valid word used in the wrong context, e.g., homophones or near-homophones).

negation_sfp_mismatch

Enum: ErrorType.NEGATION_SFP_MISMATCH Negation with wrong sentence-final particle (e.g., using affirmative တယ် instead of ဘူး after negation prefix မ-).

merged_sfp_conjunction

Enum: ErrorType.MERGED_SFP_CONJUNCTION Sentence-final particle incorrectly merged with a conjunction (e.g., တယ်ပြီး instead of ပြီး).

aspect_adverb_conflict

Enum: ErrorType.ASPECT_ADVERB_CONFLICT Aspect-adverb conflict detected (e.g., habitual adverb used with specific-past marker).

Punctuation Error Types

duplicate_punctuation

Enum: ErrorType.DUPLICATE_PUNCTUATION Duplicate punctuation mark detected.

wrong_punctuation

Enum: ErrorType.WRONG_PUNCTUATION Wrong punctuation mark used.

missing_punctuation

Enum: ErrorType.MISSING_PUNCTUATION Missing required punctuation mark.

Additional Detection Errors

missing_asat

Enum: ErrorType.MISSING_ASAT Missing asat (virama) mark on a syllable that requires one.

particle_misuse

Enum: ErrorType.PARTICLE_MISUSE Semantically wrong particle usage detected via context analysis.

collocation_error

Enum: ErrorType.COLLOCATION_ERROR Wrong word partner in a fixed phrase or collocation.

Complete Error Type Reference

Core Errors

Enum ConstantString ValueLayerDescription
SYLLABLE"invalid_syllable"1Invalid syllable structure
WORD"invalid_word"2Invalid word
GRAMMAR"grammar_error"2.5Grammar rule violation
CONTEXT_PROBABILITY"context_probability"3Low N-gram probability
SEMANTIC_ERROR"semantic_error"3Semantic validation failure

Specific Validator Errors

Enum ConstantString ValueLayerDescription
PARTICLE_TYPO"particle_typo"1Particle typo
MEDIAL_CONFUSION"medial_confusion"1Medial confusion
COLLOQUIAL_VARIANT"colloquial_variant"2Colloquial form (strict mode)
COLLOQUIAL_INFO"colloquial_info"2Colloquial form (lenient mode, informational)

Validation Strategy Errors

Enum ConstantString ValueLayerDescription
QUESTION_STRUCTURE"question_structure"2.5Question structure error
SYNTAX_ERROR"syntax_error"2.5Syntax error
HOMOPHONE_ERROR"homophone_error"2.5Homophone error
TONE_AMBIGUITY"tone_ambiguity"2.5Tone ambiguity
POS_SEQUENCE_ERROR"pos_sequence_error"2.5Invalid POS sequence

Encoding Errors

Enum ConstantString ValueLayerDescription
ZAWGYI_ENCODING"zawgyi_encoding"1Zawgyi encoding detected

Grammar Checker Errors

Enum ConstantString ValueLayerDescription
MIXED_REGISTER"mixed_register"2.5Mixed register
ASPECT_TYPO"aspect_typo"2.5Aspect marker typo
INVALID_SEQUENCE"invalid_sequence"2.5Invalid character sequence
INCOMPLETE_ASPECT"incomplete_aspect"2.5Incomplete aspect marking
TYPO"typo"2.5General typo
AGREEMENT"agreement"2.5Agreement error
COMPOUND_TYPO"compound_typo"2.5Compound word typo
INCOMPLETE_REDUPLICATION"incomplete_reduplication"2.5Incomplete reduplication
CLASSIFIER_TYPO"classifier_typo"2.5Classifier typo

Text-Level Detector Errors

Enum ConstantString ValueLayerDescription
COLLOQUIAL_CONTRACTION"colloquial_contraction"2Colloquial contraction
PARTICLE_CONFUSION"particle_confusion"2.5Particle confusion
HA_HTOE_CONFUSION"ha_htoe_confusion"2.5Ha-htoe confusion
DANGLING_PARTICLE"dangling_particle"2.5Dangling particle
DANGLING_WORD"dangling_word"2.5Dangling word
MISSING_CONJUNCTION"missing_conjunction"2.5Missing conjunction
TENSE_MISMATCH"tense_mismatch"2.5Tense mismatch
REGISTER_MIXING"register_mixing"2.5Register mixing

Grammar Checker Class-Level Errors

Enum ConstantString ValueLayerDescription
NEGATION_ERROR"negation_error"2.5Negation structure error
REGISTER_ERROR"register_error"2.5Register error
MERGED_WORD"merged_word"2.5Merged word error
ASPECT_ERROR"aspect_error"2.5Aspect marker error
CLASSIFIER_ERROR"classifier_error"2.5Classifier error
COMPOUND_ERROR"compound_error"2.5Compound word error

Orthography Errors

Enum ConstantString ValueLayerDescription
MEDIAL_ORDER_ERROR"medial_order_error"1Medial consonants in wrong order
MEDIAL_COMPATIBILITY_ERROR"medial_compatibility_error"1Incompatible medial combination
VOWEL_AFTER_ASAT"vowel_after_asat"1Vowel sign after asat
BROKEN_VIRAMA"broken_virama"1Broken virama
BROKEN_STACKING"broken_stacking"1Asat instead of virama before stacked consonant
BROKEN_COMPOUND"broken_compound"2Wrongly split compound word
LEADING_VOWEL_E"leading_vowel_e"1Zawgyi-style leading vowel-e
INCOMPLETE_STACKING"incomplete_stacking"1Virama present but stacked consonant missing

Syntactic/Semantic Errors

Enum ConstantString ValueLayerDescription
CONFUSABLE_ERROR"confusable_error"2.5Valid word, wrong in context
NEGATION_SFP_MISMATCH"negation_sfp_mismatch"2.5Negation with wrong sentence-final particle
MERGED_SFP_CONJUNCTION"merged_sfp_conjunction"2.5Merged sentence-final particle with conjunction
ASPECT_ADVERB_CONFLICT"aspect_adverb_conflict"2.5Aspect-adverb conflict

Punctuation Errors

Enum ConstantString ValueLayerDescription
DUPLICATE_PUNCTUATION"duplicate_punctuation"2.5Duplicate punctuation
WRONG_PUNCTUATION"wrong_punctuation"2.5Wrong punctuation mark
MISSING_PUNCTUATION"missing_punctuation"2.5Missing punctuation

AI Detection

Enum ConstantString ValueLayerDescription
MISSING_ASAT"missing_asat"1Missing asat/virama mark
PARTICLE_MISUSE"particle_misuse"2.5Semantically wrong particle
COLLOCATION_ERROR"collocation_error"3Wrong word in fixed phrase

Working with Errors

Checking for Errors

from myspellchecker.core.constants import ErrorType

result = checker.check(text)

if result.has_errors:
    for error in result.errors:
        print(f"Type: {error.error_type}")
        print(f"Text: {error.text}")
        print(f"Position: {error.position}")
        print(f"Suggestions: {error.suggestions}")
        print(f"Confidence: {error.confidence}")

Filtering by Error Type

from myspellchecker.core.constants import ErrorType

# Get only syllable errors
syllable_errors = [e for e in result.errors if e.error_type == ErrorType.SYLLABLE.value]

# Get only context errors
context_errors = [e for e in result.errors if e.error_type == ErrorType.CONTEXT_PROBABILITY.value]

# Get all grammar-related errors
grammar_types = {
    ErrorType.GRAMMAR.value,
    ErrorType.PARTICLE_TYPO.value,
    ErrorType.POS_SEQUENCE_ERROR.value,
    ErrorType.ASPECT_TYPO.value,
}
grammar_errors = [e for e in result.errors if e.error_type in grammar_types]

Localized Error Messages

from myspellchecker.core.i18n import set_language

# Switch to Myanmar language for error messages
set_language("my")

# Error objects provide to_dict() and to_json() for serialization
for error in result.errors:
    print(error.to_dict())
    # {"text": "မျန်", "error_type": "invalid_syllable", "suggestions": ["မြန်", "မျန်း"], ...}

Error Class Hierarchy

from myspellchecker.core.response import (
    Error,          # Base class
    SyllableError,  # Layer 1 errors
    WordError,      # Layer 2 errors (has syllable_count)
    ContextError,   # Layer 3 errors (has probability, prev_word)
    GrammarError,   # Grammar errors (has reason)
)

# Check error class
if isinstance(error, SyllableError):
    print("Syllable-level error")
elif isinstance(error, WordError):
    print(f"Word error with {error.syllable_count} syllables")
elif isinstance(error, ContextError):
    print(f"Context error: P={error.probability}, prev={error.prev_word}")
elif isinstance(error, GrammarError):
    print(f"Grammar error: {error.reason}")

Next Steps