Skip to content

Commit

Permalink
test: update lexicon test for eng ipa
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines authored and joanise committed Mar 28, 2023
1 parent c824f6b commit f05a513
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 2 additions & 0 deletions g2p/tests/public/data/eng.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Make sure the same input in NFD and NFC both get handled correctly
eng-ipa,eng-arpabet,ĩ,IY N
eng-ipa,eng-arpabet,ĩ,IY N
eng-eng-ipa,hello,hʌloʊ
eng,eng-arpabet,hello,HH AH L OW
18 changes: 6 additions & 12 deletions g2p/tests/test_lexicon_transducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,17 @@ def test_lexicon_mapping(self):
)

def test_eng_lexicon(self):
m = Mapping(in_lang="eng", out_lang="eng-arpabet")
m = Mapping(in_lang="eng", out_lang="eng-ipa")
self.assertEqual(m.kwargs["type"], "lexicon")
t = Transducer(m)
tg = t("hello")
self.assertEqual(tg.output_string, "HH AH L OW ")
self.assertEqual(
tg.edges, [(0, 0), (0, 1), (1, 3), (1, 4), (2, 6), (3, 6), (4, 8), (4, 9)]
)
self.assertEqual(tg.output_string, "hʌloʊ")
self.assertEqual(tg.edges, [(0, 0), (1, 1), (2, 2), (3, 2), (4, 3), (4, 4)])
tg = t("you're")
self.assertEqual(tg.output_string, "Y UW R ")
self.assertEqual(tg.output_string, "jʊɹ")
self.assertEqual(
tg.edges, [(0, 0), (1, 2), (1, 3), (2, 2), (2, 3), (4, 5), (5, 5)]
tg.edges, [(0, 0), (1, None), (2, 1), (3, None), (4, 2), (5, None)]
)
self.assertEqual(tg.output_string, "hʌloʊ")
tg = t("change")
self.assertEqual(tg.output_string, "tʃeɪndʒ")
self.assertEqual(tg.input_string, "change")
Expand Down Expand Up @@ -85,10 +82,7 @@ def test_eng_lexicon(self):
def test_eng_transducer(self):
transducer = make_g2p("eng", "eng-arpabet")
tg = transducer("hello")
self.assertEqual(tg.output_string, "HH EH L OW ")
self.assertEqual(
tg.edges, [(0, 0), (0, 1), (1, 3), (1, 4), (2, 6), (3, 6), (4, 8), (4, 9)]
)
self.assertEqual(tg.output_string, "HH AH L OW ")


if __name__ == "__main__":
Expand Down

0 comments on commit f05a513

Please sign in to comment.