No project description provided
Project description
simple_spell_checker
Simple Spell Checker is a spell checker based on prefix tree search. It find nearest to input word from known words (from input list). The algorithm finds mistakes in a word (insertions, deletions, replacements).
Installation
pip install simple_spell_checker
Quickstart
from simple_spell_checker.spell_checker import SpellChecker
cities = [
"Kyiv", "Kharkiv", "Odesa", "Dnipro", "Donetsk", "Zaporizhzhia", "Lviv",
"Kryvyi Rih", "Mykolaiv", "Luhansk", "Vinnytsia", "Simferopol", "Chernihiv",
"Kherson", "Poltava", "Khmelnytskyi", "Cherkasy", "Chernivtsi", "Zhytomyr", "Sumy",
"Rivne", "Ivano-Frankivsk", "Ternopil", "Kropyvnytskyi", "Lutsk", "Uzhhorod"
]
spell_checker = SpellChecker(max_mistakes_number_part=.5)
spell_checker.add_words(cities)
spell_checker.correction('Kiev')
# [{'word': 'Kyiv',
# 'corrections': [{'mistake_type': 'missing symbol "y"', 'position': 1},
# {'mistake_type': 'extra symbol "e"', 'position': 2}]}]
spell_checker.correction('odessa')
# [{'word': 'Odesa',
# 'corrections': [{'mistake_type': 'wrong symbol "o": replaced on "O"',
# 'position': 0},
# {'mistake_type': 'extra symbol "s"', 'position': 4}]}]
spell_checker.correction('Hmelnitskiy', max_mistakes_number_part=.5)
# [{'word': 'Khmelnytskyi',
# 'corrections': [{'mistake_type': 'missing symbol "K"', 'position': 0},
# {'mistake_type': 'wrong symbol "H": replaced on "h"', 'position': 0},
# {'mistake_type': 'wrong symbol "i": replaced on "y"', 'position': 5},
# {'mistake_type': 'missing symbol "y"', 'position': 9},
# {'mistake_type': 'extra symbol "y"', 'position': 10}]}]
spell_checker.correction('Kharkiv')
# [{'word': 'Kharkiv', 'corrections': []}]
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for simple_spell_checker-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f918f029376349b540a4a313678150ea1606d235b2346359c4549a23d5e5082c |
|
MD5 | eb0a9b6986f9b2cd545baa19ad46ca1c |
|
BLAKE2b-256 | a820b8b2e10f835e4e84910c564b41c7eeef84e8a43d36ec6e7f3936b06efec4 |
Close
Hashes for simple_spell_checker-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79aedfb101a25c776a9f313f74f544bca58fd67f23b50076f9e0e10a098b4b5a |
|
MD5 | 48fa433e75921756e94cdf05be598998 |
|
BLAKE2b-256 | 8082fd819b7e07faa1a55193fd63858793563276f7c6e907ce3041a841a8aab5 |