Spelling Correction with Python

In machine learning, spelling correction and spell checking is a well-known and well-studied problem in natural language processing. In this article, you will learn about a very basic machine learning project on spelling correction with Python programming language.

Introduction to Spelling Correction with Python

Modern spelling correctors aren’t perfect (indeed, automatic error correction is a popular source of fun on the web), but they’re ubiquitous in just about all software that relies on keyboard input.

Spelling correction is often viewed from two angles. Non-word spell check is the detection and correction of spelling mistakes that result in non-words. In contrast, real word spell checking involves detecting and correcting misspellings even if they accidentally result in a real English word (real word errors).

This can come from typographical errors of real-word errors (insertion, deletion, transposition) that accidentally produce a real word, or from cognitive errors where the writer substituted the wrong one.

Spelling Correction with Python

from textblob import TextBlob
words = ["falibility", "smle"]
corrected_words = []
for i in words:
print("Wrong words :", words)
print("Corrected Words are :")
for i in corrected_words:
print(i.correct(), end=" ")
Wrong words : ['falibility', 'smle']
Corrected Words are :
fallibility smile


However, it is possible to use the noisy channel to find candidates for every word the user typed and rank the correction that was probably the user’s original intention.

I hope you liked this article on creating a spelling correction with Python programming language. Feel free to ask your valuable questions in the comments section below.

Data Science enthusiast ready to help and learn from others. Raised in Eastern Cape, South Africa, I am excited to share my blogs with the world!