Skip to main content

A hopefully cross-platform reimplementation of Peter Norvig's spelling corrector.

Project description

spellcheckmate

License Python

description

A hopefully cross-platform reimplementation of Peter Norvig's spelling corrector with minor modifications. Checking for spelling and/or grammar mistakes by calling the .check(text) method of the SpellCheckMate() class enables users to interactively correct their mistakes sentence by sentence. Correct a single word by calling .correct(word) and get a list of all the alternative corrections by calling .alternatives(word) or print them out directly by .print_alternatives(word).

usage

from spellcheckmate import SpellCheckMate

spell_check = SpellCheckMate()

word = "somthign"
corrected_word = spell_check.correct(word)
""" the words 'somthign' and the correct 'something' are 1 character deletion and 1 transposed character away from each other. """
print(corrected_word) # prints the correct version, 'something'

word = "smthign"
corrected_word = spell_check.correct(word)
"""this is a limitation of the library, since it won't search for words of which Damerau–Levenshtein distance is greater than 2. """
print(corrected_word) # prints '404', since 'smthign' and 'something' are more than 2 edits away from each other.

word = "aie"
word_alternatives = spell_check.alternatives(word)
print(word_alternatives) # prints ['ave', 'amie', 'ate', 'ale', 'die', 'tie', 'ai', 'aye', 'are', ... ]
spell_check.print_alternatives(word)
"""
ave
amie
ate
ale
die
tie
ai
aye
are
...
"""

text = "We lov everithin. Or smthign like that."
""" parses text interactively sentence by sentence and points to mistyped word after which user can select from recommendations
or type correct version if not found in recommendations. """
corrected_text = spell_check.check(text)

"""
we lov everithin
   ^
low
lot
log
love
lo
nov
sov
los
loi
> love
we lov everithin
       ^
everything
> everything
we lov everithin
we love everything 
 or smthign like that
    ^
404
> something
 or smthign like that
or something like that 
"""

installation

pip install spellcheckmate

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spellcheckmate-0.1.4.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

spellcheckmate-0.1.4-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file spellcheckmate-0.1.4.tar.gz.

File metadata

  • Download URL: spellcheckmate-0.1.4.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-17-generic

File hashes

Hashes for spellcheckmate-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c6075aba9d15218996e44a4afca0a0720bef3635d66d2d7966483ed91c454c54
MD5 e655af8928fb0180fb7e12b120fa2a71
BLAKE2b-256 8d274b82c3f1cd458b22cd34352f8de7a5c64f34ca7d427a40ddef9c5969a947

See more details on using hashes here.

File details

Details for the file spellcheckmate-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: spellcheckmate-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-17-generic

File hashes

Hashes for spellcheckmate-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b2c5e81e4e2fd874f4881f99b2203228acdd83548944f776865abfa90056b693
MD5 325ed58032ff831eab6ea8d2196214a0
BLAKE2b-256 d43f0ea94504feb8d3a108f56ed4f2867df054594c1a8edf50e61c1eba6a3dc5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page