@domandigital/craft 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/CHARACTER.md +41 -6
- package/COPY.md +5 -0
- package/README.md +31 -1
- package/REGISTERS.md +163 -0
- package/dist/{audit-UJCUWORL.js → audit-4SFSLCKY.js} +3 -2
- package/dist/audit.cjs +1 -1
- package/dist/audit.d.cts +7 -0
- package/dist/audit.d.ts +7 -0
- package/dist/audit.js +1 -1
- package/dist/chunk-4QWEAL4G.js +1595 -0
- package/dist/{chunk-WAV6AKR4.js → chunk-6TSDYETQ.js} +4 -2
- package/dist/{chunk-TQKDCA4V.js → chunk-DARKHE6A.js} +7 -5
- package/dist/{chunk-LXDNIJFG.js → chunk-O5B5ELJH.js} +28 -20
- package/dist/chunk-QIEDBL4J.js +9 -0
- package/dist/{chunk-CVG5GSMN.js → chunk-RJVG5KA6.js} +8 -6
- package/dist/{chunk-YK2FFL6Z.js → chunk-SL5VZJ2J.js} +1 -1
- package/dist/{chunk-B2MJLGF6.js → chunk-WFB6F3BN.js} +65 -1633
- package/dist/{chunk-LWVGIJ5A.js → chunk-ZUYERAFM.js} +11 -6
- package/dist/{cli-AVYNHBFJ.js → cli-BN4IT6N2.js} +5 -3
- package/dist/{cli-PEATEW57.js → cli-GXIW7F3E.js} +7 -5
- package/dist/cli-JB4X5LAG.js +1573 -0
- package/dist/{cli-52M62QBN.js → cli-JZRQBCD4.js} +7 -5
- package/dist/{cli-3GQROFCB.js → cli-MDW7JTEF.js} +15 -10
- package/dist/{cli-CWORJYOU.js → cli-V44QEVS6.js} +12 -9
- package/dist/{cli-K4LSRYBE.js → cli-Y7Y5IROK.js} +8 -5
- package/dist/cli.js +4 -2
- package/dist/index.cjs +1549 -101
- package/dist/index.d.cts +247 -1
- package/dist/index.d.ts +247 -1
- package/dist/index.js +1529 -101
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -300,6 +300,241 @@ function checkPair(text, background) {
|
|
|
300
300
|
};
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
// src/character/color.ts
|
|
304
|
+
var COLOUR = /#[0-9a-fA-F]{8}\b|#[0-9a-fA-F]{6}\b|#[0-9a-fA-F]{3,4}\b|\b(?:rgba?|hsla?|oklch|oklab)\([^)]*\)|\bcolor\(\s*srgb\b[^)]*\)/g;
|
|
305
|
+
function num(token, percentOf) {
|
|
306
|
+
const t = token.trim();
|
|
307
|
+
if (t.endsWith("%")) return parseFloat(t) / 100 * percentOf;
|
|
308
|
+
return parseFloat(t);
|
|
309
|
+
}
|
|
310
|
+
function parts(fn) {
|
|
311
|
+
const inner = fn.slice(fn.indexOf("(") + 1, -1).trim();
|
|
312
|
+
const [main, slashAlpha] = inner.split("/");
|
|
313
|
+
const channels = main.split(/[\s,]+/).filter(Boolean);
|
|
314
|
+
let alpha = 1;
|
|
315
|
+
if (slashAlpha !== void 0) alpha = num(slashAlpha, 1);
|
|
316
|
+
else if (channels.length === 4) alpha = num(channels.pop(), 1);
|
|
317
|
+
return { channels, alpha: Number.isFinite(alpha) ? alpha : 1 };
|
|
318
|
+
}
|
|
319
|
+
function hslToRgb(h, s, l) {
|
|
320
|
+
const k = (n) => (n + h / 30) % 12;
|
|
321
|
+
const a = s * Math.min(l, 1 - l);
|
|
322
|
+
const f4 = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
323
|
+
return { r: f4(0), g: f4(8), b: f4(4) };
|
|
324
|
+
}
|
|
325
|
+
var clamp012 = (n) => Math.min(1, Math.max(0, n));
|
|
326
|
+
function parseColour(raw) {
|
|
327
|
+
try {
|
|
328
|
+
if (raw.startsWith("#")) {
|
|
329
|
+
const hex2 = raw.slice(1);
|
|
330
|
+
const alpha2 = hex2.length === 8 ? parseInt(hex2.slice(6), 16) / 255 : hex2.length === 4 ? parseInt(hex2[3] + hex2[3], 16) / 255 : 1;
|
|
331
|
+
return { oklch: hexToOklch(raw), alpha: alpha2 };
|
|
332
|
+
}
|
|
333
|
+
const fn = raw.slice(0, raw.indexOf("(")).toLowerCase();
|
|
334
|
+
if (fn === "color") {
|
|
335
|
+
const { channels: channels2, alpha: alpha2 } = parts(raw.replace(/^color\(\s*srgb\s+/i, "srgb("));
|
|
336
|
+
const [r, g, b] = channels2.map((c) => clamp012(num(c, 1)));
|
|
337
|
+
if (![r, g, b].every(Number.isFinite)) return null;
|
|
338
|
+
return { oklch: hexToOklch(formatHex({ r, g, b })), alpha: alpha2 };
|
|
339
|
+
}
|
|
340
|
+
const { channels, alpha } = parts(raw);
|
|
341
|
+
if (channels.length < 3 || channels.some((c) => c.startsWith("var"))) return null;
|
|
342
|
+
if (fn === "oklch") {
|
|
343
|
+
const l = num(channels[0], 1);
|
|
344
|
+
const c = num(channels[1], 0.4);
|
|
345
|
+
const h = parseFloat(channels[2]);
|
|
346
|
+
if (![l, c].every(Number.isFinite)) return null;
|
|
347
|
+
return { oklch: { l, c, h: Number.isFinite(h) ? h : 0 }, alpha };
|
|
348
|
+
}
|
|
349
|
+
if (fn === "oklab") {
|
|
350
|
+
const l = num(channels[0], 1);
|
|
351
|
+
const a = num(channels[1], 0.4);
|
|
352
|
+
const b = num(channels[2], 0.4);
|
|
353
|
+
if (![l, a, b].every(Number.isFinite)) return null;
|
|
354
|
+
const c = Math.sqrt(a * a + b * b);
|
|
355
|
+
const h = c < 1e-7 ? 0 : (Math.atan2(b, a) * 180 / Math.PI % 360 + 360) % 360;
|
|
356
|
+
return { oklch: { l, c, h }, alpha };
|
|
357
|
+
}
|
|
358
|
+
if (fn === "rgb" || fn === "rgba") {
|
|
359
|
+
const [r, g, b] = channels.map((c) => clamp012(num(c, 255) / 255));
|
|
360
|
+
if (![r, g, b].every(Number.isFinite)) return null;
|
|
361
|
+
return { oklch: hexToOklch(formatHex({ r, g, b })), alpha };
|
|
362
|
+
}
|
|
363
|
+
if (fn === "hsl" || fn === "hsla") {
|
|
364
|
+
const h = parseFloat(channels[0]);
|
|
365
|
+
const s = num(channels[1], 1);
|
|
366
|
+
const l = num(channels[2], 1);
|
|
367
|
+
if (![h, s, l].every(Number.isFinite)) return null;
|
|
368
|
+
const rgb = hslToRgb((h % 360 + 360) % 360, clamp012(s), clamp012(l));
|
|
369
|
+
return { oklch: hexToOklch(formatHex(rgb)), alpha };
|
|
370
|
+
}
|
|
371
|
+
} catch {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
function findColours(value) {
|
|
377
|
+
const out = [];
|
|
378
|
+
for (const m of value.matchAll(COLOUR)) {
|
|
379
|
+
const parsed = parseColour(m[0]);
|
|
380
|
+
if (parsed) out.push({ raw: m[0], ...parsed, index: m.index ?? 0 });
|
|
381
|
+
}
|
|
382
|
+
return out;
|
|
383
|
+
}
|
|
384
|
+
var AI_VIOLET = { hueMin: 268, hueMax: 312, minChroma: 0.1, minL: 0.3, maxL: 0.85 };
|
|
385
|
+
function isAiViolet({ l, c, h }) {
|
|
386
|
+
return c >= AI_VIOLET.minChroma && h >= AI_VIOLET.hueMin && h <= AI_VIOLET.hueMax && l >= AI_VIOLET.minL && l <= AI_VIOLET.maxL;
|
|
387
|
+
}
|
|
388
|
+
function isCream({ l, c, h }) {
|
|
389
|
+
return l >= 0.9 && l <= 0.985 && c >= 8e-3 && c <= 0.06 && h >= 55 && h <= 105;
|
|
390
|
+
}
|
|
391
|
+
function isBlueToPurple({ c, h }) {
|
|
392
|
+
return c >= 0.08 && h >= 240 && h <= 330;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// src/color/gradient.ts
|
|
396
|
+
var KEYWORDS = {
|
|
397
|
+
white: { r: 1, g: 1, b: 1, a: 1 },
|
|
398
|
+
black: { r: 0, g: 0, b: 0, a: 1 },
|
|
399
|
+
transparent: { r: 0, g: 0, b: 0, a: 0 }
|
|
400
|
+
};
|
|
401
|
+
var clamp013 = (n) => Math.min(1, Math.max(0, n));
|
|
402
|
+
function toRgba(raw) {
|
|
403
|
+
const value = raw.trim().toLowerCase();
|
|
404
|
+
if (KEYWORDS[value]) return KEYWORDS[value];
|
|
405
|
+
if (/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(value)) {
|
|
406
|
+
const h = value.length <= 5 ? [...value.slice(1)].map((c) => c + c).join("") : value.slice(1);
|
|
407
|
+
const { r: r2, g: g2, b: b2 } = parseHex(h.slice(0, 6));
|
|
408
|
+
return { r: r2, g: g2, b: b2, a: h.length === 8 ? parseInt(h.slice(6), 16) / 255 : 1 };
|
|
409
|
+
}
|
|
410
|
+
const rgb = /^rgba?\(([^)]+)\)$/.exec(value);
|
|
411
|
+
if (rgb) {
|
|
412
|
+
const parts2 = rgb[1].split(/[\s,/]+/).filter(Boolean);
|
|
413
|
+
const channel = (p) => p.endsWith("%") ? parseFloat(p) / 100 : parseFloat(p) / 255;
|
|
414
|
+
const alpha = parts2[3] === void 0 ? 1 : parts2[3].endsWith("%") ? parseFloat(parts2[3]) / 100 : parseFloat(parts2[3]);
|
|
415
|
+
const [r2, g2, b2] = parts2.slice(0, 3).map(channel);
|
|
416
|
+
if (parts2.length >= 3 && [r2, g2, b2, alpha].every(Number.isFinite)) return { r: clamp013(r2), g: clamp013(g2), b: clamp013(b2), a: clamp013(alpha) };
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
const parsed = parseColour(value);
|
|
420
|
+
if (!parsed) return null;
|
|
421
|
+
const { r, g, b } = oklchToRgb(parsed.oklch);
|
|
422
|
+
return { r: clamp013(r), g: clamp013(g), b: clamp013(b), a: clamp013(parsed.alpha) };
|
|
423
|
+
}
|
|
424
|
+
var SAMPLES_PER_SEGMENT = 256;
|
|
425
|
+
function mix(a, b, t) {
|
|
426
|
+
const alpha = a.a + (b.a - a.a) * t;
|
|
427
|
+
if (alpha === 0) return { r: 0, g: 0, b: 0, a: 0 };
|
|
428
|
+
const ch = (x, y) => (x * a.a + (y * b.a - x * a.a) * t) / alpha;
|
|
429
|
+
return { r: ch(a.r, b.r), g: ch(a.g, b.g), b: ch(a.b, b.b), a: alpha };
|
|
430
|
+
}
|
|
431
|
+
function composite(top, under) {
|
|
432
|
+
return {
|
|
433
|
+
r: top.r * top.a + under.r * (1 - top.a),
|
|
434
|
+
g: top.g * top.a + under.g * (1 - top.a),
|
|
435
|
+
b: top.b * top.a + under.b * (1 - top.a)
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function gradientStops(gradient) {
|
|
439
|
+
const inner = /gradient\(([\s\S]*)\)\s*$/.exec(gradient.trim());
|
|
440
|
+
if (!inner) throw new Error(`not a CSS gradient: ${gradient}`);
|
|
441
|
+
const parts2 = [];
|
|
442
|
+
let depth = 0;
|
|
443
|
+
let current = "";
|
|
444
|
+
for (const ch of inner[1]) {
|
|
445
|
+
if (ch === "(") depth += 1;
|
|
446
|
+
if (ch === ")") depth -= 1;
|
|
447
|
+
if (ch === "," && depth === 0) {
|
|
448
|
+
parts2.push(current.trim());
|
|
449
|
+
current = "";
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
current += ch;
|
|
453
|
+
}
|
|
454
|
+
if (current.trim()) parts2.push(current.trim());
|
|
455
|
+
const stops = [];
|
|
456
|
+
for (const part of parts2) {
|
|
457
|
+
const colour = part.replace(/(\s+-?[\d.]+(%|px|r?em|deg|turn|vw|vh))+\s*$/i, "").trim();
|
|
458
|
+
if (/^(to\s|circle|ellipse|closest|farthest|at\s|from\s|in\s|-?[\d.]+(deg|turn|rad|grad)$)/i.test(colour)) continue;
|
|
459
|
+
if (!toRgba(colour)) throw new Error(`unreadable gradient stop "${colour}" in ${gradient}`);
|
|
460
|
+
stops.push(colour);
|
|
461
|
+
}
|
|
462
|
+
if (stops.length === 0) throw new Error(`no colour stops in ${gradient}`);
|
|
463
|
+
return stops;
|
|
464
|
+
}
|
|
465
|
+
function gradientContrast(text, gradient, beneath = "#ffffff") {
|
|
466
|
+
const under = toRgba(beneath);
|
|
467
|
+
if (!under || under.a < 1) throw new Error(`beneath must be an opaque colour, got ${beneath}`);
|
|
468
|
+
const fg = toRgba(text);
|
|
469
|
+
if (!fg || fg.a < 1) throw new Error(`text must be an opaque colour, got ${text}`);
|
|
470
|
+
const textHex = formatHex(fg);
|
|
471
|
+
const raw = gradientStops(gradient).map((s) => toRgba(s));
|
|
472
|
+
const stops = raw.map((s) => formatHex(composite(s, under)));
|
|
473
|
+
let worst = stops[0];
|
|
474
|
+
let worstRatio = wcagContrast(textHex, worst);
|
|
475
|
+
for (let i = 0; i + 1 < raw.length; i++) {
|
|
476
|
+
for (let k = 1; k <= SAMPLES_PER_SEGMENT; k++) {
|
|
477
|
+
const point = formatHex(composite(mix(raw[i], raw[i + 1], k / SAMPLES_PER_SEGMENT), under));
|
|
478
|
+
const ratio = wcagContrast(textHex, point);
|
|
479
|
+
if (ratio < worstRatio) [worst, worstRatio] = [point, ratio];
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const wcag = wcagContrast(textHex, worst);
|
|
483
|
+
const lc = apcaContrast(textHex, worst);
|
|
484
|
+
return {
|
|
485
|
+
text,
|
|
486
|
+
gradient,
|
|
487
|
+
beneath,
|
|
488
|
+
stops,
|
|
489
|
+
worst,
|
|
490
|
+
wcag,
|
|
491
|
+
lc,
|
|
492
|
+
passesAA: wcag >= 4.5,
|
|
493
|
+
passesAALarge: wcag >= 3,
|
|
494
|
+
note: `${text} on ${gradient} over ${beneath}: worst point ${worst}, ${wcag.toFixed(2)}:1, Lc ${lc.toFixed(1)}`
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// src/photo/review.ts
|
|
499
|
+
function checkPhotoReview(text, options = {}) {
|
|
500
|
+
const minScore = options.minScore ?? 0.7;
|
|
501
|
+
const required = options.required ?? true;
|
|
502
|
+
const failures = [];
|
|
503
|
+
const report2 = [];
|
|
504
|
+
const add = (ok, message) => {
|
|
505
|
+
report2.push(`${ok ? "ok " : "FAIL"} ${message}`);
|
|
506
|
+
if (!ok) failures.push(message);
|
|
507
|
+
};
|
|
508
|
+
const done = () => ({ ok: failures.length === 0, failures, report: report2 });
|
|
509
|
+
if (text === null) {
|
|
510
|
+
if (required) add(false, "no photo review: run `halide review --json`");
|
|
511
|
+
else report2.push("ok no photo review, and none required");
|
|
512
|
+
return done();
|
|
513
|
+
}
|
|
514
|
+
let parsed;
|
|
515
|
+
try {
|
|
516
|
+
parsed = JSON.parse(text);
|
|
517
|
+
} catch (error) {
|
|
518
|
+
add(false, `the photo review is not valid JSON: ${error.message}`);
|
|
519
|
+
return done();
|
|
520
|
+
}
|
|
521
|
+
const images = Array.isArray(parsed.images) ? parsed.images : [];
|
|
522
|
+
const overall = typeof parsed.score === "number" ? parsed.score : null;
|
|
523
|
+
if (overall === null && images.length === 0) {
|
|
524
|
+
add(false, "the photo review has neither a score nor an images list");
|
|
525
|
+
return done();
|
|
526
|
+
}
|
|
527
|
+
if (overall !== null) add(overall >= minScore, `overall score ${overall.toFixed(2)} against a minimum of ${minScore.toFixed(2)}`);
|
|
528
|
+
const below = images.filter((i) => typeof i.score === "number" && i.score < minScore);
|
|
529
|
+
if (below.length > 0) {
|
|
530
|
+
const named = below.slice(0, 5).map((i) => `${i.file ?? i.id ?? "?"} (${i.score.toFixed(2)})`).join(", ");
|
|
531
|
+
add(false, `${below.length} of ${images.length} image(s) below ${minScore.toFixed(2)}: ${named}`);
|
|
532
|
+
} else if (images.length > 0) {
|
|
533
|
+
add(true, `all ${images.length} image(s) at or above ${minScore.toFixed(2)}`);
|
|
534
|
+
}
|
|
535
|
+
return done();
|
|
536
|
+
}
|
|
537
|
+
|
|
303
538
|
// src/color/semantic.ts
|
|
304
539
|
function accentFork(rampSteps, on, options = {}) {
|
|
305
540
|
const minWcag = options.minWcag ?? 4.5;
|
|
@@ -2547,98 +2782,6 @@ ${filler(520, 11)}`)]
|
|
|
2547
2782
|
}
|
|
2548
2783
|
];
|
|
2549
2784
|
|
|
2550
|
-
// src/character/color.ts
|
|
2551
|
-
var COLOUR = /#[0-9a-fA-F]{8}\b|#[0-9a-fA-F]{6}\b|#[0-9a-fA-F]{3,4}\b|\b(?:rgba?|hsla?|oklch|oklab)\([^)]*\)|\bcolor\(\s*srgb\b[^)]*\)/g;
|
|
2552
|
-
function num(token, percentOf) {
|
|
2553
|
-
const t = token.trim();
|
|
2554
|
-
if (t.endsWith("%")) return parseFloat(t) / 100 * percentOf;
|
|
2555
|
-
return parseFloat(t);
|
|
2556
|
-
}
|
|
2557
|
-
function parts(fn) {
|
|
2558
|
-
const inner = fn.slice(fn.indexOf("(") + 1, -1).trim();
|
|
2559
|
-
const [main, slashAlpha] = inner.split("/");
|
|
2560
|
-
const channels = main.split(/[\s,]+/).filter(Boolean);
|
|
2561
|
-
let alpha = 1;
|
|
2562
|
-
if (slashAlpha !== void 0) alpha = num(slashAlpha, 1);
|
|
2563
|
-
else if (channels.length === 4) alpha = num(channels.pop(), 1);
|
|
2564
|
-
return { channels, alpha: Number.isFinite(alpha) ? alpha : 1 };
|
|
2565
|
-
}
|
|
2566
|
-
function hslToRgb(h, s, l) {
|
|
2567
|
-
const k = (n) => (n + h / 30) % 12;
|
|
2568
|
-
const a = s * Math.min(l, 1 - l);
|
|
2569
|
-
const f4 = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
2570
|
-
return { r: f4(0), g: f4(8), b: f4(4) };
|
|
2571
|
-
}
|
|
2572
|
-
var clamp012 = (n) => Math.min(1, Math.max(0, n));
|
|
2573
|
-
function parseColour(raw) {
|
|
2574
|
-
try {
|
|
2575
|
-
if (raw.startsWith("#")) {
|
|
2576
|
-
const hex2 = raw.slice(1);
|
|
2577
|
-
const alpha2 = hex2.length === 8 ? parseInt(hex2.slice(6), 16) / 255 : hex2.length === 4 ? parseInt(hex2[3] + hex2[3], 16) / 255 : 1;
|
|
2578
|
-
return { oklch: hexToOklch(raw), alpha: alpha2 };
|
|
2579
|
-
}
|
|
2580
|
-
const fn = raw.slice(0, raw.indexOf("(")).toLowerCase();
|
|
2581
|
-
if (fn === "color") {
|
|
2582
|
-
const { channels: channels2, alpha: alpha2 } = parts(raw.replace(/^color\(\s*srgb\s+/i, "srgb("));
|
|
2583
|
-
const [r, g, b] = channels2.map((c) => clamp012(num(c, 1)));
|
|
2584
|
-
if (![r, g, b].every(Number.isFinite)) return null;
|
|
2585
|
-
return { oklch: hexToOklch(formatHex({ r, g, b })), alpha: alpha2 };
|
|
2586
|
-
}
|
|
2587
|
-
const { channels, alpha } = parts(raw);
|
|
2588
|
-
if (channels.length < 3 || channels.some((c) => c.startsWith("var"))) return null;
|
|
2589
|
-
if (fn === "oklch") {
|
|
2590
|
-
const l = num(channels[0], 1);
|
|
2591
|
-
const c = num(channels[1], 0.4);
|
|
2592
|
-
const h = parseFloat(channels[2]);
|
|
2593
|
-
if (![l, c].every(Number.isFinite)) return null;
|
|
2594
|
-
return { oklch: { l, c, h: Number.isFinite(h) ? h : 0 }, alpha };
|
|
2595
|
-
}
|
|
2596
|
-
if (fn === "oklab") {
|
|
2597
|
-
const l = num(channels[0], 1);
|
|
2598
|
-
const a = num(channels[1], 0.4);
|
|
2599
|
-
const b = num(channels[2], 0.4);
|
|
2600
|
-
if (![l, a, b].every(Number.isFinite)) return null;
|
|
2601
|
-
const c = Math.sqrt(a * a + b * b);
|
|
2602
|
-
const h = c < 1e-7 ? 0 : (Math.atan2(b, a) * 180 / Math.PI % 360 + 360) % 360;
|
|
2603
|
-
return { oklch: { l, c, h }, alpha };
|
|
2604
|
-
}
|
|
2605
|
-
if (fn === "rgb" || fn === "rgba") {
|
|
2606
|
-
const [r, g, b] = channels.map((c) => clamp012(num(c, 255) / 255));
|
|
2607
|
-
if (![r, g, b].every(Number.isFinite)) return null;
|
|
2608
|
-
return { oklch: hexToOklch(formatHex({ r, g, b })), alpha };
|
|
2609
|
-
}
|
|
2610
|
-
if (fn === "hsl" || fn === "hsla") {
|
|
2611
|
-
const h = parseFloat(channels[0]);
|
|
2612
|
-
const s = num(channels[1], 1);
|
|
2613
|
-
const l = num(channels[2], 1);
|
|
2614
|
-
if (![h, s, l].every(Number.isFinite)) return null;
|
|
2615
|
-
const rgb = hslToRgb((h % 360 + 360) % 360, clamp012(s), clamp012(l));
|
|
2616
|
-
return { oklch: hexToOklch(formatHex(rgb)), alpha };
|
|
2617
|
-
}
|
|
2618
|
-
} catch {
|
|
2619
|
-
return null;
|
|
2620
|
-
}
|
|
2621
|
-
return null;
|
|
2622
|
-
}
|
|
2623
|
-
function findColours(value) {
|
|
2624
|
-
const out = [];
|
|
2625
|
-
for (const m of value.matchAll(COLOUR)) {
|
|
2626
|
-
const parsed = parseColour(m[0]);
|
|
2627
|
-
if (parsed) out.push({ raw: m[0], ...parsed, index: m.index ?? 0 });
|
|
2628
|
-
}
|
|
2629
|
-
return out;
|
|
2630
|
-
}
|
|
2631
|
-
var AI_VIOLET = { hueMin: 268, hueMax: 312, minChroma: 0.1, minL: 0.3, maxL: 0.85 };
|
|
2632
|
-
function isAiViolet({ l, c, h }) {
|
|
2633
|
-
return c >= AI_VIOLET.minChroma && h >= AI_VIOLET.hueMin && h <= AI_VIOLET.hueMax && l >= AI_VIOLET.minL && l <= AI_VIOLET.maxL;
|
|
2634
|
-
}
|
|
2635
|
-
function isCream({ l, c, h }) {
|
|
2636
|
-
return l >= 0.9 && l <= 0.985 && c >= 8e-3 && c <= 0.06 && h >= 55 && h <= 105;
|
|
2637
|
-
}
|
|
2638
|
-
function isBlueToPurple({ c, h }) {
|
|
2639
|
-
return c >= 0.08 && h >= 240 && h <= 330;
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
2785
|
// src/character/tells/source.ts
|
|
2643
2786
|
function baseClass(cls) {
|
|
2644
2787
|
let depth = 0;
|
|
@@ -4466,7 +4609,7 @@ var SPECIFICITY_COPY_TELLS = [
|
|
|
4466
4609
|
},
|
|
4467
4610
|
rendered: {
|
|
4468
4611
|
detect: (s) => {
|
|
4469
|
-
if (!s.firstScreenText || !HOME_URL.test(s.url)) return [];
|
|
4612
|
+
if (!s.firstScreenText || !(s.home ?? HOME_URL.test(s.url))) return [];
|
|
4470
4613
|
const text = s.firstScreenText.join("\n");
|
|
4471
4614
|
if (!text.trim() || !specificity(text).generic) return [];
|
|
4472
4615
|
const h1 = s.headings.find((h) => h.level === 1 && h.top < s.viewport.height);
|
|
@@ -6244,6 +6387,1270 @@ function lexicalOf(text, brief) {
|
|
|
6244
6387
|
};
|
|
6245
6388
|
}
|
|
6246
6389
|
|
|
6390
|
+
// src/register/features.ts
|
|
6391
|
+
var REGISTER_FEATURES = [
|
|
6392
|
+
"meanSentenceWords",
|
|
6393
|
+
"contractionsPer100",
|
|
6394
|
+
"youPer100",
|
|
6395
|
+
"firstPersonPer100",
|
|
6396
|
+
"passiveShare",
|
|
6397
|
+
"meanWordLength"
|
|
6398
|
+
];
|
|
6399
|
+
var norm = (w) => w.toLowerCase().replace(/’/g, "'");
|
|
6400
|
+
var YOU = /* @__PURE__ */ new Set(["you", "your", "yours", "yourself", "yourselves", "you'll", "you're", "you've", "you'd"]);
|
|
6401
|
+
var FIRST = /* @__PURE__ */ new Set(["i", "me", "my", "mine", "we", "us", "our", "ours", "i'm", "i'll", "i've", "i'd", "we're", "we'll", "we've", "we'd"]);
|
|
6402
|
+
var CONTRACTION2 = /^[a-z]+(?:n't|'ll|'re|'ve|'d|'m)$|^(?:it|that|there|here|what|who|where|how|he|she|let)'s$/;
|
|
6403
|
+
var BE = "(?:am|is|are|was|were|be|been|being|'s|'re|'m)";
|
|
6404
|
+
var IRREGULAR = "(?:made|done|given|taken|seen|known|shown|written|built|sent|paid|held|told|found|kept|left|brought|bought|thought|taught|caught|sold|put|set|run|cut|chosen|driven|eaten|fallen|forgotten|hidden|broken|spoken|stolen|worn|torn|grown|drawn|thrown|flown|begun|sung|won|lost|met|led|read|heard|meant|spent|built|lent|dealt|felt|sought|fed|bred|laid|said|struck|hung|shut|hit|hurt|let|quit|spread|bound|wound|ground|understood|withdrawn|overseen|undertaken)";
|
|
6405
|
+
var PASSIVE = new RegExp(`\\b${BE}\\s+(?:[a-z]+ly\\s+)?(?:[a-z]+ed|[a-z]+en|${IRREGULAR})\\b`, "i");
|
|
6406
|
+
var ADJECTIVAL = /* @__PURE__ */ new Set([
|
|
6407
|
+
"tired",
|
|
6408
|
+
"interested",
|
|
6409
|
+
"excited",
|
|
6410
|
+
"pleased",
|
|
6411
|
+
"worried",
|
|
6412
|
+
"concerned",
|
|
6413
|
+
"surprised",
|
|
6414
|
+
"bored",
|
|
6415
|
+
"scared",
|
|
6416
|
+
"married",
|
|
6417
|
+
"qualified",
|
|
6418
|
+
"experienced",
|
|
6419
|
+
"based",
|
|
6420
|
+
"located",
|
|
6421
|
+
"committed",
|
|
6422
|
+
"dedicated",
|
|
6423
|
+
"delighted",
|
|
6424
|
+
"disappointed",
|
|
6425
|
+
"involved",
|
|
6426
|
+
"prepared",
|
|
6427
|
+
"supposed",
|
|
6428
|
+
"used",
|
|
6429
|
+
"open",
|
|
6430
|
+
"often",
|
|
6431
|
+
"even",
|
|
6432
|
+
"seven",
|
|
6433
|
+
"eleven",
|
|
6434
|
+
"listen",
|
|
6435
|
+
"happen",
|
|
6436
|
+
"then",
|
|
6437
|
+
"when",
|
|
6438
|
+
"ten",
|
|
6439
|
+
"garden",
|
|
6440
|
+
"kitchen",
|
|
6441
|
+
"children",
|
|
6442
|
+
"women",
|
|
6443
|
+
"men",
|
|
6444
|
+
"red",
|
|
6445
|
+
"bed",
|
|
6446
|
+
"need",
|
|
6447
|
+
"indeed",
|
|
6448
|
+
"shed",
|
|
6449
|
+
"seed",
|
|
6450
|
+
"feed",
|
|
6451
|
+
"speed",
|
|
6452
|
+
"hundred"
|
|
6453
|
+
]);
|
|
6454
|
+
function isPassive(sentence) {
|
|
6455
|
+
const re = new RegExp(PASSIVE.source, "gi");
|
|
6456
|
+
for (const m of sentence.matchAll(re)) {
|
|
6457
|
+
const last = norm(m[0].trim().split(/\s+/).pop() ?? "");
|
|
6458
|
+
if (last === "given" && /given\s+that\b/i.test(sentence.slice(m.index ?? 0))) continue;
|
|
6459
|
+
if (!ADJECTIVAL.has(last)) return true;
|
|
6460
|
+
}
|
|
6461
|
+
return false;
|
|
6462
|
+
}
|
|
6463
|
+
function registerOf(text) {
|
|
6464
|
+
const ss = splitSentences(text);
|
|
6465
|
+
const ws = words(text).map(norm);
|
|
6466
|
+
const n = ws.length;
|
|
6467
|
+
const per100 = (k) => n === 0 ? 0 : 100 * k / n;
|
|
6468
|
+
const letters = ws.reduce((s, w) => s + w.replace(/[^a-z]/g, "").length, 0);
|
|
6469
|
+
return {
|
|
6470
|
+
meanSentenceWords: ss.length === 0 ? 0 : n / ss.length,
|
|
6471
|
+
contractionsPer100: per100(ws.filter((w) => CONTRACTION2.test(w)).length),
|
|
6472
|
+
youPer100: per100(ws.filter((w) => YOU.has(w)).length),
|
|
6473
|
+
firstPersonPer100: per100(ws.filter((w) => FIRST.has(w)).length),
|
|
6474
|
+
passiveShare: ss.length === 0 ? 0 : ss.filter(isPassive).length / ss.length,
|
|
6475
|
+
meanWordLength: n === 0 ? 0 : letters / n
|
|
6476
|
+
};
|
|
6477
|
+
}
|
|
6478
|
+
|
|
6479
|
+
// src/register/registers.ts
|
|
6480
|
+
var GOVUK = "GOV.UK writing guidelines";
|
|
6481
|
+
var MAILCHIMP = "Mailchimp Content Style Guide";
|
|
6482
|
+
var OGILVY = "Ogilvy, Ogilvy on Advertising (1983)";
|
|
6483
|
+
var CAPLES = "Caples, Tested Advertising Methods";
|
|
6484
|
+
var HOUSE2 = "house judgement";
|
|
6485
|
+
var ALWAYS = "Every register keeps the COPY.md blocking tier and the proof rule. Draft first, then run `craft copy <file>` on the draft.";
|
|
6486
|
+
var REGISTERS = [
|
|
6487
|
+
{
|
|
6488
|
+
id: "plain",
|
|
6489
|
+
name: "Plain and trustworthy",
|
|
6490
|
+
useFor: "Forms, policies, terms, instructions, and professional services where the reader must act correctly.",
|
|
6491
|
+
directives: [
|
|
6492
|
+
{ text: "Put the most important information first, then taper down to the detail.", from: GOVUK },
|
|
6493
|
+
{ text: "Split any sentence over 25 words into two.", from: GOVUK },
|
|
6494
|
+
{ text: "Choose the short, common word: buy, help, about.", from: GOVUK },
|
|
6495
|
+
{ text: "Write in the active voice, so the reader sees who does what.", from: GOVUK },
|
|
6496
|
+
{ text: 'Address the reader as "you", as one person you can actually help.', from: GOVUK },
|
|
6497
|
+
{ text: `Use positive contractions such as "you'll", and write negatives out in full: "do not", "cannot".`, from: GOVUK },
|
|
6498
|
+
{ text: "Write headings that say what the section tells the reader, starting with a verb where you can.", from: GOVUK },
|
|
6499
|
+
{ text: "Give each paragraph one job.", from: HOUSE2 }
|
|
6500
|
+
],
|
|
6501
|
+
example: {
|
|
6502
|
+
before: "Should you wish to apply for a residents' parking permit, an application form must be completed and submitted to the council prior to the commencement of the permit period.",
|
|
6503
|
+
after: "Apply for a residents' parking permit before you need it. Fill in the form online. It takes about 10 minutes.",
|
|
6504
|
+
why: "The action comes first, the council is no longer the subject, and each sentence does one thing."
|
|
6505
|
+
},
|
|
6506
|
+
sources: [
|
|
6507
|
+
{
|
|
6508
|
+
name: GOVUK,
|
|
6509
|
+
url: "https://guidance.publishing.service.gov.uk/writing-to-gov-uk-standards/writing-guidelines/",
|
|
6510
|
+
note: 'Clear language (the 25-word split, short words, active voice, contractions), clear structure (most important first, headings) and right tone (address the user as "you"). Checked against the live pages on 2026-09-30.'
|
|
6511
|
+
}
|
|
6512
|
+
]
|
|
6513
|
+
},
|
|
6514
|
+
{
|
|
6515
|
+
id: "persuasive",
|
|
6516
|
+
name: "Persuasive and concise",
|
|
6517
|
+
useFor: "Landing pages, service pages, adverts and sales emails: copy whose job is one action.",
|
|
6518
|
+
directives: [
|
|
6519
|
+
{ text: "Put the promise in the headline: what the reader gets, in words they would use.", from: OGILVY },
|
|
6520
|
+
{ text: "Back each claim with something the reader can check: a number, a name, a date, a price.", from: "COPY.md" },
|
|
6521
|
+
{ text: 'Write to one reader, as "you", about their problem before your service.', from: CAPLES },
|
|
6522
|
+
{ text: "Name the mechanism: how it works, how long it takes, what it costs.", from: "COPY.md" },
|
|
6523
|
+
{ text: "Answer the objection the reader already has, with evidence, in the sentence that follows the claim.", from: HOUSE2 },
|
|
6524
|
+
{ text: "Let the copy run as long as the facts last, and cut each sentence that carries none.", from: OGILVY },
|
|
6525
|
+
{ text: "Close with one specific action and what happens straight after it.", from: "COPY.md" }
|
|
6526
|
+
],
|
|
6527
|
+
example: {
|
|
6528
|
+
before: "Transform your garden with our premium landscaping solutions. Quality you can trust.",
|
|
6529
|
+
after: "We lay a 40 square metre Indian sandstone patio in three days, for \xA34,800 fitted. Every job since 2014 is on our reviews page. Book a free site visit and get a fixed quote within 48 hours.",
|
|
6530
|
+
why: "Size, material, time and price replace the adjectives, the proof sits next to the claim, and the close says what happens next. Fictional business."
|
|
6531
|
+
},
|
|
6532
|
+
sources: [
|
|
6533
|
+
{
|
|
6534
|
+
name: OGILVY,
|
|
6535
|
+
note: "Headlines carry the promise because far more people read the headline than the body; specific, informative copy outsells vague copy. Taken from the widely quoted principles; a page-by-page check against the book is still to do."
|
|
6536
|
+
},
|
|
6537
|
+
{
|
|
6538
|
+
name: CAPLES,
|
|
6539
|
+
note: "Headlines that appeal to the reader's self-interest, and copy judged by tested response rather than taste. A page-by-page check against the book is still to do."
|
|
6540
|
+
},
|
|
6541
|
+
{
|
|
6542
|
+
name: "COPY.md",
|
|
6543
|
+
note: "Writing directives (lead with the fact, name the mechanism, persuade with something checkable) and the CTA rule."
|
|
6544
|
+
}
|
|
6545
|
+
]
|
|
6546
|
+
},
|
|
6547
|
+
{
|
|
6548
|
+
id: "warm",
|
|
6549
|
+
name: "Warm and conversational",
|
|
6550
|
+
useFor: "Customer emails, replies to enquiries, newsletters and small-business updates.",
|
|
6551
|
+
directives: [
|
|
6552
|
+
{ text: "Write the way you would talk to a customer you like: contractions, everyday words.", from: MAILCHIMP },
|
|
6553
|
+
{ text: "Keep words and sentences simple; being clear matters more than being entertaining.", from: MAILCHIMP },
|
|
6554
|
+
{ text: "Say what the reader can do, in positive language.", from: MAILCHIMP },
|
|
6555
|
+
{ text: "Use the active voice.", from: MAILCHIMP },
|
|
6556
|
+
{ text: "Match the tone to how the reader feels right now: lighter for good news, calm and direct for a problem.", from: MAILCHIMP },
|
|
6557
|
+
{ text: "Keep humour dry and occasional, and only where it comes naturally.", from: MAILCHIMP },
|
|
6558
|
+
{ text: "Sign off as a person, with a name.", from: HOUSE2 }
|
|
6559
|
+
],
|
|
6560
|
+
example: {
|
|
6561
|
+
before: "Dear Valued Customer, We wish to inform you that your order has been dispatched and will be delivered in due course.",
|
|
6562
|
+
after: "Hi Sam, your order's on its way. It left our Leicester workshop this morning and should reach you on Thursday. Any questions, just reply to this email. Priya",
|
|
6563
|
+
why: 'A name at each end, a real day and place instead of "in due course", and a next step. Fictional business.'
|
|
6564
|
+
},
|
|
6565
|
+
sources: [
|
|
6566
|
+
{
|
|
6567
|
+
name: MAILCHIMP,
|
|
6568
|
+
url: "https://styleguide.mailchimp.com/voice-and-tone/",
|
|
6569
|
+
note: "Voice and tone (plainspoken, genuine, dry humour; clear before entertaining; adjust tone to the reader's state) and grammar and mechanics (active voice, contractions, positive language). Its allowance for emoji does not apply: emoji block under COPY.md. Checked against the live pages on 2026-09-30."
|
|
6570
|
+
}
|
|
6571
|
+
]
|
|
6572
|
+
},
|
|
6573
|
+
{
|
|
6574
|
+
id: "literary",
|
|
6575
|
+
name: "Elegant and literary",
|
|
6576
|
+
useFor: "Premium brands, makers, hospitality and anything sold on craft and taste rather than price.",
|
|
6577
|
+
directives: [
|
|
6578
|
+
{ text: "Choose one precise noun over two adjectives.", from: HOUSE2 },
|
|
6579
|
+
{ text: "Let sentence length follow the thought: a long sentence to build, a short one to land.", from: "COPY.md" },
|
|
6580
|
+
{ text: "Carry the detail in concrete facts: material, place, process, time.", from: HOUSE2 },
|
|
6581
|
+
{ text: "Trust the reader with one image, state it once, and move on.", from: HOUSE2 },
|
|
6582
|
+
{ text: "Keep claims quiet and exact, and let the facts carry the prestige.", from: HOUSE2 },
|
|
6583
|
+
{ text: "Draw any metaphor from the maker's own work, and hold it for the whole piece.", from: HOUSE2 },
|
|
6584
|
+
{ text: "Read the draft aloud and rework each line that trips the breath.", from: HOUSE2 }
|
|
6585
|
+
],
|
|
6586
|
+
example: {
|
|
6587
|
+
before: "Our luxurious, handcrafted candles create an unforgettable ambience of elegance and sophistication.",
|
|
6588
|
+
after: "Each candle is poured by hand in our Hebden Bridge workshop, forty to a batch. The wax is English rapeseed and the scent is cedar, cut with a little smoke. It burns for sixty hours, and the glass is yours to keep.",
|
|
6589
|
+
why: "Place, material, scent and burn time do the work the adjectives claimed. Fictional business."
|
|
6590
|
+
},
|
|
6591
|
+
sources: [
|
|
6592
|
+
{
|
|
6593
|
+
name: HOUSE2,
|
|
6594
|
+
note: "No public style authority exists for premium-brand prose. These directives are house judgement, to be revised as the estate grows."
|
|
6595
|
+
},
|
|
6596
|
+
{
|
|
6597
|
+
name: "Register separation, 2026-09-29",
|
|
6598
|
+
url: "calibration/copy-shape/report-registers.md",
|
|
6599
|
+
note: "Literary prose (Gutenberg) carries about twice the comma density of the other human registers, the one feature that separated it from all four. Longer, jointed sentences are normal here."
|
|
6600
|
+
}
|
|
6601
|
+
]
|
|
6602
|
+
}
|
|
6603
|
+
];
|
|
6604
|
+
var REGISTER_IDS = REGISTERS.map((r) => r.id);
|
|
6605
|
+
function getRegister(id) {
|
|
6606
|
+
return REGISTERS.find((r) => r.id === id);
|
|
6607
|
+
}
|
|
6608
|
+
function registerBrief(id) {
|
|
6609
|
+
const r = getRegister(id);
|
|
6610
|
+
if (!r) throw new Error(`unknown register "${id}". Registers: ${REGISTER_IDS.join(", ")}`);
|
|
6611
|
+
const lines = [`Register: ${r.name} (${r.id})`, `Use for: ${r.useFor}`, "", "Before you draft:"];
|
|
6612
|
+
r.directives.forEach((d, i) => lines.push(` ${i + 1}. ${d.text} [${d.from}]`));
|
|
6613
|
+
lines.push("", "Example (fictional):", ` Before: ${r.example.before}`, ` After: ${r.example.after}`, ` Why: ${r.example.why}`);
|
|
6614
|
+
lines.push("", "Sources:");
|
|
6615
|
+
for (const s of r.sources) lines.push(` - ${s.name}${s.url ? ` (${s.url})` : ""}: ${s.note}`);
|
|
6616
|
+
lines.push("", `Always: ${ALWAYS}`);
|
|
6617
|
+
return lines.join("\n");
|
|
6618
|
+
}
|
|
6619
|
+
function registersDoc() {
|
|
6620
|
+
const out = [];
|
|
6621
|
+
for (const r of REGISTERS) {
|
|
6622
|
+
out.push(`## ${r.name} (\`${r.id}\`)`, "", `**Use for:** ${r.useFor}`, "", "**Before you draft:**", "");
|
|
6623
|
+
r.directives.forEach((d, i) => out.push(`${i + 1}. ${d.text} *(${d.from})*`));
|
|
6624
|
+
out.push("", "**Example (fictional):**", "", `- Before: ${r.example.before}`, `- After: ${r.example.after}`, `- Why: ${r.example.why}`);
|
|
6625
|
+
out.push("", "**Sources:**", "");
|
|
6626
|
+
for (const s of r.sources) out.push(`- ${s.url ? `[${s.name}](${s.url})` : s.name}: ${s.note}`);
|
|
6627
|
+
out.push("");
|
|
6628
|
+
}
|
|
6629
|
+
out.push(`**Always:** ${ALWAYS}`);
|
|
6630
|
+
return out.join("\n");
|
|
6631
|
+
}
|
|
6632
|
+
|
|
6633
|
+
// src/register/check.ts
|
|
6634
|
+
var REGISTER_BASELINE = {
|
|
6635
|
+
plain: {
|
|
6636
|
+
baseline: "institutional",
|
|
6637
|
+
note: "Compared with Hansard: edited parliamentary debate, the closest free UK source, not plain writing itself."
|
|
6638
|
+
},
|
|
6639
|
+
persuasive: {
|
|
6640
|
+
baseline: "marketing",
|
|
6641
|
+
note: "Compared with 715 passages from UK small-business websites before 2021: a small sample."
|
|
6642
|
+
},
|
|
6643
|
+
warm: {
|
|
6644
|
+
baseline: "business-email",
|
|
6645
|
+
note: "Compared with Enron sent email, 1999 to 2002: corporate and American, not small-business email."
|
|
6646
|
+
},
|
|
6647
|
+
literary: {
|
|
6648
|
+
baseline: "literary",
|
|
6649
|
+
note: "Compared with English fiction and essays, 1726 to 1925: older than any premium brand's copy."
|
|
6650
|
+
}
|
|
6651
|
+
};
|
|
6652
|
+
var MIN_PARAGRAPHS = 5;
|
|
6653
|
+
var CONTENT_FEATURES = /* @__PURE__ */ new Set(["hardPer100", "specificsPer100", "tradePer100", "figures", "names", "generic"]);
|
|
6654
|
+
var usable = (f4, b) => !CONTENT_FEATURES.has(f4) && b.p90 > b.p10;
|
|
6655
|
+
var LABELS = {
|
|
6656
|
+
meanSentenceWords: "Words per sentence",
|
|
6657
|
+
contractionsPer100: "Contractions per 100 words",
|
|
6658
|
+
youPer100: '"You" per 100 words',
|
|
6659
|
+
firstPersonPer100: '"I" and "we" per 100 words',
|
|
6660
|
+
passiveShare: "Share of sentences in the passive",
|
|
6661
|
+
meanWordLength: "Letters per word",
|
|
6662
|
+
commasPer100: "Commas per 100 words",
|
|
6663
|
+
commasPerSentence: "Commas per sentence",
|
|
6664
|
+
clauseDepth: "Clauses per sentence",
|
|
6665
|
+
nominalisationRate: 'Nominalisations ("the provision of") per 100 words',
|
|
6666
|
+
pronounOpenerShare: "Share of sentences opening with a pronoun",
|
|
6667
|
+
impersonalOpenerShare: 'Share of sentences opening impersonally ("It is", "There are")',
|
|
6668
|
+
coordinationRate: 'Paired phrases ("fast and friendly") per 100 words',
|
|
6669
|
+
participialRate: '"-ing" clauses per sentence',
|
|
6670
|
+
tricolons: "Lists of three",
|
|
6671
|
+
sentenceCv: "Spread of sentence lengths",
|
|
6672
|
+
skeletonRepeat: "Repeated sentence patterns",
|
|
6673
|
+
hardPer100: "Hard specifics (names, figures, dates) per 100 words",
|
|
6674
|
+
specificsPer100: "Specifics of any kind per 100 words",
|
|
6675
|
+
tradePer100: "Trade nouns per 100 words",
|
|
6676
|
+
figures: "Figures per paragraph",
|
|
6677
|
+
names: "Names per paragraph",
|
|
6678
|
+
generic: "Share of paragraphs with no specific at all"
|
|
6679
|
+
};
|
|
6680
|
+
var featureLabel = (f4) => LABELS[f4] ?? f4;
|
|
6681
|
+
function documentParagraphs(text) {
|
|
6682
|
+
return text.replace(/\r\n?/g, "\n").split(/\n\s*\n/).map((p) => p.replace(/\s*\n\s*/g, " ").trim()).filter((p) => p && !/^#{1,6}\s/.test(p));
|
|
6683
|
+
}
|
|
6684
|
+
function measure(paragraph) {
|
|
6685
|
+
const out = {};
|
|
6686
|
+
for (const [k, v] of Object.entries(shapeOf(paragraph))) out[k] = typeof v === "boolean" ? v ? 1 : 0 : v;
|
|
6687
|
+
for (const [k, v] of Object.entries(lexicalOf(paragraph))) out[k] = v;
|
|
6688
|
+
for (const [k, v] of Object.entries(registerOf(paragraph))) out[k] = v;
|
|
6689
|
+
return out;
|
|
6690
|
+
}
|
|
6691
|
+
var fmt = (x) => Math.abs(x) >= 10 ? x.toFixed(0) : x.toFixed(Math.abs(x) >= 1 ? 1 : 2);
|
|
6692
|
+
function checkRegister(text, id, profile) {
|
|
6693
|
+
const reg = getRegister(id);
|
|
6694
|
+
if (!reg) throw new Error(`unknown register "${id}"`);
|
|
6695
|
+
const { baseline, note } = REGISTER_BASELINE[id];
|
|
6696
|
+
const target2 = profile[baseline];
|
|
6697
|
+
if (!target2) throw new Error(`no baseline profile for "${baseline}"`);
|
|
6698
|
+
const kept = documentParagraphs(text).filter((p) => isBlurb(shapeOf(p)));
|
|
6699
|
+
const base = { register: id, baseline, paragraphs: kept.length, note };
|
|
6700
|
+
if (kept.length < MIN_PARAGRAPHS) {
|
|
6701
|
+
return {
|
|
6702
|
+
...base,
|
|
6703
|
+
measured: false,
|
|
6704
|
+
means: {},
|
|
6705
|
+
outside: [],
|
|
6706
|
+
nearest: [],
|
|
6707
|
+
summary: `Only ${kept.length} paragraph${kept.length === 1 ? "" : "s"} of 2 to 8 sentences. The registers overlap too much to place anything shorter than ${MIN_PARAGRAPHS}; read it against the brief instead.`
|
|
6708
|
+
};
|
|
6709
|
+
}
|
|
6710
|
+
const rows = kept.map(measure);
|
|
6711
|
+
const features = [...new Set(Object.values(profile).flatMap((p) => Object.keys(p)))];
|
|
6712
|
+
const means = {};
|
|
6713
|
+
for (const f4 of features) {
|
|
6714
|
+
const xs = rows.map((r) => r[f4]).filter((x) => typeof x === "number" && Number.isFinite(x));
|
|
6715
|
+
if (xs.length) means[f4] = xs.reduce((s, x) => s + x, 0) / xs.length;
|
|
6716
|
+
}
|
|
6717
|
+
const outside = [];
|
|
6718
|
+
for (const [f4, b] of Object.entries(target2)) {
|
|
6719
|
+
const v = means[f4];
|
|
6720
|
+
if (v === void 0 || b.separates.length === 0 || !usable(f4, b)) continue;
|
|
6721
|
+
if (v >= b.p10 && v <= b.p90) continue;
|
|
6722
|
+
const direction = v > b.p90 ? "higher" : "lower";
|
|
6723
|
+
outside.push({
|
|
6724
|
+
feature: f4,
|
|
6725
|
+
value: v,
|
|
6726
|
+
band: [b.p10, b.p90],
|
|
6727
|
+
direction,
|
|
6728
|
+
sentence: `${featureLabel(f4)}: ${fmt(v)}. ${reg.name} writing in the baseline runs ${fmt(b.p10)} to ${fmt(b.p90)}, so this is ${direction}.`
|
|
6729
|
+
});
|
|
6730
|
+
}
|
|
6731
|
+
const nearest2 = Object.entries(profile).map(([register, bands]) => {
|
|
6732
|
+
const zs = Object.entries(bands).filter(([f4, b]) => means[f4] !== void 0 && b.sd > 0 && usable(f4, b)).map(([f4, b]) => ((means[f4] - b.p50) / b.sd) ** 2);
|
|
6733
|
+
return { register, distance: zs.length ? Math.sqrt(zs.reduce((s, z) => s + z, 0) / zs.length) : Infinity };
|
|
6734
|
+
}).filter((n) => Number.isFinite(n.distance)).sort((a, b) => a.distance - b.distance);
|
|
6735
|
+
const closest = nearest2[0]?.register;
|
|
6736
|
+
const summary = (outside.length === 0 ? `All ${Object.entries(target2).filter(([f4, b]) => b.separates.length && usable(f4, b)).length} measured features sit inside the usual range for ${reg.name.toLowerCase()} writing.` : `${outside.length} feature${outside.length === 1 ? "" : "s"} outside the usual range for ${reg.name.toLowerCase()} writing.`) + (closest && closest !== baseline ? ` It reads closest to the ${closest} baseline.` : "");
|
|
6737
|
+
return { ...base, measured: true, means, outside, nearest: nearest2, summary };
|
|
6738
|
+
}
|
|
6739
|
+
|
|
6740
|
+
// src/register/profile.ts
|
|
6741
|
+
var PROFILE_PARAGRAPHS = 5;
|
|
6742
|
+
var PROFILE_MEASURED = "2026-09-30";
|
|
6743
|
+
var PROFILE = {
|
|
6744
|
+
"business-email": {
|
|
6745
|
+
"clauseDepth": {
|
|
6746
|
+
"p10": 0.36,
|
|
6747
|
+
"p50": 0.673,
|
|
6748
|
+
"p90": 1.113,
|
|
6749
|
+
"sd": 0.307,
|
|
6750
|
+
"separates": [
|
|
6751
|
+
"explanatory",
|
|
6752
|
+
"institutional",
|
|
6753
|
+
"literary"
|
|
6754
|
+
]
|
|
6755
|
+
},
|
|
6756
|
+
"commasPer100": {
|
|
6757
|
+
"p10": 1.424,
|
|
6758
|
+
"p50": 3.19,
|
|
6759
|
+
"p90": 5.154,
|
|
6760
|
+
"sd": 1.529,
|
|
6761
|
+
"separates": [
|
|
6762
|
+
"institutional",
|
|
6763
|
+
"literary"
|
|
6764
|
+
]
|
|
6765
|
+
},
|
|
6766
|
+
"commasPerSentence": {
|
|
6767
|
+
"p10": 0.2,
|
|
6768
|
+
"p50": 0.467,
|
|
6769
|
+
"p90": 0.826,
|
|
6770
|
+
"sd": 0.262,
|
|
6771
|
+
"separates": [
|
|
6772
|
+
"explanatory",
|
|
6773
|
+
"institutional",
|
|
6774
|
+
"literary",
|
|
6775
|
+
"marketing"
|
|
6776
|
+
]
|
|
6777
|
+
},
|
|
6778
|
+
"coordinationRate": {
|
|
6779
|
+
"p10": 0,
|
|
6780
|
+
"p50": 0.743,
|
|
6781
|
+
"p90": 1.712,
|
|
6782
|
+
"sd": 0.666,
|
|
6783
|
+
"separates": [
|
|
6784
|
+
"marketing"
|
|
6785
|
+
]
|
|
6786
|
+
},
|
|
6787
|
+
"figures": {
|
|
6788
|
+
"p10": 0.2,
|
|
6789
|
+
"p50": 0.8,
|
|
6790
|
+
"p90": 1.8,
|
|
6791
|
+
"sd": 0.725,
|
|
6792
|
+
"separates": [
|
|
6793
|
+
"literary"
|
|
6794
|
+
]
|
|
6795
|
+
},
|
|
6796
|
+
"firstPersonPer100": {
|
|
6797
|
+
"p10": 3.718,
|
|
6798
|
+
"p50": 5.968,
|
|
6799
|
+
"p90": 8.375,
|
|
6800
|
+
"sd": 1.825,
|
|
6801
|
+
"separates": [
|
|
6802
|
+
"explanatory"
|
|
6803
|
+
]
|
|
6804
|
+
},
|
|
6805
|
+
"generic": {
|
|
6806
|
+
"p10": 0,
|
|
6807
|
+
"p50": 0,
|
|
6808
|
+
"p90": 0.2,
|
|
6809
|
+
"sd": 0.138,
|
|
6810
|
+
"separates": [
|
|
6811
|
+
"explanatory"
|
|
6812
|
+
]
|
|
6813
|
+
},
|
|
6814
|
+
"hardPer100": {
|
|
6815
|
+
"p10": 4.289,
|
|
6816
|
+
"p50": 7.127,
|
|
6817
|
+
"p90": 11.308,
|
|
6818
|
+
"sd": 2.843,
|
|
6819
|
+
"separates": [
|
|
6820
|
+
"explanatory",
|
|
6821
|
+
"institutional",
|
|
6822
|
+
"literary"
|
|
6823
|
+
]
|
|
6824
|
+
},
|
|
6825
|
+
"impersonalOpenerShare": {
|
|
6826
|
+
"p10": 0,
|
|
6827
|
+
"p50": 0,
|
|
6828
|
+
"p90": 0.067,
|
|
6829
|
+
"sd": 0.031,
|
|
6830
|
+
"separates": [
|
|
6831
|
+
"explanatory"
|
|
6832
|
+
]
|
|
6833
|
+
},
|
|
6834
|
+
"meanSentenceWords": {
|
|
6835
|
+
"p10": 11.417,
|
|
6836
|
+
"p50": 14.25,
|
|
6837
|
+
"p90": 17.87,
|
|
6838
|
+
"sd": 2.656,
|
|
6839
|
+
"separates": [
|
|
6840
|
+
"explanatory",
|
|
6841
|
+
"literary"
|
|
6842
|
+
]
|
|
6843
|
+
},
|
|
6844
|
+
"meanWordLength": {
|
|
6845
|
+
"p10": 3.858,
|
|
6846
|
+
"p50": 4.16,
|
|
6847
|
+
"p90": 4.459,
|
|
6848
|
+
"sd": 0.231,
|
|
6849
|
+
"separates": [
|
|
6850
|
+
"explanatory"
|
|
6851
|
+
]
|
|
6852
|
+
},
|
|
6853
|
+
"names": {
|
|
6854
|
+
"p10": 1.2,
|
|
6855
|
+
"p50": 2.4,
|
|
6856
|
+
"p90": 3.6,
|
|
6857
|
+
"sd": 0.965,
|
|
6858
|
+
"separates": [
|
|
6859
|
+
"explanatory",
|
|
6860
|
+
"institutional"
|
|
6861
|
+
]
|
|
6862
|
+
},
|
|
6863
|
+
"nominalisationRate": {
|
|
6864
|
+
"p10": 0.625,
|
|
6865
|
+
"p50": 1.93,
|
|
6866
|
+
"p90": 3.831,
|
|
6867
|
+
"sd": 1.264,
|
|
6868
|
+
"separates": [
|
|
6869
|
+
"institutional",
|
|
6870
|
+
"marketing"
|
|
6871
|
+
]
|
|
6872
|
+
},
|
|
6873
|
+
"participialRate": {
|
|
6874
|
+
"p10": 0,
|
|
6875
|
+
"p50": 0,
|
|
6876
|
+
"p90": 0.05,
|
|
6877
|
+
"sd": 0.035,
|
|
6878
|
+
"separates": [
|
|
6879
|
+
"literary"
|
|
6880
|
+
]
|
|
6881
|
+
},
|
|
6882
|
+
"pronounOpenerShare": {
|
|
6883
|
+
"p10": 0,
|
|
6884
|
+
"p50": 0.05,
|
|
6885
|
+
"p90": 0.15,
|
|
6886
|
+
"sd": 0.068,
|
|
6887
|
+
"separates": [
|
|
6888
|
+
"marketing"
|
|
6889
|
+
]
|
|
6890
|
+
},
|
|
6891
|
+
"sentenceCv": {
|
|
6892
|
+
"p10": 0.344,
|
|
6893
|
+
"p50": 0.468,
|
|
6894
|
+
"p90": 0.6,
|
|
6895
|
+
"sd": 0.099,
|
|
6896
|
+
"separates": [
|
|
6897
|
+
"marketing"
|
|
6898
|
+
]
|
|
6899
|
+
},
|
|
6900
|
+
"skeletonRepeat": {
|
|
6901
|
+
"p10": 0,
|
|
6902
|
+
"p50": 0.017,
|
|
6903
|
+
"p90": 0.063,
|
|
6904
|
+
"sd": 0.031,
|
|
6905
|
+
"separates": [
|
|
6906
|
+
"institutional"
|
|
6907
|
+
]
|
|
6908
|
+
},
|
|
6909
|
+
"specificsPer100": {
|
|
6910
|
+
"p10": 4.22,
|
|
6911
|
+
"p50": 7.34,
|
|
6912
|
+
"p90": 11.46,
|
|
6913
|
+
"sd": 2.892,
|
|
6914
|
+
"separates": [
|
|
6915
|
+
"explanatory",
|
|
6916
|
+
"institutional",
|
|
6917
|
+
"literary"
|
|
6918
|
+
]
|
|
6919
|
+
},
|
|
6920
|
+
"tradePer100": {
|
|
6921
|
+
"p10": 0,
|
|
6922
|
+
"p50": 0,
|
|
6923
|
+
"p90": 0.588,
|
|
6924
|
+
"sd": 0.287,
|
|
6925
|
+
"separates": [
|
|
6926
|
+
"marketing"
|
|
6927
|
+
]
|
|
6928
|
+
},
|
|
6929
|
+
"tricolons": {
|
|
6930
|
+
"p10": 0,
|
|
6931
|
+
"p50": 0,
|
|
6932
|
+
"p90": 0.2,
|
|
6933
|
+
"sd": 0.142,
|
|
6934
|
+
"separates": [
|
|
6935
|
+
"institutional",
|
|
6936
|
+
"literary",
|
|
6937
|
+
"marketing"
|
|
6938
|
+
]
|
|
6939
|
+
}
|
|
6940
|
+
},
|
|
6941
|
+
"explanatory": {
|
|
6942
|
+
"clauseDepth": {
|
|
6943
|
+
"p10": 0.78,
|
|
6944
|
+
"p50": 1.194,
|
|
6945
|
+
"p90": 1.733,
|
|
6946
|
+
"sd": 0.383,
|
|
6947
|
+
"separates": [
|
|
6948
|
+
"business-email",
|
|
6949
|
+
"literary"
|
|
6950
|
+
]
|
|
6951
|
+
},
|
|
6952
|
+
"commasPer100": {
|
|
6953
|
+
"p10": 2.579,
|
|
6954
|
+
"p50": 4.164,
|
|
6955
|
+
"p90": 6.089,
|
|
6956
|
+
"sd": 1.423,
|
|
6957
|
+
"separates": [
|
|
6958
|
+
"literary"
|
|
6959
|
+
]
|
|
6960
|
+
},
|
|
6961
|
+
"commasPerSentence": {
|
|
6962
|
+
"p10": 0.448,
|
|
6963
|
+
"p50": 0.77,
|
|
6964
|
+
"p90": 1.2,
|
|
6965
|
+
"sd": 0.309,
|
|
6966
|
+
"separates": [
|
|
6967
|
+
"business-email",
|
|
6968
|
+
"literary"
|
|
6969
|
+
]
|
|
6970
|
+
},
|
|
6971
|
+
"coordinationRate": {
|
|
6972
|
+
"p10": 0.323,
|
|
6973
|
+
"p50": 0.973,
|
|
6974
|
+
"p90": 1.862,
|
|
6975
|
+
"sd": 0.612,
|
|
6976
|
+
"separates": [
|
|
6977
|
+
"marketing"
|
|
6978
|
+
]
|
|
6979
|
+
},
|
|
6980
|
+
"figures": {
|
|
6981
|
+
"p10": 0,
|
|
6982
|
+
"p50": 0.4,
|
|
6983
|
+
"p90": 1.4,
|
|
6984
|
+
"sd": 0.631,
|
|
6985
|
+
"separates": [
|
|
6986
|
+
"literary"
|
|
6987
|
+
]
|
|
6988
|
+
},
|
|
6989
|
+
"firstPersonPer100": {
|
|
6990
|
+
"p10": 0.27,
|
|
6991
|
+
"p50": 1.282,
|
|
6992
|
+
"p90": 3.114,
|
|
6993
|
+
"sd": 1.181,
|
|
6994
|
+
"separates": [
|
|
6995
|
+
"business-email",
|
|
6996
|
+
"literary"
|
|
6997
|
+
]
|
|
6998
|
+
},
|
|
6999
|
+
"generic": {
|
|
7000
|
+
"p10": 0,
|
|
7001
|
+
"p50": 0.4,
|
|
7002
|
+
"p90": 0.6,
|
|
7003
|
+
"sd": 0.214,
|
|
7004
|
+
"separates": [
|
|
7005
|
+
"business-email",
|
|
7006
|
+
"institutional"
|
|
7007
|
+
]
|
|
7008
|
+
},
|
|
7009
|
+
"hardPer100": {
|
|
7010
|
+
"p10": 0.988,
|
|
7011
|
+
"p50": 2.62,
|
|
7012
|
+
"p90": 5.171,
|
|
7013
|
+
"sd": 1.713,
|
|
7014
|
+
"separates": [
|
|
7015
|
+
"business-email",
|
|
7016
|
+
"institutional",
|
|
7017
|
+
"marketing"
|
|
7018
|
+
]
|
|
7019
|
+
},
|
|
7020
|
+
"impersonalOpenerShare": {
|
|
7021
|
+
"p10": 0,
|
|
7022
|
+
"p50": 0.04,
|
|
7023
|
+
"p90": 0.14,
|
|
7024
|
+
"sd": 0.061,
|
|
7025
|
+
"separates": [
|
|
7026
|
+
"business-email"
|
|
7027
|
+
]
|
|
7028
|
+
},
|
|
7029
|
+
"meanSentenceWords": {
|
|
7030
|
+
"p10": 14.973,
|
|
7031
|
+
"p50": 18.31,
|
|
7032
|
+
"p90": 22.533,
|
|
7033
|
+
"sd": 3.013,
|
|
7034
|
+
"separates": [
|
|
7035
|
+
"business-email"
|
|
7036
|
+
]
|
|
7037
|
+
},
|
|
7038
|
+
"meanWordLength": {
|
|
7039
|
+
"p10": 4.207,
|
|
7040
|
+
"p50": 4.466,
|
|
7041
|
+
"p90": 4.752,
|
|
7042
|
+
"sd": 0.213,
|
|
7043
|
+
"separates": [
|
|
7044
|
+
"business-email",
|
|
7045
|
+
"literary"
|
|
7046
|
+
]
|
|
7047
|
+
},
|
|
7048
|
+
"names": {
|
|
7049
|
+
"p10": 0.4,
|
|
7050
|
+
"p50": 1.2,
|
|
7051
|
+
"p90": 2.6,
|
|
7052
|
+
"sd": 0.941,
|
|
7053
|
+
"separates": [
|
|
7054
|
+
"business-email",
|
|
7055
|
+
"institutional"
|
|
7056
|
+
]
|
|
7057
|
+
},
|
|
7058
|
+
"nominalisationRate": {
|
|
7059
|
+
"p10": 0.766,
|
|
7060
|
+
"p50": 1.823,
|
|
7061
|
+
"p90": 3.416,
|
|
7062
|
+
"sd": 1.061,
|
|
7063
|
+
"separates": [
|
|
7064
|
+
"institutional",
|
|
7065
|
+
"marketing"
|
|
7066
|
+
]
|
|
7067
|
+
},
|
|
7068
|
+
"participialRate": {
|
|
7069
|
+
"p10": 0,
|
|
7070
|
+
"p50": 0,
|
|
7071
|
+
"p90": 0.1,
|
|
7072
|
+
"sd": 0.045,
|
|
7073
|
+
"separates": []
|
|
7074
|
+
},
|
|
7075
|
+
"pronounOpenerShare": {
|
|
7076
|
+
"p10": 0,
|
|
7077
|
+
"p50": 0.033,
|
|
7078
|
+
"p90": 0.124,
|
|
7079
|
+
"sd": 0.056,
|
|
7080
|
+
"separates": [
|
|
7081
|
+
"marketing"
|
|
7082
|
+
]
|
|
7083
|
+
},
|
|
7084
|
+
"sentenceCv": {
|
|
7085
|
+
"p10": 0.337,
|
|
7086
|
+
"p50": 0.441,
|
|
7087
|
+
"p90": 0.57,
|
|
7088
|
+
"sd": 0.092,
|
|
7089
|
+
"separates": []
|
|
7090
|
+
},
|
|
7091
|
+
"skeletonRepeat": {
|
|
7092
|
+
"p10": 9e-3,
|
|
7093
|
+
"p50": 0.039,
|
|
7094
|
+
"p90": 0.091,
|
|
7095
|
+
"sd": 0.036,
|
|
7096
|
+
"separates": []
|
|
7097
|
+
},
|
|
7098
|
+
"specificsPer100": {
|
|
7099
|
+
"p10": 1.04,
|
|
7100
|
+
"p50": 2.7,
|
|
7101
|
+
"p90": 5.36,
|
|
7102
|
+
"sd": 1.731,
|
|
7103
|
+
"separates": [
|
|
7104
|
+
"business-email",
|
|
7105
|
+
"institutional",
|
|
7106
|
+
"marketing"
|
|
7107
|
+
]
|
|
7108
|
+
},
|
|
7109
|
+
"tradePer100": {
|
|
7110
|
+
"p10": 0,
|
|
7111
|
+
"p50": 0,
|
|
7112
|
+
"p90": 0.427,
|
|
7113
|
+
"sd": 0.216,
|
|
7114
|
+
"separates": [
|
|
7115
|
+
"marketing"
|
|
7116
|
+
]
|
|
7117
|
+
},
|
|
7118
|
+
"tricolons": {
|
|
7119
|
+
"p10": 0,
|
|
7120
|
+
"p50": 0.2,
|
|
7121
|
+
"p90": 0.6,
|
|
7122
|
+
"sd": 0.222,
|
|
7123
|
+
"separates": []
|
|
7124
|
+
}
|
|
7125
|
+
},
|
|
7126
|
+
"institutional": {
|
|
7127
|
+
"clauseDepth": {
|
|
7128
|
+
"p10": 0.792,
|
|
7129
|
+
"p50": 1.233,
|
|
7130
|
+
"p90": 1.76,
|
|
7131
|
+
"sd": 0.377,
|
|
7132
|
+
"separates": [
|
|
7133
|
+
"business-email",
|
|
7134
|
+
"literary"
|
|
7135
|
+
]
|
|
7136
|
+
},
|
|
7137
|
+
"commasPer100": {
|
|
7138
|
+
"p10": 3.03,
|
|
7139
|
+
"p50": 4.435,
|
|
7140
|
+
"p90": 5.941,
|
|
7141
|
+
"sd": 1.165,
|
|
7142
|
+
"separates": [
|
|
7143
|
+
"business-email",
|
|
7144
|
+
"literary"
|
|
7145
|
+
]
|
|
7146
|
+
},
|
|
7147
|
+
"commasPerSentence": {
|
|
7148
|
+
"p10": 0.61,
|
|
7149
|
+
"p50": 0.96,
|
|
7150
|
+
"p90": 1.375,
|
|
7151
|
+
"sd": 0.307,
|
|
7152
|
+
"separates": [
|
|
7153
|
+
"business-email",
|
|
7154
|
+
"literary"
|
|
7155
|
+
]
|
|
7156
|
+
},
|
|
7157
|
+
"coordinationRate": {
|
|
7158
|
+
"p10": 0.323,
|
|
7159
|
+
"p50": 0.949,
|
|
7160
|
+
"p90": 1.752,
|
|
7161
|
+
"sd": 0.559,
|
|
7162
|
+
"separates": [
|
|
7163
|
+
"marketing"
|
|
7164
|
+
]
|
|
7165
|
+
},
|
|
7166
|
+
"figures": {
|
|
7167
|
+
"p10": 0,
|
|
7168
|
+
"p50": 0.6,
|
|
7169
|
+
"p90": 1.4,
|
|
7170
|
+
"sd": 0.56,
|
|
7171
|
+
"separates": [
|
|
7172
|
+
"literary"
|
|
7173
|
+
]
|
|
7174
|
+
},
|
|
7175
|
+
"generic": {
|
|
7176
|
+
"p10": 0,
|
|
7177
|
+
"p50": 0,
|
|
7178
|
+
"p90": 0.2,
|
|
7179
|
+
"sd": 0.114,
|
|
7180
|
+
"separates": [
|
|
7181
|
+
"explanatory",
|
|
7182
|
+
"literary",
|
|
7183
|
+
"marketing"
|
|
7184
|
+
]
|
|
7185
|
+
},
|
|
7186
|
+
"hardPer100": {
|
|
7187
|
+
"p10": 3.41,
|
|
7188
|
+
"p50": 5.135,
|
|
7189
|
+
"p90": 7.304,
|
|
7190
|
+
"sd": 1.573,
|
|
7191
|
+
"separates": [
|
|
7192
|
+
"business-email",
|
|
7193
|
+
"explanatory",
|
|
7194
|
+
"literary"
|
|
7195
|
+
]
|
|
7196
|
+
},
|
|
7197
|
+
"impersonalOpenerShare": {
|
|
7198
|
+
"p10": 0,
|
|
7199
|
+
"p50": 0.033,
|
|
7200
|
+
"p90": 0.109,
|
|
7201
|
+
"sd": 0.051,
|
|
7202
|
+
"separates": []
|
|
7203
|
+
},
|
|
7204
|
+
"names": {
|
|
7205
|
+
"p10": 2,
|
|
7206
|
+
"p50": 3.2,
|
|
7207
|
+
"p90": 4.8,
|
|
7208
|
+
"sd": 1.113,
|
|
7209
|
+
"separates": [
|
|
7210
|
+
"business-email",
|
|
7211
|
+
"explanatory",
|
|
7212
|
+
"literary",
|
|
7213
|
+
"marketing"
|
|
7214
|
+
]
|
|
7215
|
+
},
|
|
7216
|
+
"nominalisationRate": {
|
|
7217
|
+
"p10": 1.992,
|
|
7218
|
+
"p50": 3.391,
|
|
7219
|
+
"p90": 5.008,
|
|
7220
|
+
"sd": 1.147,
|
|
7221
|
+
"separates": [
|
|
7222
|
+
"business-email",
|
|
7223
|
+
"explanatory",
|
|
7224
|
+
"literary"
|
|
7225
|
+
]
|
|
7226
|
+
},
|
|
7227
|
+
"participialRate": {
|
|
7228
|
+
"p10": 0,
|
|
7229
|
+
"p50": 0,
|
|
7230
|
+
"p90": 0.1,
|
|
7231
|
+
"sd": 0.044,
|
|
7232
|
+
"separates": [
|
|
7233
|
+
"literary"
|
|
7234
|
+
]
|
|
7235
|
+
},
|
|
7236
|
+
"pronounOpenerShare": {
|
|
7237
|
+
"p10": 0,
|
|
7238
|
+
"p50": 0.05,
|
|
7239
|
+
"p90": 0.164,
|
|
7240
|
+
"sd": 0.068,
|
|
7241
|
+
"separates": [
|
|
7242
|
+
"marketing"
|
|
7243
|
+
]
|
|
7244
|
+
},
|
|
7245
|
+
"sentenceCv": {
|
|
7246
|
+
"p10": 0.386,
|
|
7247
|
+
"p50": 0.512,
|
|
7248
|
+
"p90": 0.639,
|
|
7249
|
+
"sd": 0.097,
|
|
7250
|
+
"separates": [
|
|
7251
|
+
"marketing"
|
|
7252
|
+
]
|
|
7253
|
+
},
|
|
7254
|
+
"skeletonRepeat": {
|
|
7255
|
+
"p10": 0.018,
|
|
7256
|
+
"p50": 0.048,
|
|
7257
|
+
"p90": 0.087,
|
|
7258
|
+
"sd": 0.028,
|
|
7259
|
+
"separates": [
|
|
7260
|
+
"business-email"
|
|
7261
|
+
]
|
|
7262
|
+
},
|
|
7263
|
+
"specificsPer100": {
|
|
7264
|
+
"p10": 3.36,
|
|
7265
|
+
"p50": 5.2,
|
|
7266
|
+
"p90": 7.4,
|
|
7267
|
+
"sd": 1.612,
|
|
7268
|
+
"separates": [
|
|
7269
|
+
"business-email",
|
|
7270
|
+
"explanatory",
|
|
7271
|
+
"literary"
|
|
7272
|
+
]
|
|
7273
|
+
},
|
|
7274
|
+
"tradePer100": {
|
|
7275
|
+
"p10": 0,
|
|
7276
|
+
"p50": 0,
|
|
7277
|
+
"p90": 0.157,
|
|
7278
|
+
"sd": 0.101,
|
|
7279
|
+
"separates": [
|
|
7280
|
+
"marketing"
|
|
7281
|
+
]
|
|
7282
|
+
},
|
|
7283
|
+
"tricolons": {
|
|
7284
|
+
"p10": 0,
|
|
7285
|
+
"p50": 0.2,
|
|
7286
|
+
"p90": 0.6,
|
|
7287
|
+
"sd": 0.233,
|
|
7288
|
+
"separates": [
|
|
7289
|
+
"business-email"
|
|
7290
|
+
]
|
|
7291
|
+
}
|
|
7292
|
+
},
|
|
7293
|
+
"literary": {
|
|
7294
|
+
"clauseDepth": {
|
|
7295
|
+
"p10": 1.333,
|
|
7296
|
+
"p50": 2.017,
|
|
7297
|
+
"p90": 2.933,
|
|
7298
|
+
"sd": 0.626,
|
|
7299
|
+
"separates": [
|
|
7300
|
+
"business-email",
|
|
7301
|
+
"explanatory",
|
|
7302
|
+
"institutional",
|
|
7303
|
+
"marketing"
|
|
7304
|
+
]
|
|
7305
|
+
},
|
|
7306
|
+
"commasPer100": {
|
|
7307
|
+
"p10": 5.997,
|
|
7308
|
+
"p50": 8.1,
|
|
7309
|
+
"p90": 10.586,
|
|
7310
|
+
"sd": 1.815,
|
|
7311
|
+
"separates": [
|
|
7312
|
+
"business-email",
|
|
7313
|
+
"explanatory",
|
|
7314
|
+
"institutional",
|
|
7315
|
+
"marketing"
|
|
7316
|
+
]
|
|
7317
|
+
},
|
|
7318
|
+
"commasPerSentence": {
|
|
7319
|
+
"p10": 1.067,
|
|
7320
|
+
"p50": 1.667,
|
|
7321
|
+
"p90": 2.435,
|
|
7322
|
+
"sd": 0.541,
|
|
7323
|
+
"separates": [
|
|
7324
|
+
"business-email",
|
|
7325
|
+
"explanatory",
|
|
7326
|
+
"institutional",
|
|
7327
|
+
"marketing"
|
|
7328
|
+
]
|
|
7329
|
+
},
|
|
7330
|
+
"coordinationRate": {
|
|
7331
|
+
"p10": 0.194,
|
|
7332
|
+
"p50": 0.814,
|
|
7333
|
+
"p90": 1.633,
|
|
7334
|
+
"sd": 0.572,
|
|
7335
|
+
"separates": [
|
|
7336
|
+
"marketing"
|
|
7337
|
+
]
|
|
7338
|
+
},
|
|
7339
|
+
"figures": {
|
|
7340
|
+
"p10": 0,
|
|
7341
|
+
"p50": 0,
|
|
7342
|
+
"p90": 0,
|
|
7343
|
+
"sd": 0.079,
|
|
7344
|
+
"separates": [
|
|
7345
|
+
"business-email",
|
|
7346
|
+
"explanatory",
|
|
7347
|
+
"institutional",
|
|
7348
|
+
"marketing"
|
|
7349
|
+
]
|
|
7350
|
+
},
|
|
7351
|
+
"firstPersonPer100": {
|
|
7352
|
+
"p10": 2.207,
|
|
7353
|
+
"p50": 4.67,
|
|
7354
|
+
"p90": 7.486,
|
|
7355
|
+
"sd": 2.027,
|
|
7356
|
+
"separates": [
|
|
7357
|
+
"explanatory"
|
|
7358
|
+
]
|
|
7359
|
+
},
|
|
7360
|
+
"generic": {
|
|
7361
|
+
"p10": 0,
|
|
7362
|
+
"p50": 0.2,
|
|
7363
|
+
"p90": 0.4,
|
|
7364
|
+
"sd": 0.178,
|
|
7365
|
+
"separates": [
|
|
7366
|
+
"institutional"
|
|
7367
|
+
]
|
|
7368
|
+
},
|
|
7369
|
+
"hardPer100": {
|
|
7370
|
+
"p10": 1.632,
|
|
7371
|
+
"p50": 3.076,
|
|
7372
|
+
"p90": 5.154,
|
|
7373
|
+
"sd": 1.367,
|
|
7374
|
+
"separates": [
|
|
7375
|
+
"business-email",
|
|
7376
|
+
"institutional"
|
|
7377
|
+
]
|
|
7378
|
+
},
|
|
7379
|
+
"impersonalOpenerShare": {
|
|
7380
|
+
"p10": 0,
|
|
7381
|
+
"p50": 0,
|
|
7382
|
+
"p90": 0.067,
|
|
7383
|
+
"sd": 0.039,
|
|
7384
|
+
"separates": []
|
|
7385
|
+
},
|
|
7386
|
+
"meanSentenceWords": {
|
|
7387
|
+
"p10": 15.083,
|
|
7388
|
+
"p50": 20.35,
|
|
7389
|
+
"p90": 27.027,
|
|
7390
|
+
"sd": 4.744,
|
|
7391
|
+
"separates": [
|
|
7392
|
+
"business-email"
|
|
7393
|
+
]
|
|
7394
|
+
},
|
|
7395
|
+
"meanWordLength": {
|
|
7396
|
+
"p10": 3.958,
|
|
7397
|
+
"p50": 4.186,
|
|
7398
|
+
"p90": 4.409,
|
|
7399
|
+
"sd": 0.175,
|
|
7400
|
+
"separates": [
|
|
7401
|
+
"explanatory"
|
|
7402
|
+
]
|
|
7403
|
+
},
|
|
7404
|
+
"names": {
|
|
7405
|
+
"p10": 1,
|
|
7406
|
+
"p50": 1.8,
|
|
7407
|
+
"p90": 3,
|
|
7408
|
+
"sd": 0.816,
|
|
7409
|
+
"separates": [
|
|
7410
|
+
"institutional"
|
|
7411
|
+
]
|
|
7412
|
+
},
|
|
7413
|
+
"nominalisationRate": {
|
|
7414
|
+
"p10": 0.444,
|
|
7415
|
+
"p50": 1.334,
|
|
7416
|
+
"p90": 2.486,
|
|
7417
|
+
"sd": 0.817,
|
|
7418
|
+
"separates": [
|
|
7419
|
+
"institutional",
|
|
7420
|
+
"marketing"
|
|
7421
|
+
]
|
|
7422
|
+
},
|
|
7423
|
+
"participialRate": {
|
|
7424
|
+
"p10": 0,
|
|
7425
|
+
"p50": 0.067,
|
|
7426
|
+
"p90": 0.2,
|
|
7427
|
+
"sd": 0.089,
|
|
7428
|
+
"separates": [
|
|
7429
|
+
"business-email",
|
|
7430
|
+
"institutional"
|
|
7431
|
+
]
|
|
7432
|
+
},
|
|
7433
|
+
"pronounOpenerShare": {
|
|
7434
|
+
"p10": 0,
|
|
7435
|
+
"p50": 0.025,
|
|
7436
|
+
"p90": 0.12,
|
|
7437
|
+
"sd": 0.058,
|
|
7438
|
+
"separates": [
|
|
7439
|
+
"marketing"
|
|
7440
|
+
]
|
|
7441
|
+
},
|
|
7442
|
+
"sentenceCv": {
|
|
7443
|
+
"p10": 0.367,
|
|
7444
|
+
"p50": 0.485,
|
|
7445
|
+
"p90": 0.625,
|
|
7446
|
+
"sd": 0.1,
|
|
7447
|
+
"separates": [
|
|
7448
|
+
"marketing"
|
|
7449
|
+
]
|
|
7450
|
+
},
|
|
7451
|
+
"skeletonRepeat": {
|
|
7452
|
+
"p10": 5e-3,
|
|
7453
|
+
"p50": 0.029,
|
|
7454
|
+
"p90": 0.07,
|
|
7455
|
+
"sd": 0.028,
|
|
7456
|
+
"separates": []
|
|
7457
|
+
},
|
|
7458
|
+
"specificsPer100": {
|
|
7459
|
+
"p10": 1.8,
|
|
7460
|
+
"p50": 3.28,
|
|
7461
|
+
"p90": 5.24,
|
|
7462
|
+
"sd": 1.365,
|
|
7463
|
+
"separates": [
|
|
7464
|
+
"business-email",
|
|
7465
|
+
"institutional",
|
|
7466
|
+
"marketing"
|
|
7467
|
+
]
|
|
7468
|
+
},
|
|
7469
|
+
"tradePer100": {
|
|
7470
|
+
"p10": 0,
|
|
7471
|
+
"p50": 0,
|
|
7472
|
+
"p90": 0.508,
|
|
7473
|
+
"sd": 0.275,
|
|
7474
|
+
"separates": [
|
|
7475
|
+
"marketing"
|
|
7476
|
+
]
|
|
7477
|
+
},
|
|
7478
|
+
"tricolons": {
|
|
7479
|
+
"p10": 0,
|
|
7480
|
+
"p50": 0.4,
|
|
7481
|
+
"p90": 0.8,
|
|
7482
|
+
"sd": 0.314,
|
|
7483
|
+
"separates": [
|
|
7484
|
+
"business-email"
|
|
7485
|
+
]
|
|
7486
|
+
}
|
|
7487
|
+
},
|
|
7488
|
+
"marketing": {
|
|
7489
|
+
"clauseDepth": {
|
|
7490
|
+
"p10": 0.567,
|
|
7491
|
+
"p50": 0.967,
|
|
7492
|
+
"p90": 1.56,
|
|
7493
|
+
"sd": 0.413,
|
|
7494
|
+
"separates": [
|
|
7495
|
+
"literary"
|
|
7496
|
+
]
|
|
7497
|
+
},
|
|
7498
|
+
"commasPer100": {
|
|
7499
|
+
"p10": 2.169,
|
|
7500
|
+
"p50": 4.087,
|
|
7501
|
+
"p90": 6.434,
|
|
7502
|
+
"sd": 1.667,
|
|
7503
|
+
"separates": [
|
|
7504
|
+
"literary"
|
|
7505
|
+
]
|
|
7506
|
+
},
|
|
7507
|
+
"commasPerSentence": {
|
|
7508
|
+
"p10": 0.4,
|
|
7509
|
+
"p50": 0.8,
|
|
7510
|
+
"p90": 1.35,
|
|
7511
|
+
"sd": 0.402,
|
|
7512
|
+
"separates": [
|
|
7513
|
+
"business-email",
|
|
7514
|
+
"literary"
|
|
7515
|
+
]
|
|
7516
|
+
},
|
|
7517
|
+
"coordinationRate": {
|
|
7518
|
+
"p10": 1.087,
|
|
7519
|
+
"p50": 2.236,
|
|
7520
|
+
"p90": 3.473,
|
|
7521
|
+
"sd": 0.931,
|
|
7522
|
+
"separates": [
|
|
7523
|
+
"business-email",
|
|
7524
|
+
"explanatory",
|
|
7525
|
+
"institutional",
|
|
7526
|
+
"literary"
|
|
7527
|
+
]
|
|
7528
|
+
},
|
|
7529
|
+
"figures": {
|
|
7530
|
+
"p10": 0,
|
|
7531
|
+
"p50": 0.4,
|
|
7532
|
+
"p90": 1,
|
|
7533
|
+
"sd": 0.427,
|
|
7534
|
+
"separates": [
|
|
7535
|
+
"literary"
|
|
7536
|
+
]
|
|
7537
|
+
},
|
|
7538
|
+
"generic": {
|
|
7539
|
+
"p10": 0,
|
|
7540
|
+
"p50": 0.2,
|
|
7541
|
+
"p90": 0.6,
|
|
7542
|
+
"sd": 0.206,
|
|
7543
|
+
"separates": [
|
|
7544
|
+
"institutional"
|
|
7545
|
+
]
|
|
7546
|
+
},
|
|
7547
|
+
"hardPer100": {
|
|
7548
|
+
"p10": 1.899,
|
|
7549
|
+
"p50": 4.549,
|
|
7550
|
+
"p90": 8.227,
|
|
7551
|
+
"sd": 2.655,
|
|
7552
|
+
"separates": [
|
|
7553
|
+
"explanatory"
|
|
7554
|
+
]
|
|
7555
|
+
},
|
|
7556
|
+
"impersonalOpenerShare": {
|
|
7557
|
+
"p10": 0,
|
|
7558
|
+
"p50": 0,
|
|
7559
|
+
"p90": 0.1,
|
|
7560
|
+
"sd": 0.047,
|
|
7561
|
+
"separates": []
|
|
7562
|
+
},
|
|
7563
|
+
"names": {
|
|
7564
|
+
"p10": 0.6,
|
|
7565
|
+
"p50": 1.8,
|
|
7566
|
+
"p90": 3.4,
|
|
7567
|
+
"sd": 1.21,
|
|
7568
|
+
"separates": [
|
|
7569
|
+
"institutional"
|
|
7570
|
+
]
|
|
7571
|
+
},
|
|
7572
|
+
"nominalisationRate": {
|
|
7573
|
+
"p10": 1.576,
|
|
7574
|
+
"p50": 3.222,
|
|
7575
|
+
"p90": 5.534,
|
|
7576
|
+
"sd": 1.6,
|
|
7577
|
+
"separates": [
|
|
7578
|
+
"business-email",
|
|
7579
|
+
"explanatory",
|
|
7580
|
+
"literary"
|
|
7581
|
+
]
|
|
7582
|
+
},
|
|
7583
|
+
"participialRate": {
|
|
7584
|
+
"p10": 0,
|
|
7585
|
+
"p50": 0,
|
|
7586
|
+
"p90": 0.133,
|
|
7587
|
+
"sd": 0.062,
|
|
7588
|
+
"separates": []
|
|
7589
|
+
},
|
|
7590
|
+
"pronounOpenerShare": {
|
|
7591
|
+
"p10": 0.067,
|
|
7592
|
+
"p50": 0.213,
|
|
7593
|
+
"p90": 0.4,
|
|
7594
|
+
"sd": 0.136,
|
|
7595
|
+
"separates": [
|
|
7596
|
+
"business-email",
|
|
7597
|
+
"explanatory",
|
|
7598
|
+
"institutional",
|
|
7599
|
+
"literary"
|
|
7600
|
+
]
|
|
7601
|
+
},
|
|
7602
|
+
"sentenceCv": {
|
|
7603
|
+
"p10": 0.275,
|
|
7604
|
+
"p50": 0.377,
|
|
7605
|
+
"p90": 0.52,
|
|
7606
|
+
"sd": 0.096,
|
|
7607
|
+
"separates": [
|
|
7608
|
+
"business-email",
|
|
7609
|
+
"institutional",
|
|
7610
|
+
"literary"
|
|
7611
|
+
]
|
|
7612
|
+
},
|
|
7613
|
+
"skeletonRepeat": {
|
|
7614
|
+
"p10": 0,
|
|
7615
|
+
"p50": 0.031,
|
|
7616
|
+
"p90": 0.081,
|
|
7617
|
+
"sd": 0.038,
|
|
7618
|
+
"separates": []
|
|
7619
|
+
},
|
|
7620
|
+
"specificsPer100": {
|
|
7621
|
+
"p10": 2.54,
|
|
7622
|
+
"p50": 5.2,
|
|
7623
|
+
"p90": 9.18,
|
|
7624
|
+
"sd": 2.733,
|
|
7625
|
+
"separates": [
|
|
7626
|
+
"explanatory",
|
|
7627
|
+
"literary"
|
|
7628
|
+
]
|
|
7629
|
+
},
|
|
7630
|
+
"tradePer100": {
|
|
7631
|
+
"p10": 0,
|
|
7632
|
+
"p50": 0.592,
|
|
7633
|
+
"p90": 1.515,
|
|
7634
|
+
"sd": 0.612,
|
|
7635
|
+
"separates": [
|
|
7636
|
+
"business-email",
|
|
7637
|
+
"explanatory",
|
|
7638
|
+
"institutional",
|
|
7639
|
+
"literary"
|
|
7640
|
+
]
|
|
7641
|
+
},
|
|
7642
|
+
"tricolons": {
|
|
7643
|
+
"p10": 0,
|
|
7644
|
+
"p50": 0.4,
|
|
7645
|
+
"p90": 0.8,
|
|
7646
|
+
"sd": 0.309,
|
|
7647
|
+
"separates": [
|
|
7648
|
+
"business-email"
|
|
7649
|
+
]
|
|
7650
|
+
}
|
|
7651
|
+
}
|
|
7652
|
+
};
|
|
7653
|
+
|
|
6247
7654
|
// src/character/baseline.ts
|
|
6248
7655
|
var BASELINE_VERSION = 1;
|
|
6249
7656
|
function fnv1a(text) {
|
|
@@ -7551,10 +8958,11 @@ function choiceOfShared(part) {
|
|
|
7551
8958
|
}
|
|
7552
8959
|
|
|
7553
8960
|
// src/calibrate/index.ts
|
|
7554
|
-
var
|
|
8961
|
+
var LABELS2 = ["ai", "ai-looking", "human"];
|
|
7555
8962
|
var FLAGGED_TARGET = 0.9;
|
|
7556
8963
|
var HUMAN_TYPICAL_TARGET = 0.1;
|
|
7557
8964
|
var SURFACE = new Map(CATALOGUE.map((t) => [t.id, t.surface]));
|
|
8965
|
+
var GENERATION = new Map(CATALOGUE.map((t) => [t.id, t.generation]));
|
|
7558
8966
|
function designTells(tells) {
|
|
7559
8967
|
return tells.filter((t) => SURFACE.has(t) && SURFACE.get(t) !== "copy");
|
|
7560
8968
|
}
|
|
@@ -7583,15 +8991,15 @@ function flaggedTarget(target2, s, missing) {
|
|
|
7583
8991
|
}
|
|
7584
8992
|
function calibrate(pages, unmeasured = []) {
|
|
7585
8993
|
const typicality2 = pages.length > 0 && pages.every((p) => p.typicality !== void 0);
|
|
7586
|
-
const labels =
|
|
8994
|
+
const labels = LABELS2.map((l) => summarise(l, pages, typicality2));
|
|
7587
8995
|
const byLabel = Object.fromEntries(labels.map((s) => [s.label, s]));
|
|
7588
8996
|
const missing = (l) => unmeasured.filter((u) => u.label === l).length;
|
|
7589
8997
|
const positives = pages.filter((p) => positive(p.label)).length;
|
|
7590
8998
|
const fired = new Set(pages.flatMap((p) => p.tells));
|
|
7591
8999
|
const tells = [...fired].map((tell) => {
|
|
7592
|
-
const hits = Object.fromEntries(
|
|
9000
|
+
const hits = Object.fromEntries(LABELS2.map((l) => [l, pages.filter((p) => p.label === l && p.tells.includes(tell)).length]));
|
|
7593
9001
|
const on = hits.ai + hits["ai-looking"];
|
|
7594
|
-
return { tell, hits, precision: round2(on / (on + hits.human)), recall: positives ? round2(on / positives) : null };
|
|
9002
|
+
return { tell, generation: GENERATION.get(tell) ?? null, hits, precision: round2(on / (on + hits.human)), recall: positives ? round2(on / positives) : null };
|
|
7595
9003
|
}).sort((a, b) => b.hits.ai + b.hits["ai-looking"] + b.hits.human - (a.hits.ai + a.hits["ai-looking"] + a.hits.human) || a.tell.localeCompare(b.tell));
|
|
7596
9004
|
const human = byLabel.human;
|
|
7597
9005
|
const humanNote = missing("human") ? `; ${missing("human")} not measured, counted neither way` : "";
|
|
@@ -7623,18 +9031,18 @@ function formatCalibration(c, notes = []) {
|
|
|
7623
9031
|
lines.push("", `Not measured: ${c.unmeasured.length}. A page not measured never counts as a pass.`);
|
|
7624
9032
|
for (const u of c.unmeasured) lines.push(` ${u.id} (${u.label}): ${u.reason}`);
|
|
7625
9033
|
}
|
|
7626
|
-
lines.push("", "Targets");
|
|
9034
|
+
lines.push("", "Flagged is a look-closer signal, not a verdict that a site is AI-made. Nothing gates on it.", "", "Targets");
|
|
7627
9035
|
for (const t of c.targets) lines.push(` ${t.target.padEnd(50)} ${t.met === null ? "not known" : t.met ? "met" : "NOT MET"}`, ` ${t.detail}`);
|
|
7628
9036
|
lines.push("", ` ${"label".padEnd(11)} ${"pages".padStart(5)} ${"flagged".padStart(8)} ${"typical".padStart(8)} ${"tell-heavy".padStart(11)} ${"blocking".padStart(9)}`);
|
|
7629
9037
|
for (const s of c.labels) {
|
|
7630
9038
|
lines.push(` ${s.label.padEnd(11)} ${String(s.pages).padStart(5)} ${String(s.flagged).padStart(8)} ${String(s.typical ?? "-").padStart(8)} ${String(s.tellHeavy).padStart(11)} ${String(s.blocking).padStart(9)}`);
|
|
7631
9039
|
}
|
|
7632
9040
|
lines.push("", "Per tell. A hit on ai or ai-looking counts for the tell; a hit on human counts against it.");
|
|
7633
|
-
lines.push(` ${"tell".padEnd(28)} ${"ai".padStart(7)} ${"ai-looking".padStart(10)} ${"human".padStart(7)} ${"precision".padStart(9)} ${"recall".padStart(7)}`);
|
|
9041
|
+
lines.push(` ${"tell".padEnd(28)} ${"gen".padStart(3)} ${"ai".padStart(7)} ${"ai-looking".padStart(10)} ${"human".padStart(7)} ${"precision".padStart(9)} ${"recall".padStart(7)}`);
|
|
7634
9042
|
const of = (l) => c.labels.find((s) => s.label === l)?.pages ?? 0;
|
|
7635
9043
|
for (const t of c.tells) {
|
|
7636
9044
|
lines.push(
|
|
7637
|
-
` ${t.tell.padEnd(28)} ${`${t.hits.ai}/${of("ai")}`.padStart(7)} ${`${t.hits["ai-looking"]}/${of("ai-looking")}`.padStart(10)} ${`${t.hits.human}/${of("human")}`.padStart(7)} ${t.precision.toFixed(2).padStart(9)} ${(t.recall === null ? "-" : t.recall.toFixed(2)).padStart(7)}`
|
|
9045
|
+
` ${t.tell.padEnd(28)} ${String(t.generation ?? "-").padStart(3)} ${`${t.hits.ai}/${of("ai")}`.padStart(7)} ${`${t.hits["ai-looking"]}/${of("ai-looking")}`.padStart(10)} ${`${t.hits.human}/${of("human")}`.padStart(7)} ${t.precision.toFixed(2).padStart(9)} ${(t.recall === null ? "-" : t.recall.toFixed(2)).padStart(7)}`
|
|
7638
9046
|
);
|
|
7639
9047
|
}
|
|
7640
9048
|
if (!c.tells.length) lines.push(" no tell fired");
|
|
@@ -7763,6 +9171,7 @@ export {
|
|
|
7763
9171
|
CHOICE_KEYS,
|
|
7764
9172
|
COMPONENT_ROLES,
|
|
7765
9173
|
CONSIDERATION,
|
|
9174
|
+
CONTENT_FEATURES,
|
|
7766
9175
|
CONVENTION,
|
|
7767
9176
|
CUSTOMER_KINDS,
|
|
7768
9177
|
DEFAULT_IGNORE,
|
|
@@ -7793,11 +9202,12 @@ export {
|
|
|
7793
9202
|
HUMAN_TYPICAL_TARGET,
|
|
7794
9203
|
IMAGERY_TELLS,
|
|
7795
9204
|
JSON_SCHEMA_VERSION,
|
|
7796
|
-
LABELS,
|
|
9205
|
+
LABELS2 as LABELS,
|
|
7797
9206
|
LEXICAL_FEATURES,
|
|
7798
9207
|
LICENCES,
|
|
7799
9208
|
LIGHTNESS_CURVE,
|
|
7800
9209
|
MIN_DECIDED,
|
|
9210
|
+
MIN_PARAGRAPHS,
|
|
7801
9211
|
MIN_RUNS,
|
|
7802
9212
|
MOOD,
|
|
7803
9213
|
NEGATIVE_REASSURANCE,
|
|
@@ -7806,6 +9216,9 @@ export {
|
|
|
7806
9216
|
PILL_LIMIT,
|
|
7807
9217
|
PLAINER_WORDS,
|
|
7808
9218
|
PREFERENCE,
|
|
9219
|
+
PROFILE,
|
|
9220
|
+
PROFILE_MEASURED,
|
|
9221
|
+
PROFILE_PARAGRAPHS,
|
|
7809
9222
|
PROMO_BADGE,
|
|
7810
9223
|
PROOF_NAMES,
|
|
7811
9224
|
PROPOSED,
|
|
@@ -7814,10 +9227,15 @@ export {
|
|
|
7814
9227
|
READABLE_SNAPSHOT_VERSIONS,
|
|
7815
9228
|
REFLEX_FONTS_1,
|
|
7816
9229
|
REFLEX_FONTS_2,
|
|
9230
|
+
REGISTERS,
|
|
9231
|
+
REGISTER_BASELINE,
|
|
9232
|
+
REGISTER_FEATURES,
|
|
9233
|
+
REGISTER_IDS,
|
|
7817
9234
|
RENDERED_PATHS,
|
|
7818
9235
|
RENDERED_TELLS,
|
|
7819
9236
|
REVEAL_LIMIT,
|
|
7820
9237
|
REVIEW_PHRASES,
|
|
9238
|
+
SAMPLES_PER_SEGMENT,
|
|
7821
9239
|
SCALE,
|
|
7822
9240
|
SECTION_ROLES,
|
|
7823
9241
|
SHADCN_LIMIT,
|
|
@@ -7855,7 +9273,9 @@ export {
|
|
|
7855
9273
|
checkCopy,
|
|
7856
9274
|
checkOrder,
|
|
7857
9275
|
checkPair,
|
|
9276
|
+
checkPhotoReview,
|
|
7858
9277
|
checkReason,
|
|
9278
|
+
checkRegister,
|
|
7859
9279
|
checkRestraint,
|
|
7860
9280
|
choicesOf,
|
|
7861
9281
|
clauseDepth,
|
|
@@ -7880,6 +9300,7 @@ export {
|
|
|
7880
9300
|
densityCss,
|
|
7881
9301
|
densityTokens,
|
|
7882
9302
|
designTells,
|
|
9303
|
+
documentParagraphs,
|
|
7883
9304
|
emitCss,
|
|
7884
9305
|
emptyEstate,
|
|
7885
9306
|
estateComponentPairs,
|
|
@@ -7887,6 +9308,7 @@ export {
|
|
|
7887
9308
|
exitDuration,
|
|
7888
9309
|
extractHtml,
|
|
7889
9310
|
faceLicence,
|
|
9311
|
+
featureLabel,
|
|
7890
9312
|
findClaims,
|
|
7891
9313
|
findColours,
|
|
7892
9314
|
findingKey,
|
|
@@ -7903,7 +9325,10 @@ export {
|
|
|
7903
9325
|
formatDirectionMatches,
|
|
7904
9326
|
formatHex,
|
|
7905
9327
|
formatReport,
|
|
9328
|
+
getRegister,
|
|
7906
9329
|
globToRegExp,
|
|
9330
|
+
gradientContrast,
|
|
9331
|
+
gradientStops,
|
|
7907
9332
|
groundName,
|
|
7908
9333
|
harvest,
|
|
7909
9334
|
hedgeCount,
|
|
@@ -7949,6 +9374,9 @@ export {
|
|
|
7949
9374
|
ramp,
|
|
7950
9375
|
rampFromAnchors,
|
|
7951
9376
|
readSnapshot,
|
|
9377
|
+
registerBrief,
|
|
9378
|
+
registerOf,
|
|
9379
|
+
registersDoc,
|
|
7952
9380
|
renderedOrder,
|
|
7953
9381
|
researchPrompt,
|
|
7954
9382
|
retrofitPlan,
|