Commit b58d2f8b by PLN (Algolia)

cli: cadence measures block in check, linter-style --select/--ignore

Measures ride alongside the hits, human and JSON alike, and never touch
the score. Flags take measure ids or the cadence group; ignore wins.
The documented
== AGENTS.md — 65/100 (305 mots)
  [budget tiret cadratin (>1/305 mots)] ×7 (-5 chacun)
      occurrence 2
      occurrence 3
      occurrence 4
      occurrence 5

== README.md — 0/100 (970 mots)
  [contraste binaire] ×1 (-8 chacun)
      …peners, the inflated adjectives, the "Ce n'est pas X, c'est Y" pivots, the tirets cadratin…
  [budget tiret cadratin (>1/970 mots)] ×27 (-5 chacun)
      occurrence 2
      occurrence 3
      occurrence 4
      occurrence 5

== SKILL.md — 100/100 (178 mots)

== docs/research-litreview.md — 44/100 (2983 mots)
  [faux poids] ×1 (-8 chacun)
      … just X, but also Y" and "serves as / stands as / marks / functions as / operates as / rep…
  [servilité/méta] ×2 (-10 chacun)
      …pendently catalogs "binary contrasts" as an AI tell: https://github.com/hardikpandya/stop-…
      …ia's signs page lists "Rule of three" as an AI indicator without claiming any single trico…
  [adjectif gonflé] ×3 (-5 chacun)
      …ve word frequency shifts are the most robust, hardest-to-avoid signal, and they are exac…
      …ts at https://gitlab.inria.fr/wantoun/robust-chatgpt-detection) built its French data by t…
      …ncy shifts, not single words, are the robust signal (arxiv 2406.07016). 5. **Cap total …
  [contraste binaire] ×1 (-8 chacun)
      …ion as a top indicator, in the forms "not just X, but also Y" and "serves as / stands as /…
  [budget exclamation (>2/2983 mots)] ×1 (-5 chacun)
      occurrence 3

== docs/research.md — 33/100 (748 mots)
  [anti-copule] ×1 (-5 chacun)
      …ommencer par le fond | | Anti-copule (constitue, serves as) | 4/5 | « est » presque toujou…
  [faux poids] ×1 (-8 chacun)
      …affirmative | | Faux poids (tournant, game-changer) | 3/5 | le chiffre ou l'exemple | | Se…
  [adjectif gonflé] ×4 (-5 chacun)
      …e colle | | Adjectifs gonflés | 5/5 | révolutionnaire, incontournable, robuste, seamless… …
      …tifs gonflés | 5/5 | révolutionnaire, incontournable, robuste, seamless… le fait ou rien |…
      …/5 | révolutionnaire, incontournable, robuste, seamless… le fait ou rien | | Règle de troi…
      …lutionnaire, incontournable, robuste, seamless… le fait ou rien | | Règle de trois | 5/5 |…
  [adverbe remplissage] ×3 (-3 chacun)
      …t | | Adverbes de remplissage | 4/5 | vraiment, littéralement, fondamentalement → supprime…
      …rbes de remplissage | 4/5 | vraiment, littéralement, fondamentalement → supprimer | | Ouve…
      …sage | 4/5 | vraiment, littéralement, fondamentalement → supprimer | | Ouvertures à vide |…
  [budget tiret cadratin (>1/748 mots)] ×5 (-5 chacun)
      occurrence 2
      occurrence 3
      occurrence 4
      occurrence 5

== test/fixtures/article-excerpt.txt — 100/100 (300 mots)

---- buvard v2 ----
 65/100  AGENTS.md
  0/100  README.md
100/100  SKILL.md
 44/100  docs/research-litreview.md
 33/100  docs/research.md
