Python Spelling Checker & Corrector Project with Source Code

Spell Corrector, also known as Spell Checker is a python application that checks whether a word has the correct spelling or not. In this python project, we are going to create spell checker & corrector which will take in a word and output a list of similar words to it.

About Spell Corrector

The objective of Spell Corrector is to take in a word and find out what words are closer to it. A spelling corrector displays a list of words that have the closest resemblance to the entered word. If the entered word is correct then the same word is displayed. A click of a button will find us some words similar to the entered words.

Python Spell Corrector Project Details

The objective of the project is to create a Spell Corrector Application. The application will have a GUI. In the GUI, we will have an entry field to enter the word. We will have a button that when clicked will display the list of words closest to the entered word.

Project Prerequisites

To build the Spell Corrector Project, we are going to use the Tkinter Module and Spell Checker Module:

  • Tkinter Module – Tkinter Module helps us create the GUI of the project.
  • SpellChecker – SpellChecker Module will help us check for the correct spelling and display the list of matching words.

Download the Python Spelling Checker Code

Before proceeding ahead please download python spelling checker source code from the following link: Python Spell Checker & Corrector Project

Steps to Build the Python Spell Corrector Project

Follow the below steps to build the project:

  1. Importing the Required Modules
  2. Creating the GUI Window
  3. Spell Check Function

Let’s look at each step in detail.

1. Importing the Required Modules:

from spellchecker import SpellChecker
from tkinter import *
import tkinter as tk
  • These are the commands to import the modules that we are going to use in our project.

2. Creating the GUI Window:

window=Tk()
window.geometry("400x400")
window.title("TechVidvan - Python Spell Checker")
Label(window,text="SPELL CORRECTOR",font="Arial 18",bg='orange').pack()
  • Tk() – This method helps us create a GUI Window.
  • geometry() – Defines the size of the GUI Window.
  • title() – Gives a suitable title to the GUI Window.
  • Label() – This method helps us create a label widget on the GUI Window. A label helps us display text on the GUI window.
Label(window,text="Enter A Word",font="Arial 13").pack()
Entry(window, textvariable=text).pack()
  • Entry() – This method helps us create an entry field on the GUI window. This entry field is where the user will enter the word to be checked.
Button(window,text="Correct",bg='yellow',command=check,font='Arial 15').pack()
  • Button() – This method helps us create a button on the GUI window. When this button is clicked the check operation will be performed on the entered string.

3. Spell Check Function:

spell = SpellChecker()
def check():
    t=text.get()
    correct=spell.candidates(t)
    Label(window,text="Here is a list of words:",font="Arial 12").pack()
    Label(window,text=correct,font="Arial 12").pack()
  • SpellChecker() – Loads the list of words in the variable spell.
  • get() – Using get() method we get the value of text entered.
  • candidates() – This displays the set of words that are close to the word entered.
  • Using Label, we display the set of words as an output on the GUI window.

Python Spell Checker Output

python spell checker output

Summary

In the Spell Corrector Project, we have used Tkinter Module to build an easy GUI using Python and SpellChecker Module to check the word. We have created a GUI with a button, labels and an entry field. In this way, we have successfully completed this project.