Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
after_search = re.search(after_pattern, re_rule)
if before_search is None:
before = None
else:
before = [ipa_class[ipar].to_abstract() for ipar in before_search.group(0)]
if core_search is not None:
core = ipa_class[core_search.group(0)]
else:
logger.error("No core")
raise ValueError
if after_search is None:
after = None
else:
after = [ipa_class[ipar].to_abstract() for ipar in after_search.group(0)]
abstract_position = AbstractPosition(place, before, after)
return Rule(abstract_position, core, ipa_class[estimated_sound])
def __add__(self, other):
assert isinstance(other, Rule)
assert self.position.same_place(other.position)
assert self.temp_sound.ipar == other.temp_sound.ipar
assert self.estimated_sound.ipar == other.estimated_sound.ipar
position = self.position + other.position
return Rule(position, self.temp_sound, self.estimated_sound)
"ll": "lː",
"mm": "mː",
"nn": "nː",
"pp": "pː",
"rr": "rː",
"ss": "sː",
"tt": "tː",
"vv": "vː",
}
# Some Old Norse rules
# The first rule which matches is retained
rule_th = [Rule(AbstractPosition(Rank.first, None, []), th, th),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant(voiced=True)]), th, th),
Rule(AbstractPosition(Rank.inner, [AbstractConsonant(voiced=True)], []), th, th),
Rule(AbstractPosition(Rank.inner, [], []), th, dh),
Rule(AbstractPosition(Rank.last, [], None), th, dh)]
rule_f = [Rule(AbstractPosition(Rank.first, None, []), f, f),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant(voiced=False)]), f, f),
Rule(AbstractPosition(Rank.inner, [AbstractConsonant(voiced=False)], []), f, f),
Rule(AbstractPosition(Rank.inner, [], []), f, v),
Rule(AbstractPosition(Rank.last, [], None), f, v)]
rule_g = [Rule(AbstractPosition(Rank.first, None, None), g, g),
Rule(AbstractPosition(Rank.inner, [n.to_abstract()], None), g, g),
Rule(AbstractPosition(Rank.inner, None, [AbstractConsonant(voiced=False)]), g, k),
Rule(AbstractPosition(Rank.inner, [], []), g, gh),
Rule(AbstractPosition(Rank.last, [], None), g, gh)]
old_norse_rules = []
old_norse_rules.extend(rule_f)
def __add__(self, other):
assert isinstance(other, Rule)
assert self.position.same_place(other.position)
assert self.temp_sound.ipar == other.temp_sound.ipar
assert self.estimated_sound.ipar == other.estimated_sound.ipar
position = self.position + other.position
return Rule(position, self.temp_sound, self.estimated_sound)
"rr": "rː",
"ss": "sː",
"tt": "tː",
"vv": "vː",
}
# Some Old Norse rules
# The first rule which matches is retained
rule_th = [Rule(AbstractPosition(Rank.first, None, []), th, th),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant(voiced=True)]), th, th),
Rule(AbstractPosition(Rank.inner, [AbstractConsonant(voiced=True)], []), th, th),
Rule(AbstractPosition(Rank.inner, [], []), th, dh),
Rule(AbstractPosition(Rank.last, [], None), th, dh)]
rule_f = [Rule(AbstractPosition(Rank.first, None, []), f, f),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant(voiced=False)]), f, f),
Rule(AbstractPosition(Rank.inner, [AbstractConsonant(voiced=False)], []), f, f),
Rule(AbstractPosition(Rank.inner, [], []), f, v),
Rule(AbstractPosition(Rank.last, [], None), f, v)]
rule_g = [Rule(AbstractPosition(Rank.first, None, None), g, g),
Rule(AbstractPosition(Rank.inner, [n.to_abstract()], None), g, g),
Rule(AbstractPosition(Rank.inner, None, [AbstractConsonant(voiced=False)]), g, k),
Rule(AbstractPosition(Rank.inner, [], []), g, gh),
Rule(AbstractPosition(Rank.last, [], None), g, gh)]
old_norse_rules = []
old_norse_rules.extend(rule_f)
old_norse_rules.extend(rule_g)
old_norse_rules.extend(rule_th)
rule_th = [Rule(AbstractPosition(Rank.first, None, []), th, th),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant(voiced=True)]), th, th),
Rule(AbstractPosition(Rank.inner, [AbstractConsonant(voiced=True)], []), th, th),
Rule(AbstractPosition(Rank.inner, [], []), th, dh),
Rule(AbstractPosition(Rank.last, [], None), th, dh)]
rule_f = [Rule(AbstractPosition(Rank.first, None, []), f, f),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant(voiced=False)]), f, f),
Rule(AbstractPosition(Rank.inner, [AbstractConsonant(voiced=False)], []), f, f),
Rule(AbstractPosition(Rank.inner, [], []), f, v),
Rule(AbstractPosition(Rank.last, [], None), f, v)]
rule_g = [Rule(AbstractPosition(Rank.first, None, None), g, g),
Rule(AbstractPosition(Rank.inner, [n.to_abstract()], None), g, g),
Rule(AbstractPosition(Rank.inner, None, [AbstractConsonant(voiced=False)]), g, k),
Rule(AbstractPosition(Rank.inner, [], []), g, gh),
Rule(AbstractPosition(Rank.last, [], None), g, gh)]
old_norse_rules = []
old_norse_rules.extend(rule_f)
old_norse_rules.extend(rule_g)
old_norse_rules.extend(rule_th)
def measure_old_norse_syllable(syllable: list) -> Union[Length, None]:
"""
Old Norse syllables are considered as:
- short if
- long if
- overlong if
>>> measure_old_norse_syllable([m, a.lengthen(), l]).name