-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 33a329b
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from difflib import get_close_matches | ||
import json | ||
|
||
data = json.load(open("data.json")) | ||
|
||
#print(data) | ||
|
||
|
||
|
||
# def askForInput(): | ||
# word = input("A word to define\n") | ||
# print(data[word]) | ||
# | ||
# askForInput() | ||
|
||
|
||
def translate(w): | ||
w = w.lower() | ||
matches = get_close_matches(w, data.keys(), 1) | ||
print(matches) | ||
if w in data: | ||
return data[w] | ||
elif len(matches) != 0: | ||
return matches[0] | ||
else: | ||
return "The word doesn't exist. Please double check it." | ||
|
||
word = input("Enter word: ") | ||
|
||
print(translate(word)) |
Large diffs are not rendered by default.
Oops, something went wrong.