SymSpellPy is a Python port of the SymSpell spelling corrector, designed for high performance and low memory consumption. It provides fast fuzzy search and spell correction capabilities, capable of handling large dictionaries. The library is actively maintained, with a recent major release (v6.x) and a consistent release cadence addressing new features, bug fixes, and performance improvements.
pip install symspellpyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize SymSpell, manually create dictionary entries, and perform basic spell correction for single words and compound phrases. In a production environment, dictionaries are typically loaded from text files using `sym_spell.load_dictionary()`.
Upgrade your Python interpreter to version 3.9 or newer. Consider using a virtual environment to manage Python versions.
Ensure all frequency counts in your dictionary data are parsed and stored as 64-bit integers before being passed to SymSpellPy.
Review any custom distance comparer implementations or direct calls to distance calculation methods and adjust argument names if they use `string1` or `string2`.
Explicitly configure `symspellpy`'s logger using `logging.getLogger('symspellpy')` if you need to control its output, or ensure your root logger is configured independently.Always use `ignore_non_words=True` in conjunction with `ignore_term_with_digits=True` to ensure proper behavior.
pip install symspellpy
Ensure the dictionary file exists and provide the correct absolute or relative path to it in your code, e.g., `sym_spell.load_dictionary("path/to/frequency_dictionary_en_82_765.txt", 0, 1)`.Configure the `distance_algorithm` (and other related parameters like `max_dictionary_edit_distance`, `prefix_length`) when creating the `SymSpell` object, e.g., `from symspellpy import SymSpell, DistanceAlgorithm sym_spell = SymSpell(max_dictionary_edit_distance=2, prefix_length=7, distance_algorithm=DistanceAlgorithm.DAMERAU_LEVENSHTEIN)`.
Provide an integer value for `max_dictionary_edit_distance` when instantiating `SymSpell`, for example: `from symspellpy import SymSpell sym_spell = SymSpell(max_dictionary_edit_distance=2)`.