Exemple #1
0
 def test_15(self):
     o = Ortheme("<i(i, í, ì, ị, ỉ, ĩ)>-<y(y, ý, ỳ, ỷ, ỹ, ỵ)>=/i/")
     assert o.graphemes == [
         Token("i(i, í, ì, ị, ỉ, ĩ)"),
         Token("y(y, ý, ỳ, ỷ, ỹ, ỵ)")
     ]
     assert o.phonemes == [Token('i')]
Exemple #2
0
 def test_match_inventory_allophone(self):
     inv = [
         Token("i(i, í, ì, ị, ỉ, ĩ)"),
     ]
     o = Ortheme("<x>=/í/", inventory=inv)
     assert o.graphemes == [Token('x')]
     assert o.phonemes == inv
Exemple #3
0
 def test_read_orthography_vowel(self):
     ov = self.reader.data['orthography_vowels']
     assert len(ov) == 7
     assert ov[0] == Ortheme("<i> = /ɪ/", inventory=self.reader.inventory)
     assert ov[1] == Ortheme("<e> = /ë/", inventory=self.reader.inventory)
     assert ov[2] == Ortheme("<a> = /ɐ̝/", inventory=self.reader.inventory)
     assert ov[3] == Ortheme("<o> = /ö/", inventory=self.reader.inventory)
     assert ov[4] == Ortheme("<u> = /ʊ/", inventory=self.reader.inventory)
     assert ov[5] == Ortheme("<ü> = /ɘ/", inventory=self.reader.inventory)
     assert ov[6] == Ortheme("<∅> = /ʎ/", inventory=self.reader.inventory)
Exemple #4
0
    def test_inventory_and_orthography_token_matches(self):
        # The orthographies tend to be underspecified e.g.:
        # p(p, pʰ, pʷ) is in the inventory but the orthography has
        # <p> = /p/
        # ... so we should first match the full and if not found then see
        # if we match the short form.
        assert 'p' in self.reader.get_variants()
        # ... and in orthography
        assert Ortheme('<p> = /p(p, pʰ, pʷ)/') in self.reader.orthography

        #...and in variants
        assert Token('p(p, pʰ, pʷ)') == self.reader.get_variants()['p']
Exemple #5
0
 def test_12(self):
     o = Ortheme("<k>-<q>-<c> = /k/")
     assert o.graphemes == [Token('k'), Token('q'), Token('c')]
     assert o.phonemes == [Token('k')]
Exemple #6
0
 def test_10(self):
     o = Ortheme("<oe>-<œ>=/u/")
     assert o.graphemes == [Token('oe'), Token('œ')]
     assert o.phonemes == [Token('u')]
Exemple #7
0
 def test_9(self):
     o = Ortheme("<l> = /ɮ/-/l/-/ɫ/")
     assert o.graphemes == [Token('l')]
     assert o.phonemes == [Token('ɮ'), Token('l'), Token('ɫ')]
Exemple #8
0
 def test_8(self):
     o = Ortheme("<j>-<dd>=/ɟ/")
     assert o.graphemes == [Token('j'), Token('dd')]
     assert o.phonemes == [Token('ɟ')]
Exemple #9
0
 def test_compare(self):
     assert Ortheme("<p> = /p/") == Ortheme("<p>=/p/")
     assert Ortheme("<t> = /t/-/t̪/") == Ortheme("<t>=/t/-/t̪/")
     assert Ortheme("<t> = /t/-/t̪/") != Ortheme("<t>=/t/")
Exemple #10
0
 def test_4(self):
     o = Ortheme("<ieu>=/iu/")
     assert o.graphemes == [Token('ieu')]
     assert o.phonemes == [Token('iu')]
Exemple #11
0
 def test_3(self):
     o = Ortheme("<ch> = /tʃ/")
     assert o.graphemes == [Token('ch')]
     assert o.phonemes == [Token('tʃ')]
Exemple #12
0
 def test_2(self):
     o = Ortheme("<p>=/p/")
     assert o.graphemes == [Token('p')]
     assert o.phonemes == [Token('p')]
