Skip to main content

Spell-Checker: Wrote studying LeetCode 75 Problems

Introduction

Writing Spell-checker is a challenge due to the complicated nature of searching and matching correct matches of user written words. Thus, providing correct spellings.

StackOverflow and Wikipedia offer in-depth knowledge in writing a spell-checker but are quite limited and outdated. It’s quite difficult to reverse engineer the spell checker ones present in Windows 11 by default. Including spell-checker has fundamental rules and later others tweak them to make it faster and add more features.

Establishing no prior rules how it should work, and present Neural Spell Checkers being prominent in Grammarly and Google Docs, I went on quest to write a spell checker from scratch using my understanding of Algorithms specifically LeetCode problems I solved in the past couple of weeks and reading through Articles.

Structure of SpellChecker

A unique and similar structure of past and present spell checkers were derived while designing this Algorithm. Starting

  1. A Prefix Tree search Algorithm to load every word from the dictionary into its respective nodes
  2. Iterating over the words and using Longest Common Sequence (LCS) to find most likely match for the input word
  3. Edit Distance (Levenshtein Distance) to determine the perfect match and returning result.

Word with highest LCS and lowest Edit distance is determined as a perfect match.

Learning outcomes

Practising LeetCode concepts in a real world project is valuable. Including better understanding how different Algorithms come into play and work to solve a critical problem in a unified manner. And showcasing problem solving and creativity traits.

LeetCode Problems (used)
  1. Edit Distance
  2. Longest Common Sequence
  3. Implement a Trie

These were part of LeetCode 75 Problems. https://leetcode.com/studyplan/leetcode-75/

Critical Pointers
  1. I don’t provide UI and interface to interact with the algorithm. A terminal interface needs to be utilised.
  2. A Public dictionary dataset was used.
  3. The clearest explanation of Spell Checker Algorithm and Code on the Internet.
  4. Time Complexity O(n * m * (m + m))

Consider star the repository if it helps you!

Release files for spell4checker 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spell4checker 0.0.1
File Size Uploaded
spell4checker-0.0.1.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spell4checker 0.0.1
File Interpreter ABI Platform
spell4checker-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 kB

Release files / spell4checker-0.0.1.tar.gz

Download URL spell4checker-0.0.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8236cdc69a5c7d0be56ac455f7ad7ad11689eba1f6520217a73d5402205dd0f2
BLAKE2b-256 checksum
How to use checksums
d10bd8f9bfd261a8689292b1f86a7c091a15c128525dabdcfcd4bb38a5c57bb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / spell4checker-0.0.1-py3-none-any.whl

Download URL spell4checker-0.0.1-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
993df0558990d83177c9e22eac7cb9a85474dd22207fe30e420b98a4f9d4604a
BLAKE2b-256 checksum
How to use checksums
72875389239721cace83a720fc510e31603c52d3b0b43f4b5a0b2d036e836456
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page