Skip to main content

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).

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_corrections_relative=.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_corrections_relative=.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.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

simple_spell_checker-0.0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file simple_spell_checker-0.0.2.tar.gz.

File metadata

  • Download URL: simple_spell_checker-0.0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for simple_spell_checker-0.0.2.tar.gz
Algorithm Hash digest
SHA256 98c6f377071856e076755d349917d3c41f4939d5e12b0e624c02d6089eaf2642
MD5 d06819a9979722ae5b0405ee33ebd6e1
BLAKE2b-256 8bd5a40ce6557938ea2f73831fbbe2871612a79afbbc1269844be06ce9abecb0

See more details on using hashes here.

File details

Details for the file simple_spell_checker-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_spell_checker-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a07f3d22d64aacee3328e8583e9c9e31f80de07947ae4d75e1282ba736bcd219
MD5 a22bf10618150666dcd2444de9501592
BLAKE2b-256 f377925486c07573725b784ee6834724ce322730bab1840888acef08f1767946

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