Skip to main content
All settings are managed through Pydantic models with type safety, validation, and sensible defaults. You can configure everything from edit distance thresholds to AI model paths.

Configuration Overview

Configuration is handled through Pydantic models that provide type safety and defaults:

Quick Reference

SpellCheckerConfig

The main configuration class:

Validation Level

Controls the depth of validation. Specified per-check, not in configuration:

Suggestion Settings

Control how suggestions are generated:

Context Settings

Configure N-gram context checking via NgramContextConfig:

Performance Settings

Optimize for your use case via AlgorithmCacheConfig:

POSTaggerConfig

Configure the Part-of-Speech tagger:

POSTaggerConfig Options

SemanticConfig

Configure the semantic (AI) checker:

Pre-loaded Models

You can also pass pre-loaded model instances:

ValidationConfig

Configure error detection thresholds, confidence scores, and validation behavior:

Colloquial Variant Handling

Control how informal/colloquial spellings are handled:

Extended Myanmar Support

Enable support for non-Burmese Myanmar scripts (Shan, Mon, Karen, etc.):
Note: By default, mySpellChecker only validates standard Burmese text. Extended Myanmar blocks (U+AA60-AA7F, U+A9E0-A9FF) are for other Myanmar-script languages.

Configuration Profiles

Built-in profiles for common scenarios using get_profile():

Environment Variables

Configuration can be set via environment variables with the MYSPELL_ prefix:
Load from environment:

Configuration File

Configuration can be defined programmatically. Here’s an example of a comprehensive configuration:

Provider Configuration

Configure the dictionary provider:

SQLiteProvider Options

MemoryProvider Options

Logging Configuration

Configure logging output:

Complete Example

File-Based Configuration (ConfigLoader)

The ConfigLoader class loads configuration from multiple sources with a clear precedence chain. The load_config() convenience function provides a simpler interface.

Precedence Chain

Configuration sources are merged in this order (highest precedence last):
  1. Profile defaults — built-in presets (fast, production, accurate, development, testing)
  2. Configuration file — YAML or JSON file
  3. Environment variablesMYSPELL_* prefixed variables
  4. Programmatic overrides — keyword arguments (highest precedence)

Config File Discovery

When no explicit path is provided, the loader searches for config files in this order:
  1. Current working directory: myspellchecker.yaml, myspellchecker.yml, myspellchecker.json
  2. User config directory: ~/.config/myspellchecker/myspellchecker.yaml

YAML Schema

Config files support two special keys (preset and database) alongside standard SpellCheckerConfig fields:

Usage Examples

Initialize a Config File

Generate a default config file with init_config_file():
YAML config files require PyYAML (pip install pyyaml). JSON files work without additional dependencies.

Next Steps