mirror of
https://github.com/kennethreitz/rhymepad.org.git
synced 2026-06-11 17:08:33 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user