mirror of
https://github.com/kennethreitz/rhymepad.org.git
synced 2026-06-11 17:08:33 +00:00
Rapper-native: ad-lib awareness and a bar counter
Inline (parentheticals) are delivery, not text — they no longer rhyme
or steal the line-ending slot ("...bunch (yeah)" rhymes on bunch).
The readout leads with "bar 3/16" for the caret's place in its verse.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -476,7 +476,22 @@ def analyze(draft: Draft):
|
||||
for i, line in enumerate(lines):
|
||||
if sids[i] is None:
|
||||
continue
|
||||
matches = list(WORD_RE.finditer(line))
|
||||
# ad-libs — anything in (parens) mid-line — are delivery, not
|
||||
# text: they don't rhyme and can't claim the line-ending slot
|
||||
adlib, depth, astart = [], 0, None
|
||||
for j, ch in enumerate(line):
|
||||
if ch == "(":
|
||||
if depth == 0:
|
||||
astart = j
|
||||
depth += 1
|
||||
elif ch == ")" and depth:
|
||||
depth -= 1
|
||||
if depth == 0:
|
||||
adlib.append((astart, j + 1))
|
||||
if depth:
|
||||
adlib.append((astart, len(line)))
|
||||
matches = [m for m in WORD_RE.finditer(line)
|
||||
if not any(s <= m.start() < e for s, e in adlib)]
|
||||
for j, m in enumerate(matches):
|
||||
tokens.append({
|
||||
"line": i, "start": m.start(), "end": m.end(),
|
||||
|
||||
Reference in New Issue
Block a user