MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / _translate

Method _translate

Dictionary/dictionary_.py:22–42  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers 1

dictionary_.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected