Skip to main content
Without NER, a spell checker flags every unfamiliar proper noun as a misspelling. The NER module provides heuristic, transformer, and hybrid implementations to detect entities and suppress false positives.

Overview

Named entities like personal names and place names often appear as “unknown words” to spell checkers. The NER module helps identify these entities, preventing the spell checker from flagging them as errors. Entity Types Supported:
  • PER - Personal names (e.g., ကိုအောင်)
  • LOC - Locations (e.g., ရန်ကုန်မြို့)
  • ORG - Organizations (e.g., မြန်မာ့လေကြောင်း)
  • DATE - Date expressions
  • NUM - Numbers and numeric expressions
  • TIME - Time expressions
  • MISC - Miscellaneous named entities
  • OTHER - Not an entity (used internally for BIO tag “O”)

NER Implementations

mySpellChecker provides three NER implementations with different accuracy/speed trade-offs:

HeuristicNER

Fast, rule-based NER using patterns and whitelists. Ideal for real-time applications. Features:
  • Honorific-based name detection (ဦး, ဒေါ်, ကို, မ)
  • Location suffix detection (မြို့, ရွာ, ပြည်နယ်)
  • Organization pattern matching (ကုမ္ပဏီ, ဘဏ်, တက္ကသိုလ်)
  • Whitelist support for known entities
  • No external dependencies

TransformerNER

High-accuracy NER using HuggingFace transformer models. Features:
  • State-of-the-art accuracy (~93%)
  • BIO tagging for multi-word entities
  • Confidence scores for each prediction
  • Batch processing support
  • LRU result caching for performance
Requirements:

HybridNER

Combines transformer and heuristic approaches. Uses the transformer as primary, with automatic fallback to heuristics. Features:
  • Best of both approaches
  • Graceful degradation if transformer unavailable
  • Automatic fallback on transformer errors
  • Configurable fallback behavior

NER Gazetteer

In addition to the heuristic and transformer implementations, mySpellChecker includes a curated NER gazetteer — a YAML-based dictionary of known named entities loaded from rules/named_entities.yaml. The gazetteer provides fast O(1) lookup without any ML dependencies.

Entity Categories

The gazetteer covers five categories with 373+ entities:

Gazetteer API

SQLite NER Schema

When building dictionaries, the enrichment pipeline (Step 5e) seeds NER entities into the database via the ner_entities table. This enables runtime entity lookup without loading the YAML file.

False Positive Suppression

The gazetteer integrates with error_suppression.py to automatically suppress spell check errors on recognized named entities. This prevents proper nouns, place names, and organization names from being flagged as misspellings.

Integration with SpellChecker

NER is fully integrated into the SpellChecker pipeline. When enabled, the NER model:
  1. Provides name masks to the ContextValidator (for strategies to skip named entities)
  2. Filters errors post-validation, removing any error that overlaps a detected entity

Basic Usage (Heuristic NER)

With Transformer NER

For highest accuracy, configure NERConfig with a transformer model:

CLI Usage

Disabling NER

NERConfig Options

Entity Data Structure

The Entity dataclass represents detected entities:

Advanced Usage

Batch Processing

Process multiple texts efficiently:

Custom Whitelist

Add known names to reduce false negatives:

Performance Tips

  1. Real-time typing: Use HeuristicNER for fastest response
  2. Document checking: Use HybridNER for balance
  3. Batch processing: Use TransformerNER with batching
  4. High throughput: Enable result caching

See Also