pyspellchecker is a pure Python spell checker based on Peter Norvig's blog post, utilizing a Levenshtein Distance algorithm to find permutations and compare them to a word frequency list. It supports multiple languages including English, Spanish, German, French, Portuguese, Arabic, and Basque. The current version is 0.9.0, and it is actively maintained with updates to support newer Python versions.
pip install pyspellcheckerVerified import paths — ran on the pinned version, not inferred.
Initialize SpellChecker, identify unknown words, and get corrections or candidate spellings.
Upgrade Python to >=3.10 or pin `pyspellchecker` to a compatible version (e.g., `pyspellchecker<0.9.0`).
Ensure that `language` is not set when `case_sensitive=True` or `local_dictionary` is provided.
Initialize `SpellChecker(distance=1)` or set `spell.distance = 1` after instantiation.
Update code to explicitly check for `None` return values from `correction()` and `candidates()` to avoid unexpected `TypeError` or `AttributeError`.
Consider integrating with a contextual spell checker or grammar checker for applications requiring semantic understanding, or build a highly specific custom dictionary for your domain.
pip install pyspellchecker
corrected_words = [spell.correction(word) for word in list_of_words]
spell = SpellChecker(language='en') # Replace 'en' with a supported language like 'es', 'de', 'fr', 'pt', 'ar', 'eu'
from spellchecker import SpellChecker