mirror of
https://github.com/kennethreitz/rhymepad.org.git
synced 2026-06-11 17:08:33 +00:00
Words inside grouped phrases keep word-level rhyme rights
The pass-4 suppression predates fills-only rendering; mind/time now pair even while «all this time» rides its mosaic. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -800,17 +800,13 @@ def analyze(draft: Draft):
|
||||
group_by_vc = gmap_for("vc")
|
||||
# a word inside an already-grouped phrase sits this pass out,
|
||||
# so "door" doesn't fight "door hinge" for the highlight
|
||||
phrase_spans = defaultdict(list)
|
||||
for p in phrases:
|
||||
if id(p) in grouped:
|
||||
phrase_spans[p["line"]].append((p["start"], p["end"]))
|
||||
# (words inside grouped phrases used to sit this pass out; with
|
||||
# fills-only rendering, word and phrase paint coexist — "time" can
|
||||
# rhyme "mind" even while «all this time» rides a mosaic)
|
||||
by_vc = defaultdict(list)
|
||||
for t in tokens:
|
||||
if id(t) in grouped:
|
||||
continue
|
||||
if any(s < t["end"] and t["start"] < e
|
||||
for s, e in phrase_spans[t["line"]]):
|
||||
continue
|
||||
w = t["word"].lower()
|
||||
if not t["is_end"] and (w in STOPWORDS or w in refrain or len(w) < 2):
|
||||
continue
|
||||
|
||||
@@ -532,3 +532,12 @@ def test_word_info():
|
||||
info = word_info(word="tonight")
|
||||
assert info["syl"] == 2 and info["stress"] == "01"
|
||||
assert info["rime"] == "AY T"
|
||||
|
||||
|
||||
def test_word_inside_grouped_phrase_still_rhymes():
|
||||
# «all this time» rides a mosaic with «lost in my», but the word
|
||||
# time must still pair with mind at word level
|
||||
text = ("lost in my mind for a while\n"
|
||||
"wastin' all this time with style")
|
||||
group_with(text, "mind", "time")
|
||||
group_with(text, "while", "style")
|
||||
|
||||
Reference in New Issue
Block a user