def translate_to_pig_latin(orig_file, dest_file): orig_lines_list = read_file(orig_file) dest_file_lines = [] for line in orig_lines_list: new_line = [] for word in line.split(): new_line.append(pig_latin(word)) dest_file_lines.append(' '.join(new_line)) write_file(dest_file, dest_file_lines)
def test_consonant_clusters(): assert pig_latin("glove") == "oveglay" assert pig_latin("strawberry") == "awberrystray"
def test_sentences(): assert pig_latin("How can a gentle beast live in this savage world?") == \ ("Owhay ancay away entlegay eastbay ivelay inway isthay avagesay " "orldway?") assert pig_latin("In the sunshine, all nightmares melt.") == \ "Inway ethay unshinesay, allway ightmaresnay eltmay."
def test_simple_words(): assert pig_latin("pig") == "igpay" assert pig_latin("diorama") == "ioramaday"
def test_phrases(): assert pig_latin("eight nights of horror") == \ "eightway ightsnay ofway orrorhay"
def test_beginning_vowel(): assert pig_latin("egg") == "eggway" assert pig_latin("icicle") == "icicleway"
def test_pl_2(self): r = pig_latin("Bellsprout") expected = "Ellsproutbay" self.assertEqual(r, expected)
def test_pl_1(self): r = pig_latin("Gotta catch them all!") expected = "Ottagay atchcay hemtay allway!" self.assertEqual(r, expected)
def translate(voice_data): translated_text = pig_latin(voice_data) print(translated_text) speak(translated_text)