Skip to content
Snippets Groups Projects
Commit e53370d8 authored by Simon Will's avatar Simon Will
Browse files

Fix bug in elision recognition

parent b7e7e306
No related branches found
No related tags found
No related merge requests found
......@@ -221,7 +221,9 @@ def get_syllables_for_token(token: Token):
syllable_length=syll_vowel_length)
syllables.append(syll)
else:
syllables = []
if not token.is_punct():
syllables = [Syllable(syllable=token.text, span=token.span, idx=None,
vowel_length=1, syllable_length=1)]
return syllables
......@@ -269,12 +271,21 @@ def positional_lengthening(verse):
def make_elisions(verse):
for reading in verse.readings:
for i, token in enumerate(reading.tokens):
if i < len(reading.tokens) - 1:
if not token.is_punct() and i < len(reading.tokens) - 1:
this_syllable = token.syllables[-1]
next_syllable = reading.tokens[i+1].syllables[0]
j = i
for j in range(i + 1, len(reading.tokens)):
if not reading.tokens[j].is_punct():
next_syllable = reading.tokens[j].syllables[0]
break
else:
# No succeeding syllable has been found.
# Break the for and continue with the next reading.
break
m = re.search(r'[aeiouy][mh]*$', this_syllable.text)
if m:
if re.search(r'h?[aeiouy]', next_syllable.text):
if re.search(r'^h?[aeiouy]', next_syllable.text):
# Elision!
this_syllable.phenomena['elision'] = Phenomenon(omitted=m.group())
this_syllable.syllable_length = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment