From 4d024c7194f063f3f6122adb6bf623f0b2cf832a Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 7 Jun 2026 02:35:54 -0400 Subject: [PATCH] Phrases yield only when both halves already rhyme beast mode / sleep though / seats though: the though half rhyming shouldn't suppress the phrase that carries the beast/sleep/seats half. Pure-redundancy phrases (oh my over oh+my) still yield. Co-Authored-By: Claude Opus 4.8 (1M context) --- app.py | 9 +++++++-- tests/test_rhymes.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 58f5aec..77d21cb 100644 --- a/app.py +++ b/app.py @@ -551,8 +551,13 @@ def analyze(draft: Draft): for p in phrases: if p["weak"]: continue - if any(s < p["end"] and p["start"] < e - for s, e in grouped_spans[p["line"]]): + # a phrase yields only when BOTH its halves already rhyme (pure + # redundancy); if one half is new, the phrase carries information + # (beast mode / sleep though: though already rhymes, beast doesn't) + spans = grouped_spans[p["line"]] + a_taken = any(s <= p["start"] < e for s, e in spans) + b_taken = any(s < p["end"] <= e for s, e in spans) + if a_taken and b_taken: continue vs = p["vowels"] if len(vs) >= 3 or (len(vs) == 2 and vs[1] not in REDUCED): diff --git a/tests/test_rhymes.py b/tests/test_rhymes.py index c1f2f80..05d0cda 100644 --- a/tests/test_rhymes.py +++ b/tests/test_rhymes.py @@ -336,3 +336,14 @@ def test_schwa_phrase_needs_consonant_support(): text = ("Looming over your shoulder, like a sloth hugs a tree,\n" "Thinking it won't fall, yet there it goes. Damn, it's free.") assert "sloth hugs" not in highlighted(text) + + +def test_phrase_with_one_new_half_is_not_suppressed(): + # though/mode already rhyme as words, but beast/sleep/seats only + # rhyme through the phrase pairs — those must survive + text = ("Look, I woke up in beast mode\n" + "With my girl, that's beauty and the beast though\n" + "Been top 5, these niggas sleep though\n" + "Only thing that sold out is the seats though") + group_with(text, "beast mode", "beast though", "sleep though", + "seats though")