def change_feature(self, args): """ This translates unconditional changes where the domain and codomain are both feature expressions. The change_feature function from the change_functions module is used to change each feature individually. Finally, the created change object is given the condition of a predicate that matches the feature values passed in for the domain. :param list args: Two feature expressions, parsed into dictionaries. :returns: A Change object. """ domain, codomain = args[0], args[1] ch = Change() for name, value in codomain.items(): ch = ch.do(lambda td: change_functions.change_feature( td.phoneme, name, value)) def match_features(p, fdict=domain): """ Function that closes over the change domain. Matches the domain feature values with the target phoneme's features. """ for name, value in fdict.items(): if not p.feature_is(name, value): return False return True ch = ch.to(This.forall(Phone)(match_features)) return ch
def intervocal_voicing(this): return change.Change().do( lambda this: change_functions.change_feature( this.phoneme, "voice", True)).to( change.This.forall(Phone)(make_predicate(this))).when( change.This.at(Phone, -1, lambda p: p.is_vowel())).when( change.This.at(Phone, 1, lambda p: p.is_vowel()))
def lengthen(phone): return change.Change().do( lambda this: change_functions.change_feature( this.phoneme, "long", True) ).to(change.This.forall(Phone)(make_predicate(phone)))