Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added GUIScripts/English Dictionary/Images/code.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUIScripts/English Dictionary/Images/gui1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUIScripts/English Dictionary/Images/gui2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions GUIScripts/English Dictionary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# English Dictionary

### Description :

- A search tool for meanings of different words of the English language. Works like an online dictionary.
- Libraries imported- Tkinter, json and get_closer_matches module from difflib.

### Setup Instructions :

1. The json data is stored in 'data.json' file in the 'Related' folder.
2. Location of this file should be entered in the json.load command. eg. json.load(open("Related/data.json"))
3. Run the code and a window appears.
4. Enter the word in the search box and click on the search button. The meaning appears in the display box.

### Output :
![gui1](https://user-images.githubusercontent.com/71630760/121812391-424d2200-cc85-11eb-8dfb-eeb1fcb56c87.PNG)![gui2](https://user-images.githubusercontent.com/71630760/121812420-54c75b80-cc85-11eb-80a0-f6583d303ce3.PNG)

### Conclusion :
* Meanings of words can be searched effectively.
* Even if any word is misspelled, a prompt appears displaying the meaning of the closest match.

### Author :
Sonali Bedade
1 change: 1 addition & 0 deletions GUIScripts/English Dictionary/Related/data.json

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions GUIScripts/English Dictionary/english_dictionary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from tkinter import * #importing the necessary libraries
import json
from difflib import get_close_matches

data = json.load(open("Related/data.json")) #loading and storing the data from json file

def search(word):
if word in data: #if the typed word is present in the data
t1.delete(1.0,END)
t1.config(fg='white')
t1.insert(END,data[word])
elif len(get_close_matches(word,data.keys()))>0: #if the typed word is not found in data or is misspelled
t1.config(fg='red')
t1.delete(1.0,END)
t1.insert(END,"Did you mean {} to mean : {} ".format (get_close_matches(word,data.keys())[0],data[get_close_matches(word,data.keys())[0]]))
output = get_close_matches(word,data.keys())


window = Tk()
window.title ("English Dictionary")

label = Label(window)
label.pack()

e1_value=StringVar()
e1 = Entry(window,textvariable=e1_value,bg="black",fg="white",justify = CENTER,font = ('courier', 30, 'bold')) #for the text bar
e1.place(relx=.185,rely=0.70,relwidth=.63,relheight=.082)


b1 = Button(window,text="Search",command= lambda : search(e1_value.get()),relief=FLAT,bg="black",fg="white",font = ('courier', 30, 'bold') ) #for the search button
b1.place(relx=.40,rely=.85,relwidth=.2,relheight=.052)


t1 = Text(window,fg="white",relief=FLAT,bg="#444444",font = ('courier', 20, 'bold')) #for displaying the meaning
t1.place(relx=.185,rely=.09,relwidth=.63,relheight=.50)

window.mainloop()
3 changes: 3 additions & 0 deletions GUIScripts/English Dictionary/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Tkinter -- for creating GUI
json -- for loading the JSON data
difflib.get_close_matches -- for getting the closest match of a misspelled word.