Skip to content

added interactive python console based dictionary app #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions PythonBasedDictionaryApp/app1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Software Developed by Shaksham Sinha
# Date : 30th August 2019
# Description : A basic console based Dictionary app

import json
from difflib import get_close_matches

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

# fucntion to find the word


def translate(word):
word = word.lower()
if word in data:
return data[word]
elif word.title() in data:
return data[word.title()]
elif word.upper() in data:
return data[word.upper()]
elif len(get_close_matches(word, data.keys(), cutoff=0.8)) > 0:
yn = input("Did you mean {} instead? Enter Y if yes N if No: ".format(
get_close_matches(word, data.keys())[0]))
if yn.upper() == "Y":
return data[get_close_matches(word, data.keys())[0]]
elif yn.upper() == "N":
return "The word dosent exist. Please double check it again"
else:
return "We didn't understad your query."

else:
return "The word dosent exit please double check again"


print("Welcome to My Dictionary App :)")
word = input("Enter the word to find its meaning : ")
output = translate(word)
if type(output) == list:
for i in output:
print(" - " + i)
else:
print(output)
1 change: 1 addition & 0 deletions PythonBasedDictionaryApp/data.json

Large diffs are not rendered by default.