def test_rule7_utils(self): b = ut.Consonant(ut.Place.bilabial, ut.Manner.stop, True, "b", False) th = ut.Consonant(ut.Place.dental, ut.Manner.fricative, False, "θ", False) dh = ut.Consonant(ut.Place.dental, ut.Manner.fricative, True, "ð", False) rule = ut.Rule( ut.AbstractPosition( ut.Rank.inner, [ut.AbstractConsonant(voiced=True)], [ut.AbstractConsonant(voiced=True)], ), th, dh, ) pos = ut.Position(ut.Rank.inner, b, b) self.assertEqual(rule.can_apply(pos), True)
def test_rule4_utils(self): a = ut.Vowel(ut.Height.open, ut.Backness.front, False, ut.Length.short, "a") th = ut.Consonant(ut.Place.dental, ut.Manner.fricative, False, "θ", False) dh = ut.Consonant(ut.Place.dental, ut.Manner.fricative, True, "ð", False) rule = ut.Rule( ut.AbstractPosition( ut.Rank.inner, [ut.AbstractConsonant(voiced=True)], [ut.AbstractConsonant(voiced=True)], ), th, dh, ) pos = ut.Position(ut.Rank.inner, a, a) self.assertEqual(rule.can_apply(pos), False)
def test_rule_conversion3(self): # Definition of real Vowel and Consonant instances a = ut.Vowel(ut.Height.open, ut.Backness.front, False, ut.Length.short, "a") e = ut.Vowel( ut.Height.close_mid, ut.Backness.front, False, ut.Length.short, "e" ) i = ut.Vowel(ut.Height.close, ut.Backness.front, False, ut.Length.short, "i") o = ut.Vowel(ut.Height.close_mid, ut.Backness.back, True, ut.Length.short, "o") u = ut.Vowel(ut.Height.close, ut.Backness.back, True, ut.Length.short, "u") b = ut.Consonant(ut.Place.bilabial, ut.Manner.stop, True, "b", False) d = ut.Consonant(ut.Place.alveolar, ut.Manner.stop, True, "d", False) f = ut.Consonant(ut.Place.labio_dental, ut.Manner.fricative, False, "f", False) g = ut.Consonant(ut.Place.velar, ut.Manner.stop, True, "g", False) k = ut.Consonant(ut.Place.velar, ut.Manner.stop, False, "k", False) p = ut.Consonant(ut.Place.bilabial, ut.Manner.stop, False, "p", False) s = ut.Consonant(ut.Place.alveolar, ut.Manner.fricative, False, "s", False) t = ut.Consonant(ut.Place.alveolar, ut.Manner.stop, False, "t", False) v = ut.Consonant(ut.Place.labio_dental, ut.Manner.fricative, True, "v", False) th = ut.Consonant(ut.Place.dental, ut.Manner.fricative, False, "θ", False) dh = ut.Consonant(ut.Place.dental, ut.Manner.fricative, True, "ð", False) # examples of phonology and ipa_class phonology = [a, e, i, o, u, b, d, f, g, k, p, s, t, v, th, dh] ru3 = ut.Rule( ut.AbstractPosition( ut.Rank.last, [ut.AbstractConsonant(manner=ut.Manner.stop)], None ), dh, th, ) self.assertEqual(ru3.ipa_to_regular_expression(phonology), "(?<=[bdgkpt])ð$")