A Cython reimplementation of Peter Norvig's spelling corrector.
Project description
spellcheckmate
description
A Cython 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)
.
installation
pip install spellcheckmate
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
"""
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.1.tar.gz
(2.4 MB
view hashes)
Built Distribution
Close
Hashes for spellcheckmate-0.1.1-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4b0d22863cc35ab2d6d468c7315d3ccf87018873330d9d5e185ede2fab42b75 |
|
MD5 | 74a77be9daab7e38b7fe59be229520da |
|
BLAKE2b-256 | da05b73eb1ed9c363e2aaaaafe7e2e3e60a45f6593e597672f183e8d1dd0fa90 |