Tutorial to build a Python English Dictionary Software in 2020

How to build a Working Simple Dictionary Software in Python

Hi, The Codezine Fellows! Your Dark Soulz is back with another exciting Python #DIY tutorials. Today, I will be talking about “How to build a Simple Dictionary Software in Python“.This piece will be really helpful for, firstly those who are new to python and secondly for those, who want to create their own dictionary software. Also, I assure you guys that, after going through this tutorial you will be able to build any Dictionary Software. [For example Spanish, Latin, Hindi, etc.]. Hope you are excited. So let us move on directly to our tut. a topic which is Tutorial to build a Python English Dictionary Software in 2020.

Project Built In Overview:

Languages Used:

  • Python 3+ [Tkinter]
  • JSON

Key Features:

  • Simple Codes to understand for beginners & Feasible to understand.
  • Can be modified to a language dictionary by simply editing JSON.
  • Errors Free & Bugs Free Codes.
  • Easy to understand the JSON data structure.

Project Requirements:

  • Basic concepts of python programming.
  • A Pc with the latest version of python 3 installed.
  • A good code ide such as Vs code, Atom, Sublime, etc
  • Your attention & focus on this tutorial.

Tutorial:

  • Firstly, make a file called main.py[Python File] & dictionary.json[JSON File] in your ide or in your desktop after making a folder with any name. Note for newbies: dictionary.json is the file that is used for storing word meaning & words. You can change it with any dialects of your choice.
  • Secondly, drag the file into your code ide or editor.
  • The Next Step is to, copy the codes below given and save it.
  • The Last Thing is to, run the python it by SHIFT+RIGHT CLICK cmd and type python main.py which will help you to execute the py file. That’s it your work is done.

Source Code:

Main.py


import json
from difflib import get_close_matches as g

data=json.load(open("dictionary.json"))
keys = data.keys()

def meaning():

    w = e1_value.get()

    if w in data:
        for i, j in enumerate(data[w]):
            t1.insert(END,str(i)+' '+j+'\n')
    elif w.upper() in data:
        for i, j in enumerate(data[w.upper()]):
            t1.insert(END,str(i)+' '+j+'\n')
    elif w.title() in data:
        for i, j in enumerate(data[w.title()]):
            t1.insert(END,str(i)+' '+j+'\n')
    else:
        list=g(w,keys,n=1,cutoff=0.8)
        if len(list) == 0:
            t1.insert(END,"Sorry, no word found!")
        else:
            real=list[0]
            answer=tkinter.messagebox.askquestion("Word Suggestion", "Is your word "+real+"?")
            
            if answer == "yes":
                for i, j in enumerate(data[real]):
                    t1.insert(END,str(i)+' '+j+'\n')
            #elif x == "yes":
                #for i, j in enumerate(data[real]):
                    #t1.insert(END,str(i)+' '+j+'\n')
            else:
                t1.insert(END,"Iss!, no word found. Please check your input word again.")


def meaning2():
    t1.delete(1.0,END)
    e1.delete(0,END)

    meaning

from tkinter import *
import tkinter.messagebox
root=Tk()
root.title("The Codezine")



header=Label(root, text="Python English Dictionary Software", bg="tomato", fg="white")
header.pack(fill=X)

label1=Label(root, text="Enter your word:")
label1.pack()

e1_value=StringVar()
e1=Entry(root, textvariable=e1_value)
e1.pack()

button=Button(root, text="Meaning!", command=meaning, bg="dark orchid")
button.pack()

t1=Text(root)
t1.pack(fill=X)

label2=Label(root, text="Press it for clearing screen")
label2.pack()

button2=Button(root,text="Clear Screen!", command=meaning2, bg="dark orchid")
button2.pack()


root.mainloop()

dictionary.py

As the JSON data file size is maximum and long that’s why we have not given the file here directly. But, no worries as you can copy the dictionary.json here: https://gist.github.com/jupiterdv/31da602ffffe2697292164456b2e2558

Conclusion

I hope the code will be easy for any beginners as it is written in an effortless & understandable way. Also, as like earlier tutorials, always try to take special care while copying the codes or while writing codes as it will help you to avoid errors. Don’t forget to comment & share this blog if you find it interesting. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.