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 viaNgramContextConfig:
Performance Settings
Optimize for your use case viaAlgorithmCacheConfig:
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.):Configuration Profiles
Built-in profiles for common scenarios usingget_profile():
Environment Variables
Configuration can be set via environment variables with theMYSPELL_ prefix:
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)
TheConfigLoader 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):- Profile defaults — built-in presets (
fast,production,accurate,development,testing) - Configuration file — YAML or JSON file
- Environment variables —
MYSPELL_*prefixed variables - Programmatic overrides — keyword arguments (highest precedence)
Config File Discovery
When no explicit path is provided, the loader searches for config files in this order:- Current working directory:
myspellchecker.yaml,myspellchecker.yml,myspellchecker.json - 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 withinit_config_file():
YAML config files require PyYAML (
pip install pyyaml). JSON files work without additional dependencies.Next Steps
- API Reference - Complete API documentation
- Performance Tuning - Optimization guide
- CLI Reference - Command-line options