MCPcopy
hub / github.com/geekcomputers/Python / translate

Function translate

diction.py:39–58  ·  view source on GitHub ↗
(word)

Source from the content-addressed store, hash-verified

37
38
39def translate(word):
40 word = word.lower()
41 if word in data:
42 speak("Here is what I found in dictionary..")
43 d = data[word]
44 d = "".join(str(e) for e in d)
45 speak(d)
46 elif len(get_close_matches(word, data.keys())) > 0:
47 x = get_close_matches(word, data.keys())[0]
48 speak("Did you mean " + x + " instead, respond with Yes or No.")
49 ans = takeCommand().lower()
50 if "yes" in ans:
51 speak("ok " + "It means.." + data[x])
52 elif "no" in ans:
53 speak("Word doesn't exist. Please make sure you spelled it correctly.")
54 else:
55 speak("We didn't understand your entry.")
56
57 else:
58 speak("Word doesn't exist. Please double check it.")
59
60
61if __name__ == "__main__":

Callers 1

diction.pyFile · 0.70

Calls 2

takeCommandFunction · 0.85
speakFunction · 0.70

Tested by

no test coverage detected