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')]
def test_match_inventory_allophone(self): inv = [ Token("i(i, í, ì, ị, ỉ, ĩ)"), ] o = Ortheme("<x>=/í/", inventory=inv) assert o.graphemes == [Token('x')] assert o.phonemes == inv
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)
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']
def test_12(self): o = Ortheme("<k>-<q>-<c> = /k/") assert o.graphemes == [Token('k'), Token('q'), Token('c')] assert o.phonemes == [Token('k')]
def test_10(self): o = Ortheme("<oe>-<œ>=/u/") assert o.graphemes == [Token('oe'), Token('œ')] assert o.phonemes == [Token('u')]
def test_9(self): o = Ortheme("<l> = /ɮ/-/l/-/ɫ/") assert o.graphemes == [Token('l')] assert o.phonemes == [Token('ɮ'), Token('l'), Token('ɫ')]
def test_8(self): o = Ortheme("<j>-<dd>=/ɟ/") assert o.graphemes == [Token('j'), Token('dd')] assert o.phonemes == [Token('ɟ')]
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/")
def test_4(self): o = Ortheme("<ieu>=/iu/") assert o.graphemes == [Token('ieu')] assert o.phonemes == [Token('iu')]
def test_3(self): o = Ortheme("<ch> = /tʃ/") assert o.graphemes == [Token('ch')] assert o.phonemes == [Token('tʃ')]
def test_2(self): o = Ortheme("<p>=/p/") assert o.graphemes == [Token('p')] assert o.phonemes == [Token('p')]
def test_match_inventory_error(self): with self.assertRaises(ValueError): Ortheme("<x>=/a/", inventory=[Token("i(i, í, ì, ị, ỉ, ĩ)")])
def test_error_on_multiple_separators(self): with self.assertRaises(OrthemeException): Ortheme("<eu>=/øə/=<aa>")
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)
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')]
def test_14(self): o = Ortheme("<a(a, á, à, ả, ã, ạ)>=/a/") assert o.graphemes == [Token("a(a, á, à, ả, ã, ạ)")] assert o.phonemes == [Token('a')]
def test_5(self): o = Ortheme("<ph>=/pʰ/") assert o.graphemes == [Token('ph')] assert o.phonemes == [Token('pʰ')]
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))
def test_6(self): o = Ortheme("<t> = /t/-/t̪/") assert o.graphemes == [Token('t')] assert o.phonemes == [Token('t'), Token('t̪')]
def test_error_on_dash_separator(self): with self.assertRaises(OrthemeException): Ortheme("<eu>-/øə/")
def test_7(self): o = Ortheme("<n> = /n/-/ŋ/") assert o.graphemes == [Token('n')] assert o.phonemes == [Token('n'), Token('ŋ')]