Skip to main content

Probabilistic Spell Checker in Python

Spell checker based on edit distance (Levenshtein-ish) and word frequency in a training corpus.

For theoretical background, see Peter Norvig's article,

https://norvig.com/spell-correct.html

Comes with a dictionary trained from German Wikipedia articles.

Usage:

import json
import re
import probspellchecker

spellchecker = probspellchecker.ProbabilisticSpellChecker(
    word_counts=json.load(open("dictionary_dewiki_full10plus.json")),
    word_whitelist=["my", "custom", "wordlist"],
)

text = "lorem ipsum whatever"
for word in re.findall(r"\w+", text):
    correction = spellchecker.correction(word.lower())
    if correction:
        print(correction)
    else:
        print(word)

Word counts is just that, a dict with word to count mapping. To build your own dictionaries, see probdict-from-dewiki.py and probdict-from-text.py. You may also specify a whitelist of words that should just be accepted by the spell checker, which is useful if your name is not in the dictionary.

If your language sports special characters like the German umlauts, you might need to pass an additional charset parameter which is a string with all allowed characters of your language, to the ProbabilisticSpellChecker. This is then used to generate candidate words.

Logging

If the logging annoys you, just shut it up:

spell_log = logging.getLogger("probspellchecker")
spell_log.setLevel(logging.ERROR)  # log only errors

Metadata

Release files for probspellchecker 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for probspellchecker 0.1.3
File Size Uploaded Provenance
probspellchecker-0.1.3.tar.gz 4.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for probspellchecker 0.1.3
File Interpreter ABI Platform
probspellchecker-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / probspellchecker-0.1.3.tar.gz

Download URL probspellchecker-0.1.3.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
735c1f46a8457fa9b28eebd878991d6189517ecc05848e833dd8240f160ea9bf
BLAKE2b-256 checksum
How to use checksums
a3d18230e6ee19220a074266fe59db4b1755739e7830c8973fe592e7366d281d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

Release files / probspellchecker-0.1.3-py3-none-any.whl

Download URL probspellchecker-0.1.3-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f497da79cb39d72af0ffdf97065c94425acc356a9442d917f90bb8eed0899029
BLAKE2b-256 checksum
How to use checksums
4637d33a6ad59535a6dece54bc309cd565706b4824d0b28d5a5d5ba2754ab065
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

Security for probspellchecker 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page