Exemple #13
0
 def test_match_inventory_error(self):
     with self.assertRaises(ValueError):
         Ortheme("<x>=/a/", inventory=[Token("i(i, í, ì, ị, ỉ, ĩ)")])
Exemple #14
0
 def test_error_on_multiple_separators(self):
     with self.assertRaises(OrthemeException):
         Ortheme("<eu>=/øə/=<aa>")
Exemple #15
0
 def test_read_orthography_consonant(self):
     oc = self.reader.data['orthography_consonants']
     assert len(oc) == 18, oc
     assert oc[0] == Ortheme("<p> = /p/", inventory=self.reader.inventory)
     assert oc[1] == Ortheme("<t> = /t/-/t̪/",
                             inventory=self.reader.inventory)
     assert oc[2] == Ortheme("<k> = /k/", inventory=self.reader.inventory)
     assert oc[3] == Ortheme("<ch> = /tʃ/", inventory=self.reader.inventory)
     assert oc[4] == Ortheme("<tr> = /ʈʂ/", inventory=self.reader.inventory)
     assert oc[5] == Ortheme("<m> = /m/", inventory=self.reader.inventory)
     assert oc[6] == Ortheme("<n> = /n/-/n̪/",
                             inventory=self.reader.inventory)
     assert oc[7] == Ortheme("<ñ> = /ɲ(ɲ, ɲː)/",
                             inventory=self.reader.inventory)
     assert oc[8] == Ortheme("<ng> = /ŋ/", inventory=self.reader.inventory)
     assert oc[9] == Ortheme("<f> = /f/", inventory=self.reader.inventory)
     assert oc[10] == Ortheme("<d> = /θ/", inventory=self.reader.inventory)
     assert oc[11] == Ortheme("<s> = /s/-/ʃ/",
                              inventory=self.reader.inventory)
     assert oc[12] == Ortheme("<r> = /ʐ/", inventory=self.reader.inventory)
     assert oc[13] == Ortheme("<g> = /ɣ/", inventory=self.reader.inventory)
     assert oc[14] == Ortheme("<y> = /j/", inventory=self.reader.inventory)
     assert oc[15] == Ortheme("<l> = /l/-/l̪/",
                              inventory=self.reader.inventory)
     assert oc[16] == Ortheme("<ll> = /ʎ/", inventory=self.reader.inventory)
     assert oc[17] == Ortheme("<w> = /w/", inventory=self.reader.inventory)
Exemple #16
0
 def test_13(self):
     o = Ortheme("<s>-<c>-<ç>-<ss> = /s/")
     assert o.graphemes == [Token('s'), Token('c'), Token('ç'), Token("ss")]
     assert o.phonemes == [Token('s')]
Exemple #17
0
 def test_14(self):
     o = Ortheme("<a(a, á, à, ả, ã, ạ)>=/a/")
     assert o.graphemes == [Token("a(a, á, à, ả, ã, ạ)")]
     assert o.phonemes == [Token('a')]
Exemple #18
0
 def test_5(self):
     o = Ortheme("<ph>=/pʰ/")
     assert o.graphemes == [Token('ph')]
     assert o.phonemes == [Token('pʰ')]
Exemple #19
0
 def test_repr(self):
     for o in ["<p> = /p/", "<n> = /n/-/ŋ/", "<k>-<q>-<c> = /k/"]:
         assert repr(Ortheme(o)) == o, "%s != %r" % (o, Ortheme(o))
Exemple #20
0
 def test_6(self):
     o = Ortheme("<t> = /t/-/t̪/")
     assert o.graphemes == [Token('t')]
     assert o.phonemes == [Token('t'), Token('t̪')]
Exemple #21
0
 def test_error_on_dash_separator(self):
     with self.assertRaises(OrthemeException):
         Ortheme("<eu>-/øə/")
Exemple #22
0
 def test_7(self):
     o = Ortheme("<n> = /n/-/ŋ/")
     assert o.graphemes == [Token('n')]
     assert o.phonemes == [Token('n'), Token('ŋ')]