A simple spelling tool
Project description
PySpell
PySpell provides functionality for spell checking and sentence correction. It uses a dictionary of words and the Levenshtein distance algorithm to suggest corrections.
Functions
load_dictionary(file_path)
This function loads a dictionary from a text file. Each line in the file should contain a single word.
get_difference(word1, word2)
This function calculates the Levenshtein distance between two words. The Levenshtein distance is a measure of the difference between two sequences of words.
spell_check(word, amount: int, show_distance=False)
This function checks the spelling of a word and suggests corrections. The number of suggestions is determined by the amount parameter. If show_distance is set to True, the function will also return the Levenshtein distance for each suggestion.
correct_word(word)
This function returns the most likely correction for a word.
correct_sentence(sentence)
This function corrects all the words in a sentence and returns the corrected sentence.
Usage
First, load the dictionary:
# Import the library
import pyspell
# Load words from text file
dictionary = pyspell.load_dictionary("words.txt")
# Get top 5 closest words to helo
print(pyspell.spell_check("heelo", 5, dictionary))
# Get top suggestion to helo
print(pyspell.correct_word("heelo", dictionary))
# Correct all words in a sentance
print(pyspell.correct_sentence("heelo wrold", dictionary))
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyspell-0.0.6.tar.gz.
File metadata
- Download URL: pyspell-0.0.6.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e54ad9ab8eb113a970ee801391a0136271808aab724ace39d53fd9ada8c39f7
|
|
| MD5 |
1e9f983eb57c86bf3e21fa98cbf8f958
|
|
| BLAKE2b-256 |
7900b0403af336cb555da30dc33f3f42c1a7b8df8e753d67d9264d87b93224db
|
File details
Details for the file pyspell-0.0.6-py3-none-any.whl.
File metadata
- Download URL: pyspell-0.0.6-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d347120b701c359e1adb6bc25db38cf5eef8b3a0d7d7a45f6b1d679c20da3550
|
|
| MD5 |
a15e423b5d9d0234aabf237f9dd39b51
|
|
| BLAKE2b-256 |
88a54e69682d34f3307cca9f5423ff7c14c3bc64ed25acd8354555df0fa8c465
|