├── Interactive Dictionary ├── WordMeaning.py ├── data.json └── pythonProject.png ├── Python3 Mini Projects.jpg └── README.md /Interactive Dictionary/WordMeaning.py: -------------------------------------------------------------------------------- 1 | # Importing json and get_close_matches 2 | import json 3 | from difflib import get_close_matches 4 | 5 | # Loading json to a python3 dictionary 6 | data_dict = json.load(open('data.json')) 7 | 8 | 9 | def translate(w): 10 | """ 11 | This function finds the meaning of word given by user and suggest similar words if not typed correctly 12 | :param w: word 13 | :return: info 14 | """ 15 | if w in data_dict: 16 | return data_dict[w] 17 | elif len(get_close_matches(w, data_dict.keys())) > 0: 18 | print("\nDo you mean...\n\t1. {suggestion_1}\n\t2. {suggestion_2}\n\t3. {suggestion_3}\ninstead?\n".format( 19 | suggestion_1=get_close_matches(w, data_dict.keys())[0], 20 | suggestion_2=get_close_matches(w, data_dict.keys())[1], 21 | suggestion_3=get_close_matches(w, data_dict.keys())[2], 22 | ) 23 | ) 24 | answer_1 = input("If Yes then enter 'Y' and if No then enter 'N': ") 25 | answer_1 = answer_1.upper() 26 | if answer_1 == 'Y': 27 | answer_2 = input("Enter the word number '1', '2' or '3': ") 28 | if answer_2 == 1: 29 | return data_dict[get_close_matches(w, data_dict.keys())[0]] 30 | elif answer_2 == 2: 31 | return data_dict[get_close_matches(w, data_dict.keys())[1]] 32 | else: 33 | return data_dict[get_close_matches(w, data_dict.keys())[2]] 34 | else: 35 | return "OOPS! Word doesn't exist in database. Please enter another word" 36 | else: 37 | return "OOPS! Word doesn't exist in database. Please enter another word" 38 | 39 | 40 | def main(): 41 | print('\n---------------------------- * Dictionary * -----------------------------\n' 42 | '------------- * Find meaning of any word with auto suggest * ------------\n') 43 | word = input( 44 | 'Enter word: ') 45 | word = word.lower() 46 | translated = translate(word) 47 | if type(translated) == list: 48 | print('\n', word, ':\n') 49 | for meaning in translated: 50 | print("- ", meaning) 51 | layout() 52 | else: 53 | print(translated) 54 | layout() 55 | 56 | 57 | def layout(): 58 | start = input("\nEnter 'Q' to quit or any other key to continue: ") 59 | start = start.upper() 60 | if start == 'Q': 61 | exit(0) 62 | else: 63 | main() 64 | 65 | 66 | layout() 67 | -------------------------------------------------------------------------------- /Interactive Dictionary/pythonProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deathook007/Python3-Mini-Projects/cba975f80ad8ef6c4bdba0cc2a50d7e74b8b4bce/Interactive Dictionary/pythonProject.png -------------------------------------------------------------------------------- /Python3 Mini Projects.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deathook007/Python3-Mini-Projects/cba975f80ad8ef6c4bdba0cc2a50d7e74b8b4bce/Python3 Mini Projects.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Screenshot-1](https://github.com/deathook007/Python3-Mini-Projects/blob/main/Python3%20Mini%20Projects.jpg) 2 | # Python3 Mini Projects 📚 3 | 4 | ## 1. Interactive Dictionary 5 | - Simple and interactive dictionary (Find meaning of most words) 6 | - Auto suggest words ! 7 | - Libraries used - difflib and json. 8 | 9 | ### ScreenShots Below 👇 10 | 11 | ![Screenshot-1](https://github.com/deathook007/Python3-Mini-Projects/blob/main/Interactive%20Dictionary/pythonProject.png) 12 | --------------------------------------------------------------------------------