Skip to content

Make syllabification a value and fix the synalepha across punctuation - #7

Merged
neburnodrog merged 3 commits into
mainfrom
refactor/syllabification-value
Oct 3, 2026
Merged

neburnodrog merged 3 commits into
mainfrom
refactor/syllabification-value

Conversation

@neburnodrog

Copy link
Copy Markdown
Owner

A word's syllable division was carried between modules as a hyphenated string. Twenty three places decoded that format with count("-"), lstrip("-"), find("-", 1) and replace("-", ""). Now one does.

What changed

Syllabification is a frozen dataclass holding the syllables as a tuple plus the punctuation written before and after them. It renders back to the hyphen form, with or without the leading hyphen, and parses that form once, where the Word stores the syllabifier's output.

The syllabifier itself is untouched. The consonant cluster table, the diphthong merge and the triphthong handling produce what they produced before, and their tests are not in this diff.

Sentence now holds the positions where a synalepha joins a word to the one before it, and derives its readable list from them. Pyverse counts by summing its words' syllables and subtracting its synalephas, instead of counting hyphens in the rendered string. The check for a final atonic monosyllable that elided is an index test instead of a search through a list of strings.

strip_hyphen is renamed joins_previous_word and gains the corrected condition. That guarded block at the top of the predicate is the whole behaviour change:

Pyverse("el arma ¿antigua?").synalephas  ->  []   (was ['arma ¿antigua?'])

The old predicate read the first character of the syllabified string after stripping hyphens. For a word starting with punctuation that character was neither consonant nor vowel, so it fell through and claimed a synalepha. The count came out right anyway, because lstrip("-") could not remove a hyphen that punctuation had displaced. Two errors cancelled, which is why the fix and the move onto the model are one commit: either alone turns a correct count into an incorrect one.

How to review it

The first commit records a characterization snapshot of 1497 verses at the Pyverse seam, while it still described the old behaviour. It covers every verse literal already in the test suite, a set putting punctuation in every position, and 300 verses generated from a Spanish vocabulary with a fixed seed. The diff against it is the review artifact.

It moves on 686 verses and on no verse without punctuation:

  • 574 report fewer synalephas, and nothing else. This is the fix.
  • 98 contain a token with no letters at all (la casa ... alta). Such a token now carries no syllables and renders as itself, where add_punctuation used to splice hyphens between its characters through replace(""). Count and rendering both move.
  • 14 end in an atonic monosyllable behind an opening mark (el arma ¿y). With the phantom synalepha gone the verse ends in an oxytone, so it counts one more.

The last two go beyond what the spec promised and were both signed off; the spec's ## Comments section records them.

Compatibility

verse.syllables stays a string, verse.synalephas a list of strings, the accentuation integer keeps its meaning, word.rhyme is untouched and the CLI output shape is unchanged.

🤖 Generated with Claude Code

neburnodrog and others added 3 commits September 25, 2026 18:02
The snapshot pins the syllabified text, the count, the synalephas and both
rhymes for 1497 Verses, drawn from the literals already in the test suite, a
set built to put punctuation in every position, and 300 Verses generated from
a Spanish vocabulary with a fixed seed.

It is recorded before any code changes, so the diff against it is the review
artifact for the Syllabification work. It captures the known synalepha defect:
"el arma ¿antigua?" reports a synalepha that is not pronounced.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A word's syllable division was carried between modules as a hyphenated
string. Twenty three places decoded that format with count("-"), lstrip("-"),
find("-", 1) and replace("-", ""). Now one does.

Syllabification is a frozen dataclass holding the syllables as a tuple plus
the punctuation written before and after them. It renders back to the hyphen
form, with or without the leading hyphen, and parses that form once, where the
Word stores the syllabifier's output. The syllabifier itself is untouched: the
consonant cluster table, the diphthong merge and the triphthong handling all
produce what they produced before.

The Sentence now holds the positions where a synalepha joins a word to the one
before it, and derives its readable list from them. The Verse counts by summing
its words' syllables and subtracting its synalephas, instead of counting
hyphens in the rendered string. The check for a final atonic monosyllable that
elided is an index test instead of a search through a list of strings.

strip_hyphen is renamed to joins_previous_word and gains the corrected
condition, which is the whole behaviour change and the one guarded block at the
top of the predicate:

    Pyverse("el arma ¿antigua?").synalephas  ->  []   (was ['arma ¿antigua?'])

The old predicate read the first character of the syllabified string after
stripping hyphens. For a word starting with punctuation that character was
neither consonant nor vowel, so it fell through and claimed a synalepha. The
count came out right anyway because lstrip("-") could not remove a hyphen that
punctuation had displaced. Two errors cancelled. Moving the count onto the
model without fixing the predicate would have turned a correct count into an
incorrect one, so both changes are here.

The snapshot moves on 686 of its 1497 verses, in three groups, and on no verse
without punctuation:

- 574 report fewer synalephas, and nothing else. This is the fix.
- 98 contain a token with no letters at all ("la casa ... alta"). Such a token
  now carries no syllables and renders as itself, where add_punctuation used to
  splice hyphens between its characters through replace(""). Count and rendering
  both move. This was agreed with the maintainer.
- 14 end in an atonic monosyllable behind an opening mark ("el arma ¿y"). With
  the phantom synalepha gone the verse ends in an oxytone, so it counts one
  more.

verse.syllables stays a string, verse.synalephas a list of strings, the
accentuation integer keeps its meaning and word.rhyme is untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Name the synalepha positions for what they hold. State the punctuation rule in
the glossary and once in the predicate, not four times. Import the snapshot
through the tests package instead of through a sys.path insert.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@neburnodrog
neburnodrog merged commit 7d3d40a into main Oct 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant