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.

Complete Error Type Reference

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
PARTICLE_TYPO"particle_typo"1Particle typo
MEDIAL_CONFUSION"medial_confusion"1Medial confusion
COLLOQUIAL_VARIANT"colloquial_variant"2Colloquial (strict)
COLLOQUIAL_INFO"colloquial_info"2Colloquial (lenient)
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
MIXED_REGISTER"mixed_register"2.5Mixed register
ASPECT_TYPO"aspect_typo"2.5Aspect typo
INVALID_SEQUENCE"invalid_sequence"2.5Invalid sequence
INCOMPLETE_ASPECT"incomplete_aspect"2.5Incomplete aspect
TYPO"typo"2.5General typo
AGREEMENT"agreement"2.5Agreement error
COMPOUND_TYPO"compound_typo"2.5Compound typo
INCOMPLETE_REDUPLICATION"incomplete_reduplication"2.5Incomplete reduplication
CLASSIFIER_TYPO"classifier_typo"2.5Classifier typo
ZAWGYI_ENCODING"zawgyi_encoding"1Zawgyi encoding detected

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
set_language("my")

for error in result.errors:
    print(error.get_localized_message())
    # Output: စာလုံးပေါင်း မမှန်ကန်ပါ: 'မျန်' - အကြံပြုချက်များ: မြန်, မျန်း

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