Skip to main content
Practical guides for using and extending mySpellChecker.

Getting Started

If you’re new to mySpellChecker, start here:
  1. Installation - Install the library
  2. Quick Start - Basic usage
  3. Configuration - Configure settings

System Requirements

RequirementMinimumRecommended
Python3.10+3.11+
RAM256 MB1 GB+
Disk Space100 MB500 MB
OSLinux, macOS, WindowsLinux, macOS
Optional FeatureRequirement
Cython ExtensionsC++ compiler (gcc, clang, MSVC)
OpenMP Parallelizationlibomp (macOS: brew install libomp)
Transformer POS TaggerPyTorch, transformers package
Semantic CheckingONNX Runtime

Usage Guides

Core Functionality

  • Custom Dictionaries - Build and use custom dictionaries
  • Batch Processing - Use checker.check_batch(texts) for efficient multi-text processing (see Quick Start)

Deployment

  • Docker - Run with Docker and Docker Compose

Configuration & Customization

Performance & Optimization

Integration & Deployment

Advanced Topics

Feature Guides

Detailed guides for specific features:
FeatureGuideDescription
Syllable ValidationLinkFirst-level validation
Word ValidationLinkDictionary-based checking
Grammar CheckingLinkPOS and grammar rules
Context CheckingLinkN-gram analysis
SuggestionsLinkSpelling suggestions

Development Guides

For developers extending or contributing:

Quick Reference

Common Tasks

TaskCommand/Code
Check textchecker.check("text")
Batch checkchecker.check_batch(["text1", "text2"])
Build dictionarymyspellchecker build --input corpus.txt
Enable debugconfigure_logging(level="DEBUG")

Configuration Presets

from myspellchecker import SpellChecker
from myspellchecker.core.config import SpellCheckerConfig, POSTaggerConfig
from myspellchecker.core.constants import ValidationLevel
from myspellchecker.providers import SQLiteProvider

# Fast checking (syllable only) - level specified per-check
provider = SQLiteProvider(database_path="path/to/dictionary.db")
checker = SpellChecker(provider=provider)
result = checker.check(text, level=ValidationLevel.SYLLABLE)

# Thorough checking (all layers)
config = SpellCheckerConfig(
    use_context_checker=True,
    use_rule_based_validation=True,
)
checker = SpellChecker(config=config)
result = checker.check(text, level=ValidationLevel.WORD)

# Memory efficient
config = SpellCheckerConfig(
    semantic=None,  # Disable semantic checking
    pos_tagger=POSTaggerConfig(tagger_type="rule_based"),
)

Tutorials

Step-by-step tutorials for common use cases:

1. Basic Spell Checking

from myspellchecker import SpellChecker
from myspellchecker.providers import SQLiteProvider

# Create checker (requires a built dictionary database)
provider = SQLiteProvider(database_path="path/to/dictionary.db")
checker = SpellChecker(provider=provider)

# Check text
result = checker.check("မြန်မာစာ")

# Handle errors
if result.has_errors:
    for error in result.errors:
        print(f"{error.text}: {error.suggestions}")

2. Building a Custom Dictionary

# Prepare corpus file (UTF-8 Myanmar text)
echo "မြန်မာနိုင်ငံ" > corpus.txt
echo "ကျေးဇူးတင်ပါသည်" >> corpus.txt

# Build dictionary
myspellchecker build --input corpus.txt --output custom.db

# Use custom dictionary
python -c "
from myspellchecker import SpellChecker
from myspellchecker.providers import SQLiteProvider
provider = SQLiteProvider(database_path='custom.db')
checker = SpellChecker(provider=provider)
print(checker.check('မြန်မာ'))
"

3. Web API Integration

from flask import Flask, request, jsonify
from myspellchecker import SpellChecker
from myspellchecker.providers import SQLiteProvider

app = Flask(__name__)
provider = SQLiteProvider(database_path="path/to/dictionary.db")
checker = SpellChecker(provider=provider)

@app.route('/check', methods=['POST'])
def check_spelling():
    text = request.json.get('text', '')
    result = checker.check(text)
    return jsonify({
        'has_errors': result.has_errors,
        'errors': [
            {
                'text': e.text,
                'position': e.position,
                'suggestions': e.suggestions,
            }
            for e in result.errors
        ]
    })

if __name__ == '__main__':
    app.run(debug=True)

Best Practices

Performance

  1. Warm up the checker before production use
  2. Use batch processing for multiple texts
  3. Choose appropriate validation level for your use case
  4. Enable Cython extensions for best performance

Accuracy

  1. Build domain-specific dictionaries from relevant corpora
  2. Enable context validation for real-word error detection
  3. Use grammar checking for formal text
  4. Normalize input before checking

Integration

  1. Handle errors gracefully with try/except
  2. Log warnings and errors for debugging
  3. Cache SpellChecker instances (they’re expensive to create)
  4. Use connection pooling for SQLite in multi-threaded apps

See Also