-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
28 lines (24 loc) · 754 Bytes
/
script.py
File metadata and controls
28 lines (24 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
from difflib import get_close_matches
data = json.load(open("data.json"))
def meaning(word):
word = word.lower()
if word in data.keys():
return data[word]
elif len(get_close_matches(word,data.keys(),cutoff=0.8))>0 :
match = get_close_matches(word,data.keys(),cutoff=0.8)[0]
choice = input("Did you mean '%s' ??? \nEnter Y if Yes or N if No : " %match )
if choice in ['Y','y']:
return data[match]
else :
return "No such word exists!"
else :
return "No such word exists!"
query = input("Enter a word : ")
#printing the meaning
output = meaning(query)
if type(output) == list :
for item in output:
print("# "+item)
else :
print(output)