Exemple #1
0
    def test_rule_conversion1(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
        ]

        # examples of ipa_to_regular_expression and from_regular_expression methods
        ru1 = ut.Rule(ut.AbstractPosition(ut.Rank.inner, [ut.AbstractConsonant(voiced=False)],
                                          [ut.AbstractConsonant(voiced=True)]), th, th)
        self.assertEqual(ru1.ipa_to_regular_expression(PHONOLOGY), "(?<=[fkpstθ])θ(?=[bdgvð])")
Exemple #2
0
    def test_rule_conversion1(self):
        # Definition of real Vowel and Consonant instances
        a = ut.Vowel("open", "front", False, "short", "a")
        e = ut.Vowel("close-mid", "front", False, "short", "e")
        i = ut.Vowel("close", "front", False, "short", "i")
        o = ut.Vowel("close-mid", "back", True, "short", "o")
        u = ut.Vowel("close", "back", True, "short", "u")

        b = ut.Consonant("bilabial", "stop", True, "b", False)
        d = ut.Consonant("alveolar", "stop", True, "d", False)
        f = ut.Consonant("labio-dental", "frictative", False, "f", False)
        g = ut.Consonant("velar", "stop", True, "g", False)
        k = ut.Consonant("velar", "stop", False, "k", False)
        p = ut.Consonant("bilabial", "stop", False, "p", False)
        s = ut.Consonant("alveolar", "frictative", False, "s", False)
        t = ut.Consonant("alveolar", "stop", False, "t", False)
        v = ut.Consonant("labio-dental", "frictative", True, "v", False)
        th = ut.Consonant("dental", "frictative", False, "θ", False)
        dh = ut.Consonant("dental", "frictative", 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]

        # examples of ipa_to_regular_expression and from_regular_expression methods
        ru1 = ut.Rule(
            ut.AbstractPosition("inner", [ut.AbstractConsonant(voiced=False)],
                                [ut.AbstractConsonant(voiced=True)]), th, th)
        self.assertEqual(ru1.ipa_to_regular_expression(PHONOLOGY),
                         "(?<=[fkpstθ])θ(?=[bdgvð])")
Exemple #3
0
 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)
Exemple #4
0
 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)
Exemple #5
0
 def test_rule7_utils(self):
     b = ut.Consonant("bilabial", "stop", True, "b", False)
     th = ut.Consonant("dental", "frictative", False, "θ", False)
     dh = ut.Consonant("dental", "frictative", True, "ð", False)
     rule = ut.Rule(
         ut.AbstractPosition("inner", [ut.AbstractConsonant(voiced=True)],
                             [ut.AbstractConsonant(voiced=True)]), th, dh)
     pos = ut.Position("inner", b, b)
     self.assertEqual(rule.can_apply(pos), True)
Exemple #6
0
 def test_rule4_utils(self):
     a = ut.Vowel("open", "front", False, "short", "a")
     th = ut.Consonant("dental", "frictative", False, "θ", False)
     dh = ut.Consonant("dental", "frictative", True, "ð", False)
     rule = ut.Rule(
         ut.AbstractPosition("inner", [ut.AbstractConsonant(voiced=True)],
                             [ut.AbstractConsonant(voiced=True)]), th, dh)
     pos = ut.Position("inner", a, a)
     self.assertEqual(rule.can_apply(pos), False)
Exemple #7
0
    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])ð$")
Exemple #8
0
    def test_rule_conversion2(self):
        # Definition of real Vowel and Consonant instances
        a = ut.Vowel("open", "front", False, "short", "a")
        e = ut.Vowel("close-mid", "front", False, "short", "e")
        i = ut.Vowel("close", "front", False, "short", "i")
        o = ut.Vowel("close-mid", "back", True, "short", "o")
        u = ut.Vowel("close", "back", True, "short", "u")

        b = ut.Consonant("bilabial", "stop", True, "b", False)
        d = ut.Consonant("alveolar", "stop", True, "d", False)
        f = ut.Consonant("labio-dental", "frictative", False, "f", False)
        g = ut.Consonant("velar", "stop", True, "g", False)
        k = ut.Consonant("velar", "stop", False, "k", False)
        p = ut.Consonant("bilabial", "stop", False, "p", False)
        s = ut.Consonant("alveolar", "frictative", False, "s", False)
        t = ut.Consonant("alveolar", "stop", False, "t", False)
        v = ut.Consonant("labio-dental", "frictative", True, "v", False)
        th = ut.Consonant("dental", "frictative", False, "θ", False)
        dh = ut.Consonant("dental", "frictative", 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]
        ru2 = ut.Rule(
            ut.AbstractPosition("first", None,
                                [ut.AbstractConsonant(place="velar")]), p, k)
        self.assertEqual(ru2.ipa_to_regular_expression(PHONOLOGY),
                         "^p(?=[gk])")