100/100  test/fixtures/article-excerpt.txt
priorité: README.md (0/100) verb is now dropped instead of collected
as a phantom target.
parent a05d764f
...@@ -20,6 +20,47 @@ buvard check posts/ # scores + grouped hits, per file ...@@ -20,6 +20,47 @@ buvard check posts/ # scores + grouped hits, per file
buvard check article.md --json # machine-readable, for pipelines buvard check article.md --json # machine-readable, for pipelines
``` ```
## Cadence measures
Above the vocabulary sits the rhythm, and rhythm is where a text can score
100 yet still read machine-flavored. `buvard check` therefore reports five
**cadence measures** alongside the hits — informational signals, never
verdicts: they never touch the score, and a staccato paragraph can be the
best thing in a text.
- **staccato** — share of paragraphs that are one sentence of ≤ 25 words.
- **triads** — "X, Y and Z" / "X, Y et Z" enumerations per 1000 words
(precision-first: single-word items only, so it undercounts).
- **antithesis** — contrastive constructs per 1000 words ("not X; it's Y",
"ce n'est pas X, c'est Y", …). Regexes miss balanced contrasts without
"not" and any parallelism carried by morphology; the module doc lists the
gaps and leaves the seam for a smarter pass.
- **bookends** — content-word overlap between the first and last paragraph
(Jaccard, lowercased, stopword-filtered). An intro promise repeated in the
coda shows up here.
- **sentence-cv** — coefficient of variation of sentence lengths, a
burstiness proxy: uniform droning scores low, varied prose scores high.
Baseline rates on a 15-text pre-2022 Gutenberg human corpus:
[docs/cadence-corpus.md](docs/cadence-corpus.md) — report-only for now, the
calibration comes later against the same < 2% false-positive gate as the
catalog.
Linter-style selection, matching the ergonomics of eslint and friends:
```bash
buvard check posts/ # all measures on, report-only
buvard check posts/ --ignore bookends # drop one measure
buvard check posts/ --select cadence # the whole group
buvard check posts/ --select staccato,triads # specific ids
buvard check posts/ --select cadence --ignore staccato
```
`--select` restricts, `--ignore` removes, and ignore wins; ids and the group
name `cadence` both work. An emptied selection drops the whole `measures`
block (human and `--json` alike). The regex catalog itself has no selection
yet — flags currently scope to the measures only.
## The barème ## The barème
Score starts at 100. A lexique hit costs 5, a structure hit 8, servility or Score starts at 100. A lexique hit costs 5, a structure hit 8, servility or
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* buvard — l'anti-slop qui tache. Blotting paper for AI-flavored prose. * buvard — l'anti-slop qui tache. Blotting paper for AI-flavored prose.
* *
* buvard check [files|dirs] [--json] [--hidden] run the catalog over markdown/text * buvard check [files|dirs] [--json] [--hidden] [--select ids] [--ignore ids]
* buvard score <file> [--json] single-file score, machine-readable * buvard score <file> [--json] single-file score, machine-readable
* buvard --help | --version * buvard --help | --version
* *
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
* Walks skip dot-directories (--hidden to include) and never follow directory * Walks skip dot-directories (--hidden to include) and never follow directory
* symlinks; unreadable directories are warned about, not fatal. * symlinks; unreadable directories are warned about, not fatal.
* *
* Alongside the score, `check` reports cadence measures (group `cadence`:
* staccato, triads, antithesis, bookends, sentence-cv). They are signals,
* never verdicts: they never touch the score. --select/--ignore take a
* comma list of measure ids or group names; an emptied selection drops the
* whole block.
*
* Known gaps, deliberately manual: règle de trois, synonyme acrobatique and * Known gaps, deliberately manual: règle de trois, synonyme acrobatique and
* sentence-length variance need document-level analysis that regex fakes * sentence-length variance need document-level analysis that regex fakes
* badly. Read the text too. * badly. Read the text too.
...@@ -21,7 +27,7 @@ ...@@ -21,7 +27,7 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { CATALOG_VERSION, lint, bodyOf } from '../lib/index.mjs'; import { CATALOG_VERSION, lint, bodyOf, measuresOf, filterMeasures } from '../lib/index.mjs';
const TEXT_EXT = /\.(md|txt|mdx)$/i; const TEXT_EXT = /\.(md|txt|mdx)$/i;
const PKG_VERSION = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version; const PKG_VERSION = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
...@@ -35,8 +41,10 @@ Usage: ...@@ -35,8 +41,10 @@ Usage:
buvard --version package version buvard --version package version
Options: Options:
--json machine-readable output --json machine-readable output
--hidden include dot-directories when walking (skipped by default) --hidden include dot-directories when walking (skipped by default)
--select ids comma list of measure ids or groups to keep (check)
--ignore ids comma list of measure ids or groups to drop (check)
Scoring: 100 base; each hit costs its weight (lexique -5, structure -8, Scoring: 100 base; each hit costs its weight (lexique -5, structure -8,
servile -10; punctuation past budget charges per occurrence: one tiret servile -10; punctuation past budget charges per occurrence: one tiret
...@@ -91,15 +99,34 @@ function scoreReport(file, json) { ...@@ -91,15 +99,34 @@ function scoreReport(file, json) {
console.log(`${r.score}/100 ${path.relative(process.cwd(), r.file)} (${r.words} mots, ${r.hits.length} candidat${r.hits.length === 1 ? '' : 's'})`); console.log(`${r.score}/100 ${path.relative(process.cwd(), r.file)} (${r.words} mots, ${r.hits.length} candidat${r.hits.length === 1 ? '' : 's'})`);
} }
/** One human-readable segment per selected measure; counts come from the full run. */
function cadenceLine(selected, full) {
const parts = [];
if ('staccato' in selected) parts.push(`staccato ${Math.round(selected.staccato * 100)}% (${full.staccato_count}/${full.paragraphs})`);
if ('triads' in selected) parts.push(`triades ${selected.triads.toFixed(1)}/1000w`);
if ('antithesis' in selected) parts.push(`antithèses ${selected.antithesis.toFixed(1)}/1000w`);
if ('bookends' in selected) parts.push(`bookends ${selected.bookends.toFixed(2)}`);
if ('sentence-cv' in selected) parts.push(`cv phrases ${selected['sentence-cv'].toFixed(2)}`);
return parts.join(' · ');
}
function main(argv) { function main(argv) {
const flags = new Set(); const flags = new Set();
const select = [];
const ignore = [];
const positional = []; const positional = [];
for (const a of argv) { // The documented invocation is `buvard check <targets>`; the verb itself
// names no file, so it is dropped, not collected.
for (let i = 0; i < argv.length; i++) {
const a = argv[i];
if (!a.startsWith('-')) { if (!a.startsWith('-')) {
positional.push(a); positional.push(a);
continue; continue;
} }
if (a === '--json' || a === '--hidden') { if (a === '--select' || a === '--ignore' || a.startsWith('--select=') || a.startsWith('--ignore=')) {
const val = a.includes('=') ? a.slice(a.indexOf('=') + 1) : argv[++i];
(a.startsWith('--select') ? select : ignore).push(...String(val ?? '').split(',').filter(Boolean));
} else if (a === '--json' || a === '--hidden') {
flags.add(a); flags.add(a);
} else if (a === '-h' || a === '--help') { } else if (a === '-h' || a === '--help') {
console.log(USAGE); console.log(USAGE);
...@@ -142,13 +169,20 @@ function main(argv) { ...@@ -142,13 +169,20 @@ function main(argv) {
errors.forEach((e) => console.error(e)); errors.forEach((e) => console.error(e));
if (files.length === 0 && positional.length > 0) return 2; if (files.length === 0 && positional.length > 0) return 2;
const results = files.map((file) => ({ file, ...lint(bodyOf(fs.readFileSync(file, 'utf8'))) })); const results = files.map((file) => {
const body = bodyOf(fs.readFileSync(file, 'utf8'));
const full = measuresOf(body);
const r = { file, ...lint(body) };
const selected = filterMeasures(full, { select, ignore });
if (Object.keys(selected).length > 0) r.measures = selected;
return { r, full };
});
if (json) { if (json) {
console.log(JSON.stringify({ buvard: CATALOG_VERSION, results }, null, 1)); console.log(JSON.stringify({ buvard: CATALOG_VERSION, results: results.map(({ r }) => r) }, null, 1));
return 0; return 0;
} }
for (const r of results) { for (const { r, full } of results) {
const grouped = {}; const grouped = {};
for (const h of r.hits) (grouped[h.id] ??= []).push(h); for (const h of r.hits) (grouped[h.id] ??= []).push(h);
console.log(`\n== ${path.relative(process.cwd(), r.file)} — ${r.score}/100 (${r.words} mots)`); console.log(`\n== ${path.relative(process.cwd(), r.file)} — ${r.score}/100 (${r.words} mots)`);
...@@ -156,10 +190,11 @@ function main(argv) { ...@@ -156,10 +190,11 @@ function main(argv) {
console.log(` [${id}] ×${list.length} (-${list[0].w} chacun)`); console.log(` [${id}] ×${list.length} (-${list[0].w} chacun)`);
for (const h of list.slice(0, 4)) console.log(` ${h.at}`); for (const h of list.slice(0, 4)) console.log(` ${h.at}`);
} }
if (r.measures) console.log(` cadence (signaux, jamais un verdict): ${cadenceLine(r.measures, full)}`);
} }
console.log(`\n---- buvard v${CATALOG_VERSION} ----`); console.log(`\n---- buvard v${CATALOG_VERSION} ----`);
for (const r of results) console.log(`${String(r.score).padStart(3)}/100 ${path.relative(process.cwd(), r.file)}`); for (const { r } of results) console.log(`${String(r.score).padStart(3)}/100 ${path.relative(process.cwd(), r.file)}`);
const worst = results.filter((r) => r.hits.length > 0).sort((a, b) => a.score - b.score)[0]; const worst = results.map(({ r }) => r).filter((r) => r.hits.length > 0).sort((a, b) => a.score - b.score)[0];
if (worst) console.log(`priorité: ${path.relative(process.cwd(), worst.file)} (${worst.score}/100)`); if (worst) console.log(`priorité: ${path.relative(process.cwd(), worst.file)} (${worst.score}/100)`);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment