Skip to main content
Traditional spell checking compares an input word against every dictionary entry, which is far too slow for real-time use. SymSpell avoids this by pre-computing delete variants at build time, turning each lookup into a constant-time hash table hit. This page walks through the algorithm with Myanmar language examples.

The Problem: Traditional Edit Distance

Traditional spell checking calculates the Levenshtein edit distance between an input word and every word in the dictionary:
Problem: This is O(N × M) where N = dictionary size, M = word length. For a 100,000-word dictionary, this means 100,000 comparisons per lookup.

The Solution: Symmetric Delete

SymSpell’s key insight: Instead of comparing words directly, pre-compute all possible deletions.

Why “Symmetric”?

If we delete characters from both the dictionary word AND the misspelled word, they’ll meet in the middle:
Both reach the same intermediate form through deletions!

How It Works

1

Indexing (Build Time)

For each word in the dictionary, generate all possible deletions up to max_edit_distance (typically 2):
Store in hash map:
2

Lookup (Query Time)

When checking a misspelled word, generate its deletions too:
3

Match

Look up each deletion in the pre-built index:
Result: Found candidate “မြန်မာ” in O(1) hash lookup!

Visual Example: Syllable Correction

Visual Example: Word Correction

Myanmar-Specific Considerations

Character Clusters

Myanmar characters often form clusters (consonant + medials + vowels). SymSpell treats each Unicode code point as a unit:

Common Myanmar Typos SymSpell Catches

Syllable vs Word Level

mySpellChecker applies SymSpell at two levels: 1. Syllable Level (faster, catches 90% of errors):
2. Word Level (slower, for complex errors):

Performance Characteristics

Time Complexity

Where:
  • V = vocabulary size
  • L = average term length
  • d = max edit distance

Space Complexity

SymSpell trades memory for speed:

Benchmark: Myanmar Dictionary

Source docstring notes: “Typical Myanmar corpus (100K terms, d=2): ~50-100MB index.” Memory grows with max_edit_distance — values above 2 cause exponential growth.

Configuration

SpellCheckerConfig Options

Edit Distance Guidelines

Prefix Length

The prefix_length parameter optimizes memory by only indexing the first N characters:

Implementation Details

Index Structure

Lookup Algorithm

Suggestion Dataclass

Each suggestion returned by lookup() includes:

Additional Methods

Comparison with Other Algorithms

SymSpell is the fastest for dictionary-based spell checking, making it ideal for real-time applications.

See Also