Skip to content

Commit

Permalink
added rule for /k/ palatization
Browse files Browse the repository at this point in the history
  • Loading branch information
free-variation committed Mar 13, 2019
1 parent 59f0191 commit 9ac7fc4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
14 changes: 12 additions & 2 deletions cltk/phonology/old_english/orthophonology.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,18 @@

oe = Orthophonology(sound_inventory, alphabet, diphthongs_ipa, digraphs_ipa)

# intervocalic fricatives are voiced
oe.add_rule(InnerPhonologicalRule(
lambda before, target, after:
condition = lambda before, target, after:
isinstance(before, Vowel) and target[Manner] == Manner.fricative and isinstance(after, Vowel),
lambda target:
action = lambda target:
oe.voice(target)))

# /k/ is palatized in specific environments
oe.add_rule(PhonologicalRule(
condition = lambda before, target, after:
target == k and
((isinstance(after, Vowel) and after[Backness] == Backness.front) or
(before is not None and before == i and
(after is None or (isinstance(after, Vowel) and after[Backness] != Backness.back)))),
action = lambda _: tsh))
18 changes: 13 additions & 5 deletions cltk/phonology/orthophonology.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
class PhonologicalFeature(IntEnum):
pass

class Consonantal(PhonologicalFeature):
neg = auto()
pos = auto()

class Voiced(PhonologicalFeature):
neg = auto()
pos = auto()
Expand Down Expand Up @@ -116,10 +120,11 @@ def __init__(self, place, manner, voiced, ipa, geminate = Geminate.neg):
assert ipa is not None

AbstractPhoneme.__init__(self, {
Place : place,
Manner : manner,
Voiced : voiced,
Geminate : geminate},
Consonantal : Consonantal.pos,
Place : place,
Manner : manner,
Voiced : voiced,
Geminate : geminate},
ipa)

def is_more_sonorous(self, other):
Expand All @@ -134,6 +139,7 @@ def __init__(self, height, backness, rounded, length, ipa):
assert ipa is not None

AbstractPhoneme.__init__(self, {
Consonantal : Consonantal.neg,
Height : height,
Backness : backness,
Roundedness : rounded,
Expand Down Expand Up @@ -249,7 +255,9 @@ def transcribe_word(self, word):
return phonemes

def transcribe(self, text):
return [self.transcribe_word(word) for word in self.tokenize(text)]
phoneme_words = [self.transcribe_word(word) for word in self.tokenize(text)]
words = [''.join([phoneme.ipa for phoneme in word]) for word in phoneme_words]
return ' '.join(words)

def find_sound(self, phoneme) :
for sound in self.sound_inventory:
Expand Down

0 comments on commit 9ac7fc4

Please sign in to comment.