mirror of
https://github.com/kennethreitz/rhymepad.org.git
synced 2026-06-11 17:08:33 +00:00
Family inspector + strength-as-saturation
#4: caret in a colored word names its family in the readout — "rhymes ay t — night, light, flight". The colors stop being a mystery. #5: slant rhymes render at 62% of a perfect rhyme's fill, so the page shows match strength, not just match presence. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1238,7 +1238,9 @@ def analyze(draft: Draft):
|
||||
color = min(avail, key=lambda c: (usage[c], c))
|
||||
usage[color] += 1
|
||||
chosen.append(color)
|
||||
groups_out.append({"id": gid, "color": color, "slant": g["slant"]})
|
||||
sound = re.sub(r"^[a-z0-9]+:", "", g["key"]).replace("|", " ").lower()
|
||||
groups_out.append({"id": gid, "color": color, "slant": g["slant"],
|
||||
"sound": sound})
|
||||
|
||||
# stanza rhyme schemes from line-ending groups: the token covering
|
||||
# the most of the line's tail owns the slot — Em rhymes "-cock it",
|
||||
|
||||
@@ -630,6 +630,7 @@ function render(){
|
||||
: (p && (focusGid === null || p.g === focusGid)) ? p
|
||||
: (w || p);
|
||||
let alpha = !t.ph ? (t.end ? 34 : 19) : (t.end ? 24 : 14);
|
||||
if(t.slant) alpha = Math.round(alpha * 0.62); // slant sits back
|
||||
// the caret's family brightens; everything else stays itself
|
||||
if(focusGid !== null && t.g === focusGid){
|
||||
alpha = Math.min(85, Math.round(alpha * 2.8));
|
||||
@@ -802,6 +803,13 @@ function buildReadout(){
|
||||
const shown = sch.slice(0, 16).split('').join(' ') + (sch.length > 16 ? ' …' : '');
|
||||
parts.push(`scheme <b>${shown}</b>`);
|
||||
}
|
||||
if(focusGid !== null && analysis){
|
||||
const g = analysis.groups.find(x=>x.id === focusGid);
|
||||
const fam = [...new Set(analysis.tokens.filter(t=>t.g===focusGid)
|
||||
.map(t=>analysis.lines[t.l].slice(t.s,t.e).toLowerCase()))];
|
||||
if(g && fam.length >= 2)
|
||||
parts.push(`rhymes <b>${esc(g.sound)}</b> — ${esc(fam.slice(0,6).join(', '))}`);
|
||||
}
|
||||
schemeReadout.innerHTML = parts.join(' ');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user