From 4f3ccf9f96895888ed41b4d47faff0c059489a6c Mon Sep 17 00:00:00 2001 From: Isin Demirsahin Date: Wed, 18 Dec 2024 15:31:17 -0800 Subject: [PATCH] Tests for Marathi diphthong grapheme -> long vowel phoneme rules. PiperOrigin-RevId: 707687686 --- nisaba/scripts/natural_translit/brahmic/g2p.py | 4 ++++ .../natural_translit/g2p/testdata/mr_iso_ipa.textproto | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/nisaba/scripts/natural_translit/brahmic/g2p.py b/nisaba/scripts/natural_translit/brahmic/g2p.py index 50be557a..9d10924a 100644 --- a/nisaba/scripts/natural_translit/brahmic/g2p.py +++ b/nisaba/scripts/natural_translit/brahmic/g2p.py @@ -39,6 +39,10 @@ def iso_to_txn() -> pyn.Fst: # Vowels +# TODO: Convert this constant to a function where duration and diphthong +# context are passed as arguments, and remove the recovery rule. +# The current rule rewrites all /a/ to /ə/ including the diphthongs like /ai/, +# and recovers long a with /ə:/ -> /a:/ but not the diphthongs. A_TO_EC = ( rw.rewrite(ph.A, ph.EC) @ rw.rewrite(ph.EC + ph.DURH, ph.A + ph.DURH) diff --git a/nisaba/scripts/natural_translit/g2p/testdata/mr_iso_ipa.textproto b/nisaba/scripts/natural_translit/g2p/testdata/mr_iso_ipa.textproto index 988e540b..962a2108 100644 --- a/nisaba/scripts/natural_translit/g2p/testdata/mr_iso_ipa.textproto +++ b/nisaba/scripts/natural_translit/g2p/testdata/mr_iso_ipa.textproto @@ -39,3 +39,13 @@ rewrite { input: "siddʰēgavhāṇa" output: "sid̪d̪ʰeːɡəʋʰaːɳ" } +rewrite { + rule: "ISO_TO_IPA" + input: "aisā" + output: "ɛːsaː" +} +rewrite { + rule: "ISO_TO_IPA" + input: "kannauja" + output: "kən̪n̪ɔːd͡ʒ" +} \ No newline at end of file