Skip to main content
Layer 2 extends syllable validation to handle multi-syllable words, including dictionary lookup, compound validation, OOV recovery, and context-aware ranking.

Overview

Word validation extends syllable validation to handle multi-syllable words. It includes:
  • Dictionary lookup for complete words
  • Compound word validation (SymSpell)
  • Productive reduplication validation (ReduplicationEngine)
  • Compound word synthesis via DP segmentation (CompoundResolver)
  • OOV (Out-of-Vocabulary) recovery via morphological analysis
  • Context-aware suggestion ranking
  • Morpheme-level suggestion correction (MorphemeSuggestionStrategy)
  • Colloquial variant detection

Architecture

WordValidator

Initialization

Factory Method

Basic Usage

Validation Process

Step 1: Word Segmentation

Text is segmented into words using the configured segmenter:

Step 2: Dictionary Lookup

Each word is checked against the word repository:

Step 3: Compound Validation

Words not found directly may be valid compounds:

Step 4: Reduplication Validation

Words not found in the dictionary or via compound check may be productive reduplications of known words:
Supported patterns:
  • AA: Simple repetition (ကောင်းကောင်း “well”)
  • AABB: Each syllable doubles (သေသေချာချာ “carefully”)
  • ABAB: Whole word repeats (ခဏခဏ “frequently”)
  • RHYME: Known rhyme pairs from grammar/patterns.py
Safeguards: base must be in dictionary, frequency >= 5, POS must be V/ADJ/ADV/N.

Step 5: Compound Synthesis

Words not matching any previous check may be valid compounds formed from known dictionary morphemes:
Uses dynamic programming for optimal segmentation. Allowed patterns: N+N, V+V, N+V, V+N, ADJ+N. Blocked patterns: P+P, P+N, N+P. Safeguards: all parts in dictionary, frequency >= 10 per morpheme, max 4 parts.

Step 6: OOV Recovery (Morphology)

For unknown words, attempt morphological analysis:

Step 7: Suggestion Generation

Suggestions are generated via the unified strategy pipeline:

Step 8: Context Ranking

Suggestions are ranked using bidirectional context:

OOV Recovery Details

Morphological Analysis

The morphology module decomposes unknown words:

Enhanced Suggestions

OOV recovery improves suggestion quality:

Colloquial Variant Detection

Configuration

Behavior by Mode

Examples

Interface Segregation

WordValidator uses narrow repository interfaces:

WordRepository Interface

SyllableRepository Interface

This design:
  • Reduces coupling to full DictionaryProvider
  • Makes testing easier with minimal mocks
  • Allows different storage backends

Error Types

WordValidator returns WordError objects:

Error Type Values

Configuration Options

Via SpellCheckerConfig

Usage with SpellChecker

Validation Level

Performance Comparison

See benchmarks for measured performance data.

Suggestion Strategy

Composite Strategy Pipeline

Testing

Unit Test Example

See Also