Skip to content

Repository files navigation

SymSpellCppPy

Fast Unicode spelling correction and word segmentation for Python. SymSpellCppPy uses the Symmetric Delete algorithm in C++20 and exposes it through nanobind.

PyPI CI Documentation (latest)

Install

python -m pip install SymSpellCppPy

The project targets CPython 3.10–3.15. The release workflow builds wheels for Linux x86-64 and arm64, Windows x64, and macOS Intel and Apple Silicon. Source builds require CMake 3.26 or newer and a C++20 compiler.

Correct a word

from SymSpellCppPy import SymSpell, Verbosity

spell = SymSpell(max_dictionary_edit_distance=1)
spell.create_dictionary_entry("damen", 42)
spell.create_dictionary_entry("receive", 100)

suggestion, = spell.lookup("dämen", Verbosity.TOP)
print(suggestion.term, suggestion.distance)  # damen 1

suggestion, = spell.lookup("Recieve", Verbosity.TOP, transfer_casing=True)
print(suggestion.term)  # Receive

The package includes English unigram and bigram dictionaries. The runnable quickstart shows how to load them and use word lookup, compound correction, and segmentation. See the usage guides and API reference for custom dictionaries, Unicode, and binary snapshots.

SymSpell compatibility

The compatibility guide tracks the C# reference through SymSpell 6.7.3. It covers the 6.7 segmentation changes, the 6.7.1 dictionary update, and remaining differences with the reference and symspellpy.

Development

python -m pip install -e '.[test,docs]'
python -m pytest
python -m sphinx -W -b html docs/source build/docs
python -m sphinx -W -b doctest docs/source build/doctest

Native tests use Catch2 and CTest.

cmake -S . -B build/native -DBUILD_FOR_TEST=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build/native --config Release
ctest --test-dir build/native -C Release --output-on-failure

Set the release version in pyproject.toml. The installed package exposes the same version as SymSpellCppPy.__version__.

  1. Push a matching tag such as v0.1.0 to build and test the wheels and source distribution. GitHub Actions stores them as artifacts for review.
  2. Publish a GitHub release from that tag. The release run rebuilds and tests the distributions, then uploads them to PyPI.

Benchmarks

See benchmark results and reproduction commands for the comparison with symspellpy and native symspell_rs. Run python benchmark.py to measure the installed extension. The benchmark extra adds symspellpy with the optional editdistpy accelerator.

Acknowledgements