| 20 | return data |
| 21 | |
| 22 | def _translate(self): |
| 23 | word = str.lower(self.word) |
| 24 | if word in self.data: |
| 25 | logging.debug(f"Found the word({word}) in the json file...") |
| 26 | return self.data[word] |
| 27 | elif word.title() in self.data: |
| 28 | logging.debug(f"Found the word title({word.title()}) in the json file...") |
| 29 | return self.data[word.title()] |
| 30 | elif word.upper() in self.data: |
| 31 | logging.debug(f"Found the word upper({word.upper()}) in the json file...") |
| 32 | return self.data[word.upper()] |
| 33 | elif len(get_close_matches(word, self.data.keys())) > 0: |
| 34 | print("did you mean %s instead" % get_close_matches(word, self.data.keys())[0]) |
| 35 | decide = input("press y for yes or n for no: ") |
| 36 | if decide == "y": |
| 37 | return self.data[get_close_matches(word, self.data.keys())[0]] |
| 38 | elif decide == "n": |
| 39 | return ("pugger your paw steps on working keys ") |
| 40 | |
| 41 | else: |
| 42 | logging.debug(f"Couldn't find the word({word}) in the json file...") |
| 43 | |
| 44 | |
| 45 | |