Skip to main content

No project description provided

Project description

simple_spell_checker

Coverage Status Coverage Status

Coverage Status Coverage Status

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


Download files

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

Source Distribution

simple_spell_checker-0.0.1.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

simple_spell_checker-0.0.1-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

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