コード例 #1
0
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)
コード例 #2
0
def test_consonant_clusters():
    assert pig_latin("glove") == "oveglay"
    assert pig_latin("strawberry") == "awberrystray"
コード例 #3
0
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."
コード例 #4
0
def test_simple_words():
    assert pig_latin("pig") == "igpay"
    assert pig_latin("diorama") == "ioramaday"
コード例 #5
0
def test_phrases():
    assert pig_latin("eight nights of horror") == \
        "eightway ightsnay ofway orrorhay"
コード例 #6
0
def test_beginning_vowel():
    assert pig_latin("egg") == "eggway"
    assert pig_latin("icicle") == "icicleway"
コード例 #7
0
 def test_pl_2(self):
     r = pig_latin("Bellsprout")
     expected = "Ellsproutbay"
     self.assertEqual(r, expected)
コード例 #8
0
 def test_pl_1(self):
     r = pig_latin("Gotta catch them all!")
     expected = "Ottagay atchcay hemtay allway!"
     self.assertEqual(r, expected)
コード例 #9
0
def translate(voice_data):
    translated_text = pig_latin(voice_data)
    print(translated_text)
    speak(translated_text)