paperlint 16.8.0 → 17.1.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/CLAUDE.md +10 -2
- package/CONTRIBUTING.md +1 -1
- package/README.md +17 -14
- package/dist/adapters/latex/abstract.d.ts +7 -1
- package/dist/adapters/latex/abstract.d.ts.map +1 -1
- package/dist/adapters/latex/abstract.js +19 -4
- package/dist/adapters/latex/abstract.js.map +1 -1
- package/dist/adapters/latex/captions.d.ts +6 -5
- package/dist/adapters/latex/captions.d.ts.map +1 -1
- package/dist/adapters/latex/captions.js +14 -30
- package/dist/adapters/latex/captions.js.map +1 -1
- package/dist/adapters/latex/index.d.ts +1 -1
- package/dist/adapters/latex/index.d.ts.map +1 -1
- package/dist/adapters/latex/index.js +5 -2
- package/dist/adapters/latex/index.js.map +1 -1
- package/dist/adapters/latex/prose.d.ts +6 -0
- package/dist/adapters/latex/prose.d.ts.map +1 -1
- package/dist/adapters/latex/prose.js +18 -12
- package/dist/adapters/latex/prose.js.map +1 -1
- package/dist/cli.d.ts +6 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +16 -8
- package/dist/cli.js.map +1 -1
- package/dist/domain/register.d.ts +23 -1
- package/dist/domain/register.d.ts.map +1 -1
- package/dist/domain/register.js +37 -14
- package/dist/domain/register.js.map +1 -1
- package/dist/domain/term-definitions.d.ts +48 -0
- package/dist/domain/term-definitions.d.ts.map +1 -0
- package/dist/domain/term-definitions.js +228 -0
- package/dist/domain/term-definitions.js.map +1 -0
- package/dist/domain/tex-document.d.ts +11 -0
- package/dist/domain/tex-document.d.ts.map +1 -1
- package/dist/domain/tex-document.js.map +1 -1
- package/dist/eslint-rules/review-frontmatter.js +5 -5
- package/dist/eslint-rules/review-frontmatter.schema.json +15 -8
- package/dist/eslint-rules/sibling-frontmatter.d.ts.map +1 -1
- package/dist/folder-venue-rule.d.ts +1 -1
- package/dist/folder-venue-rule.d.ts.map +1 -1
- package/dist/folder-venue-rule.js +4 -2
- package/dist/folder-venue-rule.js.map +1 -1
- package/dist/hooks-notice.d.ts +3 -3
- package/dist/hooks-notice.d.ts.map +1 -1
- package/dist/hooks-notice.js +41 -8
- package/dist/hooks-notice.js.map +1 -1
- package/dist/link-skills.d.ts +5 -0
- package/dist/link-skills.d.ts.map +1 -1
- package/dist/link-skills.js +7 -0
- package/dist/link-skills.js.map +1 -1
- package/dist/ports/latex.d.ts +11 -1
- package/dist/ports/latex.d.ts.map +1 -1
- package/dist/presets.d.ts +21 -2
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +66 -17
- package/dist/presets.js.map +1 -1
- package/dist/readability.d.ts +12 -2
- package/dist/readability.d.ts.map +1 -1
- package/dist/readability.js +76 -3
- package/dist/readability.js.map +1 -1
- package/dist/register-bands.d.ts +16 -5
- package/dist/register-bands.d.ts.map +1 -1
- package/dist/register-bands.js +56 -17
- package/dist/register-bands.js.map +1 -1
- package/dist/skills/argument-arc/scripts/headings-core.d.ts +12 -0
- package/dist/skills/argument-arc/scripts/headings.d.ts +2 -0
- package/dist/skills/cold-read-diff/scripts/cold-read-core.d.ts +12 -0
- package/dist/skills/cold-read-diff/scripts/readers.d.ts +2 -1
- package/dist/term-definition-rules.d.ts +26 -0
- package/dist/term-definition-rules.d.ts.map +1 -0
- package/dist/term-definition-rules.js +137 -0
- package/dist/term-definition-rules.js.map +1 -0
- package/dist/tex-paper.d.ts +6 -0
- package/dist/tex-paper.d.ts.map +1 -1
- package/dist/tex-paper.js +10 -0
- package/dist/tex-paper.js.map +1 -1
- package/dist/tex-requirements.d.ts +2 -0
- package/dist/tex-requirements.d.ts.map +1 -1
- package/dist/tex-requirements.js +9 -0
- package/dist/tex-requirements.js.map +1 -1
- package/dist/tex-venue-rules.d.ts +3 -2
- package/dist/tex-venue-rules.d.ts.map +1 -1
- package/dist/tex-venue-rules.js +3 -2
- package/dist/tex-venue-rules.js.map +1 -1
- package/docs/configuration.md +2 -2
- package/{skills/paper-pipeline/references → docs/design}/acceptance-gate.md +50 -53
- package/docs/design/paper-pipeline-history.md +217 -0
- package/docs/design/skill-provenance.md +132 -0
- package/docs/design/study-modes.md +1 -1
- package/docs/design/verify-citations-history.md +135 -0
- package/docs/design/writing-exemplars.md +19 -0
- package/docs/install.md +7 -4
- package/docs/layout.md +5 -4
- package/docs/optional-rules.md +4 -0
- package/docs/osf-artifact.md +54 -0
- package/docs/pipeline.md +171 -0
- package/docs/render.md +82 -0
- package/docs/rules/paper/folder-venue-leftover.md +10 -7
- package/docs/rules/tex/contrast-frames.md +1 -2
- package/docs/rules/tex/max-caption-words.md +82 -0
- package/docs/rules/tex/max-paragraph-words.md +2 -2
- package/docs/rules/tex/negated-sentences.md +96 -0
- package/docs/rules/tex/term-before-definition.md +103 -0
- package/docs/rules/tex/term-defined-twice.md +62 -0
- package/docs/rules/tex/venue-leftover.md +13 -1
- package/docs/rules.md +23 -18
- package/docs/skills.md +16 -21
- package/docs/submission.md +14 -0
- package/docs/texlive-install-decision.md +1 -1
- package/docs/toolchain.md +11 -11
- package/eslint-rules/review-frontmatter.schema.json +15 -8
- package/eslint-rules/review-frontmatter.test.mjs +8 -5
- package/eslint-rules/review-frontmatter.ts +5 -5
- package/eslint.config.mjs +1 -5
- package/hooks/paper-status-gates.sh +21 -4
- package/hooks/paper-status-gates.test.ts +51 -0
- package/lib/skill-checks.test.mjs +2 -6
- package/lib/skill-trigger-cases.mjs +12 -97
- package/lib/skill-trigger-cases.test.ts +0 -6
- package/package.json +3 -1
- package/presets/acm-sigconf.md +1 -1
- package/presets/agenticdev.jsonc +5 -2
- package/presets/agenticdev.md +4 -2
- package/presets/aidc.jsonc +14 -1
- package/presets/aidc.md +3 -2
- package/presets/aisec.jsonc +9 -3
- package/presets/aisec.md +4 -1
- package/presets/ase.jsonc +145 -0
- package/presets/ase.md +178 -0
- package/presets/ccs.jsonc +87 -0
- package/presets/ccs.md +184 -0
- package/presets/icse.jsonc +100 -0
- package/presets/icse.md +126 -0
- package/presets/ieee-conference.md +1 -1
- package/presets/sp.jsonc +152 -0
- package/presets/sp.md +160 -0
- package/presets/venue-profile.schema.json +22 -3
- package/scripts/harness-api.frozen.json +0 -4
- package/scripts/pipeline.ts +481 -0
- package/skills/CLAUDE.md +2 -2
- package/skills/CLAUDE.md.spec.ts +26 -1
- package/skills/analyze-sibling-paper/SKILL.md +2 -20
- package/skills/analyze-sibling-paper/SKILL.md.spec.ts +9 -19
- package/skills/argument-arc/SKILL.md +32 -18
- package/skills/argument-arc/SKILL.md.spec.ts +43 -17
- package/skills/argument-arc/scripts/headings-core.js +46 -0
- package/skills/argument-arc/scripts/headings-core.ts +65 -0
- package/skills/argument-arc/scripts/headings.js +15 -0
- package/skills/argument-arc/scripts/headings.test.ts +105 -0
- package/skills/argument-arc/scripts/headings.ts +20 -0
- package/skills/build-benchmark/SKILL.md +1 -12
- package/skills/build-benchmark/SKILL.md.spec.ts +15 -11
- package/skills/build-label-page/SKILL.md.spec.ts +11 -0
- package/skills/camera-ready/SKILL.md +1 -8
- package/skills/camera-ready/SKILL.md.spec.ts +8 -7
- package/skills/cold-read-diff/SKILL.md +36 -25
- package/skills/cold-read-diff/SKILL.md.spec.ts +44 -24
- package/skills/cold-read-diff/scripts/cold-read-core.js +63 -6
- package/skills/cold-read-diff/scripts/cold-read-core.ts +81 -6
- package/skills/cold-read-diff/scripts/cold-read.js +1 -1
- package/skills/cold-read-diff/scripts/cold-read.test.ts +66 -0
- package/skills/cold-read-diff/scripts/cold-read.ts +1 -1
- package/skills/cold-read-diff/scripts/readers.js +2 -1
- package/skills/cold-read-diff/scripts/readers.ts +2 -1
- package/skills/draft-paper/SKILL.md +16 -29
- package/skills/draft-paper/SKILL.md.spec.ts +27 -28
- package/skills/extend-paper/SKILL.md +7 -16
- package/skills/extend-paper/SKILL.md.spec.ts +18 -15
- package/skills/find-venue/SKILL.md +11 -24
- package/skills/find-venue/SKILL.md.spec.ts +19 -23
- package/skills/harden-paper/SKILL.md +62 -290
- package/skills/harden-paper/SKILL.md.spec.ts +82 -304
- package/skills/harden-paper/harden-paper.harness.mjs +1 -2
- package/skills/jobs.ts +25 -0
- package/skills/label-agent-runs/SKILL.md.spec.ts +10 -0
- package/skills/map-prior-work/SKILL.md +5 -4
- package/skills/map-prior-work/SKILL.md.spec.ts +13 -3
- package/skills/paper-pipeline/SKILL.md +80 -278
- package/skills/paper-pipeline/SKILL.md.spec.ts +130 -276
- package/skills/paper-pipeline/description-language.eval.mjs +0 -22
- package/skills/paper-pipeline/framing-vs-vocabulary.eval.mjs +0 -29
- package/skills/paper-pipeline/paper-pipeline.harness.mjs +0 -16
- package/skills/paper-pipeline/pipeline-firing.eval.mjs +7 -29
- package/skills/paper-pipeline/pipeline-language.eval.mjs +0 -52
- package/skills/paper-pipeline/references/artifact-checklist.md +6 -1
- package/skills/paper-pipeline/references/body-vs-appendix.md +3 -4
- package/skills/paper-pipeline/references/pipeline-status-template.md +8 -10
- package/skills/paper-pipeline/references/review-ratchet.md +4 -7
- package/skills/paper-pipeline/references/venue-bar.md +1 -2
- package/skills/paper-pipeline/references/writing-craft.md +21 -281
- package/skills/paper-status/SKILL.md +17 -20
- package/skills/paper-status/SKILL.md.spec.ts +23 -19
- package/skills/pc-panel-review/SKILL.md +66 -93
- package/skills/pc-panel-review/SKILL.md.spec.ts +75 -92
- package/skills/plan-paper-timeline/SKILL.md +7 -29
- package/skills/plan-paper-timeline/SKILL.md.spec.ts +16 -28
- package/skills/plan-paper-timeline/plan-paper-timeline.effects.harness.mjs +2 -2
- package/skills/render-paper/check-render.sh +2 -2
- package/skills/render-paper/render-paper.harness.mjs +4 -20
- package/skills/research-ideate/SKILL.md +15 -32
- package/skills/research-ideate/SKILL.md.spec.ts +25 -31
- package/skills/rewrite-unclear/SKILL.md +15 -14
- package/skills/rewrite-unclear/SKILL.md.spec.ts +24 -15
- package/skills/rewrite-unclear/rewrite-unclear.eval.ts +2 -3
- package/skills/run-agent-grid/SKILL.md +3 -3
- package/skills/run-agent-grid/SKILL.md.spec.ts +10 -2
- package/skills/study-accepted-papers/SKILL.md +5 -5
- package/skills/study-accepted-papers/SKILL.md.spec.ts +27 -4
- package/skills/submit-paper/SKILL.md +37 -31
- package/skills/submit-paper/SKILL.md.spec.ts +46 -30
- package/skills/submit-paper/check-deanon.sh +1 -1
- package/skills/tighten-paper/SKILL.md +43 -68
- package/skills/tighten-paper/SKILL.md.spec.ts +51 -67
- package/skills/verify-citations/SKILL.md +18 -112
- package/skills/verify-citations/SKILL.md.spec.ts +27 -114
- package/src/adapters/latex/abstract.test.ts +42 -0
- package/src/adapters/latex/abstract.ts +23 -6
- package/src/adapters/latex/captions.test.ts +36 -38
- package/src/adapters/latex/captions.ts +16 -33
- package/src/adapters/latex/index.test.ts +11 -0
- package/src/adapters/latex/index.ts +5 -2
- package/src/adapters/latex/prose.ts +23 -11
- package/src/cli.ts +26 -5
- package/src/domain/register.test.ts +65 -0
- package/src/domain/register.ts +72 -16
- package/src/domain/term-definitions.test.ts +240 -0
- package/src/domain/term-definitions.ts +329 -0
- package/src/domain/tex-document.ts +12 -0
- package/src/domain/venue-name.test.ts +4 -4
- package/src/folder-venue-rule.test.ts +23 -2
- package/src/folder-venue-rule.ts +8 -8
- package/src/hooks-notice.test.ts +127 -0
- package/src/hooks-notice.ts +50 -10
- package/src/link-skills.ts +9 -0
- package/src/new-paper.test.ts +2 -2
- package/src/paper-settings-commands.test.ts +1 -1
- package/src/ports/latex.ts +11 -0
- package/src/preset-card-rule.test.ts +4 -0
- package/src/presets.test.ts +141 -4
- package/src/presets.ts +113 -22
- package/src/readability.test.ts +92 -0
- package/src/readability.ts +113 -5
- package/src/register-bands.test.ts +81 -1
- package/src/register-bands.ts +88 -23
- package/src/rule-cases.test.ts +122 -2
- package/src/term-definition-rules.test.ts +150 -0
- package/src/term-definition-rules.ts +189 -0
- package/src/tex-paper.test.ts +18 -1
- package/src/tex-paper.ts +11 -0
- package/src/tex-requirements.ts +15 -0
- package/src/tex-venue-rules.test.ts +45 -1
- package/src/tex-venue-rules.ts +8 -3
- package/src/venue-rules.test.ts +2 -2
- package/templates/paper/PIPELINE-STATUS.md +19 -19
- package/dist/paper-prose.d.ts +0 -17
- package/dist/paper-prose.d.ts.map +0 -1
- package/dist/paper-prose.js +0 -46
- package/dist/paper-prose.js.map +0 -1
- package/skills/grade-paper-writing/SKILL.md +0 -494
- package/skills/grade-paper-writing/SKILL.md.spec.ts +0 -501
- package/skills/grade-paper-writing/__snapshots__/prose-lint.test.ts.snap +0 -84
- package/skills/grade-paper-writing/fixtures/control_gopen.txt +0 -1
- package/skills/grade-paper-writing/fixtures/control_human_paper.txt +0 -1
- package/skills/grade-paper-writing/fixtures/rewrite.txt +0 -1
- package/skills/grade-paper-writing/fixtures/specimen.txt +0 -1
- package/skills/grade-paper-writing/fixtures/structure-checks.md +0 -22
- package/skills/grade-paper-writing/grade-paper-writing.eval.mjs +0 -19
- package/skills/grade-paper-writing/grade-paper-writing.harness.mjs +0 -23
- package/skills/grade-paper-writing/prose-lint.mjs +0 -602
- package/skills/grade-paper-writing/prose-lint.test.ts +0 -413
- package/skills/osf-artifact-upload/SKILL.md +0 -58
- package/skills/osf-artifact-upload/SKILL.md.spec.ts +0 -65
- package/skills/osf-artifact-upload/osf-artifact-upload.eval.mjs +0 -22
- package/skills/osf-artifact-upload/osf-artifact-upload.harness.ts +0 -102
- package/skills/paper-adversarial-review/SKILL.md +0 -100
- package/skills/paper-adversarial-review/SKILL.md.spec.ts +0 -107
- package/skills/paper-adversarial-review/paper-adversarial-review.eval.mjs +0 -19
- package/skills/paper-adversarial-review/paper-adversarial-review.harness.mjs +0 -24
- package/skills/paper-pipeline/grade-paper-writing-ablation.eval.mjs +0 -1274
- package/skills/paper-pipeline/references/credit-criteria.md +0 -69
- package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/README.md +0 -35
- package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/run_retext.mjs +0 -24
- package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/sentences.txt +0 -11
- package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/test_sentences.py +0 -25
- package/skills/paper-pipeline/references/occupancy-2026-08-06-prose-checkers.md +0 -538
- package/skills/paper-pipeline/references/occupancy-2026-08-06-reproducible-tooling.md +0 -431
- package/skills/paper-pipeline/references/occupancy-2026-08-06-staleness-and-orchestration.md +0 -592
- package/skills/paper-pipeline/repro/2026-08-08-parent-replication.mjs +0 -92
- package/skills/render-paper/SKILL.md +0 -123
- package/skills/render-paper/SKILL.md.spec.ts +0 -130
- package/skills/render-paper/render-paper.eval.mjs +0 -19
- package/skills/submission-portal/SKILL.md +0 -129
- package/skills/submission-portal/SKILL.md.spec.ts +0 -134
- package/skills/submission-portal/submission-portal.eval.mjs +0 -15
- package/skills/submission-portal/submission-portal.test.ts +0 -12
- package/skills/sweep-design-space/SKILL.md +0 -232
- package/skills/sweep-design-space/SKILL.md.spec.ts +0 -248
- package/skills/sweep-design-space/sweep-design-space.eval.mjs +0 -19
- package/skills/sweep-design-space/sweep-design-space.harness.mjs +0 -23
- package/src/paper-prose.test.ts +0 -78
- package/src/paper-prose.ts +0 -67
package/src/presets.ts
CHANGED
|
@@ -28,6 +28,14 @@
|
|
|
28
28
|
* template the child wins, with its `template_forbids`; so does `name`, and `required_sections`, `register`, `talk`,
|
|
29
29
|
* `portal`, `deadlines` and `submission_fields` (each whole)
|
|
30
30
|
* aliases union, with every `name` — what the venue is called along the chain
|
|
31
|
+
* parent the child wins: the conference a workshop is held at, a spec resolved from the
|
|
32
|
+
* file that names it
|
|
33
|
+
*
|
|
34
|
+
* ── THE PARENT CONFERENCE ─────────────────────────────────────────────────────────
|
|
35
|
+
* A workshop names the venue it is held at (`"parent": "paperlint:ccs"` in aisec.jsonc). The parent
|
|
36
|
+
* is resolved like any spec and must be a venue; its names, and its own parent's, are
|
|
37
|
+
* `parentNames`: names a paper of this venue may use as its own. A parent that does not resolve to
|
|
38
|
+
* a venue, or parents that name each other, are refused naming the file that says it.
|
|
31
39
|
*
|
|
32
40
|
* ── THE ID AND THE LABEL ──────────────────────────────────────────────────────────
|
|
33
41
|
* The facts file and the build plan carry the preset's `id`: the spec's file name without its
|
|
@@ -106,6 +114,11 @@ export interface Preset {
|
|
|
106
114
|
readonly template: PresetTemplate | null;
|
|
107
115
|
/** Every `name` and `aliases` along the chain: what this venue is called in a paper's text. */
|
|
108
116
|
readonly aliases: readonly string[];
|
|
117
|
+
/**
|
|
118
|
+
* Every name of the conference this venue is held at (`parent`), and of that one's parent: names a
|
|
119
|
+
* paper of this venue may use as its own. Empty when no file of the chain names a parent.
|
|
120
|
+
*/
|
|
121
|
+
readonly parentNames: readonly string[];
|
|
109
122
|
/** Whether the venue reviews double-blind (`anonymity/identity`); false when no file of the chain says. */
|
|
110
123
|
readonly blind: boolean;
|
|
111
124
|
/**
|
|
@@ -153,7 +166,11 @@ export type PresetProblem =
|
|
|
153
166
|
/** A family extending a venue, or anything extending the base set. */
|
|
154
167
|
readonly parentType: "venue" | "base";
|
|
155
168
|
}
|
|
156
|
-
| { readonly kind: "broken"; readonly file: string; readonly why: string }
|
|
169
|
+
| { readonly kind: "broken"; readonly file: string; readonly why: string }
|
|
170
|
+
/** `file` names a parent conference that does not resolve to a venue preset: `why`. */
|
|
171
|
+
| { readonly kind: "bad-parent"; readonly file: string; readonly why: string }
|
|
172
|
+
/** Venues that name each other as `parent`, in the order they were followed. */
|
|
173
|
+
| { readonly kind: "parent-cycle"; readonly chain: readonly string[] };
|
|
157
174
|
|
|
158
175
|
/** The display label of a spec: the file name without its extension. Pure. */
|
|
159
176
|
export function labelOf(spec: string): string {
|
|
@@ -284,12 +301,23 @@ const namesOf = (i: PresetIdentity): readonly string[] =>
|
|
|
284
301
|
i.type === "venue" ? [i.name] : [];
|
|
285
302
|
|
|
286
303
|
/** What the merge carries from file to file: the preset without what only the whole chain knows. */
|
|
287
|
-
type Merging = Omit<
|
|
304
|
+
type Merging = Omit<
|
|
305
|
+
Preset,
|
|
306
|
+
"id" | "label" | "chain" | "identity" | "parentNames"
|
|
307
|
+
> & {
|
|
288
308
|
readonly name: string | null;
|
|
309
|
+
readonly parent: ParentLink | null;
|
|
289
310
|
};
|
|
290
311
|
|
|
312
|
+
/** A `parent` as a file of the chain names it: the spec, and the file it is resolved from. */
|
|
313
|
+
interface ParentLink {
|
|
314
|
+
readonly spec: string;
|
|
315
|
+
readonly file: string;
|
|
316
|
+
}
|
|
317
|
+
|
|
291
318
|
const NOTHING_MERGED: Merging = {
|
|
292
319
|
name: null,
|
|
320
|
+
parent: null,
|
|
293
321
|
template: null,
|
|
294
322
|
aliases: [],
|
|
295
323
|
blind: false,
|
|
@@ -333,6 +361,7 @@ const mergeOne = (
|
|
|
333
361
|
{ preset: p, file }: { readonly preset: PresetFile; readonly file: string },
|
|
334
362
|
): Merging => ({
|
|
335
363
|
name: nameOf(p.identity) ?? acc.name,
|
|
364
|
+
parent: p.parent === null ? acc.parent : { spec: p.parent, file },
|
|
336
365
|
template:
|
|
337
366
|
p.template === null
|
|
338
367
|
? acc.template
|
|
@@ -350,12 +379,12 @@ const mergeOne = (
|
|
|
350
379
|
...wholeBlocks(acc, p),
|
|
351
380
|
});
|
|
352
381
|
|
|
353
|
-
/** The chain, root first, merged into one preset. Pure. */
|
|
382
|
+
/** The chain, root first, merged into one preset, and the parent it names. Pure. */
|
|
354
383
|
function merged(
|
|
355
384
|
spec: string,
|
|
356
385
|
rootFirst: readonly { readonly preset: PresetFile; readonly file: string }[],
|
|
357
386
|
leaf: { readonly preset: PresetFile },
|
|
358
|
-
): Preset {
|
|
387
|
+
): Omit<Preset, "parentNames"> & { readonly parent: ParentLink | null } {
|
|
359
388
|
const { name, ...rest } = rootFirst.reduce(mergeOne, NOTHING_MERGED);
|
|
360
389
|
return {
|
|
361
390
|
id: labelOf(spec),
|
|
@@ -366,6 +395,62 @@ function merged(
|
|
|
366
395
|
};
|
|
367
396
|
}
|
|
368
397
|
|
|
398
|
+
/** A problem as a caller reads it: a missing file lists the shipped presets. */
|
|
399
|
+
const refusal = (p: PresetProblem, venuesDir: string): PresetProblem =>
|
|
400
|
+
p.kind === "not-found" ? { ...p, shipped: shippedPresets(venuesDir) } : p;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The names `parent` brings, resolved from the file that names it: the parent venue's names and its
|
|
404
|
+
* own `parentNames`. `below` is every venue whose parent led here, so a cycle is refused. A problem
|
|
405
|
+
* of a parent further up is passed on as it is: it names the file that says the bad parent.
|
|
406
|
+
*/
|
|
407
|
+
function parentNamesOf(
|
|
408
|
+
parent: ParentLink,
|
|
409
|
+
below: readonly string[],
|
|
410
|
+
deps: PresetDeps,
|
|
411
|
+
): Result<readonly string[], PresetProblem> {
|
|
412
|
+
const up = resolveFrom(parent.spec, parent.file, deps, below);
|
|
413
|
+
const bad = (why: string): Result<readonly string[], PresetProblem> =>
|
|
414
|
+
err({ kind: "bad-parent", file: parent.file, why });
|
|
415
|
+
const named = `"parent": "${parent.spec}"`;
|
|
416
|
+
if (!up.ok) {
|
|
417
|
+
const p = up.error;
|
|
418
|
+
if (p.kind === "bad-parent" || p.kind === "parent-cycle") return up;
|
|
419
|
+
// The parent's own file is missing or misspelt: say it of `parent`, not of an `extends`.
|
|
420
|
+
return "spec" in p && p.spec === parent.spec
|
|
421
|
+
? bad(presetProblemText(p, "parent"))
|
|
422
|
+
: bad(`${named} does not resolve: ${presetProblemText(p)}`);
|
|
423
|
+
}
|
|
424
|
+
if (up.value.identity.type !== "venue")
|
|
425
|
+
return bad(
|
|
426
|
+
`${named} is a ${up.value.identity.type}, and a workshop's parent is the venue it is held at`,
|
|
427
|
+
);
|
|
428
|
+
return ok([...new Set([...up.value.aliases, ...up.value.parentNames])]);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/** `resolvePreset`, inside the venues `below` whose `parent` led here. */
|
|
432
|
+
function resolveFrom(
|
|
433
|
+
spec: string,
|
|
434
|
+
fromFile: string,
|
|
435
|
+
deps: PresetDeps,
|
|
436
|
+
below: readonly string[],
|
|
437
|
+
): Result<Preset, PresetProblem> {
|
|
438
|
+
const leaf = readPreset(spec, fromFile, deps);
|
|
439
|
+
if (!leaf.ok) return err(refusal(leaf.error, deps.venuesDir));
|
|
440
|
+
const here = [...below, leaf.value.file];
|
|
441
|
+
if (below.includes(leaf.value.file))
|
|
442
|
+
return err({ kind: "parent-cycle", chain: here });
|
|
443
|
+
const chain = chainUp([leaf.value], leaf.value, deps);
|
|
444
|
+
if (!chain.ok) return err(refusal(chain.error, deps.venuesDir));
|
|
445
|
+
const { parent, ...preset } = merged(
|
|
446
|
+
spec,
|
|
447
|
+
[...chain.value].reverse(),
|
|
448
|
+
leaf.value,
|
|
449
|
+
);
|
|
450
|
+
const names = parent === null ? ok([]) : parentNamesOf(parent, here, deps);
|
|
451
|
+
return names.ok ? ok({ ...preset, parentNames: names.value }) : names;
|
|
452
|
+
}
|
|
453
|
+
|
|
369
454
|
/**
|
|
370
455
|
* `spec`, as written in `fromFile` (a paper's `paperlint.json`), → the merged preset, or why it
|
|
371
456
|
* does not resolve. Reads through `deps.files` only; never throws.
|
|
@@ -375,17 +460,7 @@ export function resolvePreset(
|
|
|
375
460
|
fromFile: string,
|
|
376
461
|
deps: PresetDeps,
|
|
377
462
|
): Result<Preset, PresetProblem> {
|
|
378
|
-
|
|
379
|
-
err(
|
|
380
|
-
p.kind === "not-found"
|
|
381
|
-
? { ...p, shipped: shippedPresets(deps.venuesDir) }
|
|
382
|
-
: p,
|
|
383
|
-
);
|
|
384
|
-
const leaf = readPreset(spec, fromFile, deps);
|
|
385
|
-
if (!leaf.ok) return refused(leaf.error);
|
|
386
|
-
const chain = chainUp([leaf.value], leaf.value, deps);
|
|
387
|
-
if (!chain.ok) return refused(chain.error);
|
|
388
|
-
return ok(merged(spec, [...chain.value].reverse(), leaf.value));
|
|
463
|
+
return resolveFrom(spec, fromFile, deps, []);
|
|
389
464
|
}
|
|
390
465
|
|
|
391
466
|
/** The shipped presets' names (each is spelled `paperlint:<name>`). */
|
|
@@ -433,26 +508,42 @@ export const venueOf = ({
|
|
|
433
508
|
export const shippedVenueNames = (deps: PresetDeps): readonly ShippedVenue[] =>
|
|
434
509
|
resolveShipped(deps).map(venueOf);
|
|
435
510
|
|
|
436
|
-
/**
|
|
437
|
-
|
|
511
|
+
/**
|
|
512
|
+
* One line for a problem, naming what to change. `key` is the setting that named the spec of an
|
|
513
|
+
* `unsupported` or `not-found` problem. Pure.
|
|
514
|
+
*/
|
|
515
|
+
export function presetProblemText(
|
|
516
|
+
p: PresetProblem,
|
|
517
|
+
key: "extends" | "parent" = "extends",
|
|
518
|
+
): string {
|
|
438
519
|
switch (p.kind) {
|
|
439
520
|
case "unsupported":
|
|
440
|
-
return `"
|
|
521
|
+
return `"${key}": "${p.spec}" — a preset is \`paperlint:<name>\` (shipped) or a path starting with ./ or ../ (your own); npm presets: not yet supported. Did you mean "${shippedSpec(p.spec)}"?`;
|
|
441
522
|
case "not-found":
|
|
442
|
-
return `"
|
|
523
|
+
return `"${key}": "${p.spec}" names no preset (${p.file}); shipped presets (${SHIPPED_PREFIX}<name>): ${p.shipped.join(", ")}`;
|
|
443
524
|
case "cycle":
|
|
444
525
|
return `the presets extend each other in a cycle: ${p.chain.join(" → ")}`;
|
|
445
526
|
case "too-deep":
|
|
446
527
|
return `the preset chain is longer than ${String(MAX_PRESET_DEPTH)}: ${p.chain.join(" → ")}`;
|
|
447
528
|
case "broken":
|
|
448
529
|
return `the preset ${p.file} does not parse: ${p.why}`;
|
|
530
|
+
case "bad-parent":
|
|
531
|
+
return `the preset ${p.file} names a parent conference that does not resolve to a venue: ${p.why}`;
|
|
532
|
+
case "parent-cycle":
|
|
533
|
+
return `the presets name each other as "parent" in a cycle: ${p.chain.join(" → ")}`;
|
|
449
534
|
case "wrong-parent":
|
|
450
|
-
return p
|
|
451
|
-
? `the preset ${p.file} extends ${p.parent}, the TeX base set — every paper gets that set already, and no preset extends it`
|
|
452
|
-
: `the preset ${p.file} is a template family and extends ${p.parent}, a venue — a family builds only on a family; a venue extends a family or another venue`;
|
|
535
|
+
return wrongParentText(p);
|
|
453
536
|
}
|
|
454
537
|
}
|
|
455
538
|
|
|
539
|
+
/** The line for a chain whose file extends a preset of a type it may not extend. Pure. */
|
|
540
|
+
const wrongParentText = (
|
|
541
|
+
p: Extract<PresetProblem, { readonly kind: "wrong-parent" }>,
|
|
542
|
+
): string =>
|
|
543
|
+
p.parentType === "base"
|
|
544
|
+
? `the preset ${p.file} extends ${p.parent}, the TeX base set — every paper gets that set already, and no preset extends it`
|
|
545
|
+
: `the preset ${p.file} is a template family and extends ${p.parent}, a venue — a family builds only on a family; a venue extends a family or another venue`;
|
|
546
|
+
|
|
456
547
|
// ── a paper's preset ────────────────────────────────────────────────────────────────────
|
|
457
548
|
|
|
458
549
|
/** What one paper declares and the preset it resolves to — one answer for every reader. */
|
package/src/readability.test.ts
CHANGED
|
@@ -8,9 +8,11 @@ import { memoryFiles } from "./adapters/memory/index.ts";
|
|
|
8
8
|
import { sourcesCodec } from "./adapters/sources-record/index.ts";
|
|
9
9
|
import {
|
|
10
10
|
DEFAULT_MAX_PARAGRAPH_WORDS,
|
|
11
|
+
judgeCaptionWords,
|
|
11
12
|
judgeParagraphNumbers,
|
|
12
13
|
judgeParagraphWords,
|
|
13
14
|
judgeSentenceWords,
|
|
15
|
+
maxCaptionWordsRule,
|
|
14
16
|
maxOf,
|
|
15
17
|
maxParagraphNumbersRule,
|
|
16
18
|
maxParagraphWordsRule,
|
|
@@ -256,3 +258,93 @@ describe("the new rules, through create()", () => {
|
|
|
256
258
|
expect(run(maxParagraphWordsRule(deps), "Short.")).toHaveLength(0);
|
|
257
259
|
});
|
|
258
260
|
});
|
|
261
|
+
|
|
262
|
+
/** `n` words as one run. */
|
|
263
|
+
const captionWords = (n: number): string =>
|
|
264
|
+
Array.from({ length: n }, () => "word").join(" ");
|
|
265
|
+
/** A sentence of `n` words: capitalised, so the splitter ends the one before it. */
|
|
266
|
+
const sentence = (n: number): string => `Word ${captionWords(n - 1)}.`;
|
|
267
|
+
/** A paper whose one figure has `caption`. */
|
|
268
|
+
const fig = (caption: string): string =>
|
|
269
|
+
doc(`Text.\n\\begin{figure}\\caption{${caption}}\\end{figure}`);
|
|
270
|
+
|
|
271
|
+
describe("tex/max-caption-words — a caption, or a caption sentence, over its ceiling", () => {
|
|
272
|
+
const found = (caption: string, max = 100, maxSentence = 40) => {
|
|
273
|
+
const src = fig(caption);
|
|
274
|
+
return judgeCaptionWords(latexReader.captions(src), max, maxSentence).map(
|
|
275
|
+
(f) => ({
|
|
276
|
+
...f,
|
|
277
|
+
at: f.at && src.slice(f.at.start, f.at.start + 9),
|
|
278
|
+
}),
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
it("🔴 a caption of 101 words fires at its \\caption; one of 100 does not", () => {
|
|
283
|
+
const four = [25, 25, 25, 26].map(sentence).join(" ");
|
|
284
|
+
expect(found(four)).toEqual([
|
|
285
|
+
{
|
|
286
|
+
messageId: "caption",
|
|
287
|
+
data: {
|
|
288
|
+
words: 101,
|
|
289
|
+
max: 100,
|
|
290
|
+
head: "Word word word word word word word word…",
|
|
291
|
+
},
|
|
292
|
+
at: "\\caption{",
|
|
293
|
+
},
|
|
294
|
+
]);
|
|
295
|
+
expect(found([25, 25, 25, 25].map(sentence).join(" "))).toEqual([]);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it("🔴 a caption sentence of 41 words fires at its start; one of 40 does not", () => {
|
|
299
|
+
expect(found(`${captionWords(41)}.`)).toEqual([
|
|
300
|
+
{
|
|
301
|
+
messageId: "captionSentence",
|
|
302
|
+
data: {
|
|
303
|
+
words: 41,
|
|
304
|
+
max: 40,
|
|
305
|
+
head: "word word word word word word word word…",
|
|
306
|
+
},
|
|
307
|
+
at: "word word",
|
|
308
|
+
},
|
|
309
|
+
]);
|
|
310
|
+
expect(found(`${captionWords(40)}.`)).toEqual([]);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it("🔴 a caption commented out or in verbatim is not measured", () => {
|
|
314
|
+
const src = doc(
|
|
315
|
+
`% \\caption{${captionWords(120)}.}\n\\begin{verbatim}\\caption{${captionWords(120)}.}\\end{verbatim}`,
|
|
316
|
+
);
|
|
317
|
+
expect(judgeCaptionWords(latexReader.captions(src), 100, 40)).toEqual([]);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
describe("tex/max-caption-words, through create()", () => {
|
|
322
|
+
it("the options move both ceilings", () => {
|
|
323
|
+
const rule = maxCaptionWordsRule({
|
|
324
|
+
files: memoryFiles({ "/p/paper.tex": "" }),
|
|
325
|
+
latex: latexReader,
|
|
326
|
+
codec: sourcesCodec,
|
|
327
|
+
});
|
|
328
|
+
const ids = (options: readonly unknown[]) => {
|
|
329
|
+
const src = fig(`${captionWords(30)}.`);
|
|
330
|
+
const out: string[] = [];
|
|
331
|
+
rule
|
|
332
|
+
.create({
|
|
333
|
+
filename: "/p/paper.tex",
|
|
334
|
+
options,
|
|
335
|
+
sourceCode: {
|
|
336
|
+
text: src,
|
|
337
|
+
getLocFromIndex: () => ({ line: 1, column: 0 }),
|
|
338
|
+
},
|
|
339
|
+
report: (d) => out.push("messageId" in d ? d.messageId : d.message),
|
|
340
|
+
})
|
|
341
|
+
.root?.();
|
|
342
|
+
return out;
|
|
343
|
+
};
|
|
344
|
+
expect(ids([])).toEqual([]);
|
|
345
|
+
expect(ids([{ max: 20, maxSentence: 25 }])).toEqual([
|
|
346
|
+
"caption",
|
|
347
|
+
"captionSentence",
|
|
348
|
+
]);
|
|
349
|
+
});
|
|
350
|
+
});
|
package/src/readability.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* name and the `max` option follow ESLint's own `max-lines`, `max-len`, `max-statements`.
|
|
9
9
|
*
|
|
10
10
|
* ── WHERE 150 COMES FROM ─────────────────────────────────────────────────────────
|
|
11
|
-
* The wall
|
|
11
|
+
* The wall writing-craft.md names («The wall-of-text check»), measured
|
|
12
12
|
* with this rule's counter on the accepted papers in `fixtures/accepted-papers/`: it sits at the
|
|
13
13
|
* pooled 95th percentile of paragraph length of the five two-column IEEE ones (154). The measurement
|
|
14
14
|
* is on the rule's page. A paragraph is at most `max` words; 150 is allowed.
|
|
@@ -21,11 +21,15 @@
|
|
|
21
21
|
* registered numbers the parser counted in it (`Passage.registeredNumbers`); inline math is a mark,
|
|
22
22
|
* so nothing inside it is a number.
|
|
23
23
|
*/
|
|
24
|
-
import type { Passage } from "./domain/tex-document.ts";
|
|
24
|
+
import type { Caption, Passage } from "./domain/tex-document.ts";
|
|
25
25
|
import { runText, spanIn } from "./domain/tex-document.ts";
|
|
26
26
|
import { runOf } from "./domain/sentences.ts";
|
|
27
27
|
import { NUMBER } from "./claim-provenance.ts";
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
bodySentences,
|
|
30
|
+
wordsOf,
|
|
31
|
+
type BodySentence,
|
|
32
|
+
} from "./domain/register.ts";
|
|
29
33
|
import { fieldOf } from "./domain/record.ts";
|
|
30
34
|
import { startOf } from "./register.ts";
|
|
31
35
|
import { readPaper, reportInPaper, type ProseDeps } from "./tex-paper.ts";
|
|
@@ -44,6 +48,12 @@ export const DEFAULT_MAX_PARAGRAPH_NUMBERS = 8;
|
|
|
44
48
|
/** The sentence ceiling when the config sets none: a 56th word fires. */
|
|
45
49
|
export const DEFAULT_MAX_SENTENCE_WORDS = 55;
|
|
46
50
|
|
|
51
|
+
/** The caption ceiling when the config sets none: a 101st word fires. */
|
|
52
|
+
export const DEFAULT_MAX_CAPTION_WORDS = 100;
|
|
53
|
+
|
|
54
|
+
/** The caption-sentence ceiling when the config sets none: a 41st word fires. */
|
|
55
|
+
export const DEFAULT_MAX_CAPTION_SENTENCE_WORDS = 40;
|
|
56
|
+
|
|
47
57
|
/** How many words of a paragraph a message quotes. */
|
|
48
58
|
const HEAD_WORDS = 8;
|
|
49
59
|
|
|
@@ -79,8 +89,7 @@ export function maxOf(
|
|
|
79
89
|
options: readonly unknown[] | undefined,
|
|
80
90
|
fallback: number = DEFAULT_MAX_PARAGRAPH_WORDS,
|
|
81
91
|
): number {
|
|
82
|
-
|
|
83
|
-
return typeof v === "number" ? v : fallback;
|
|
92
|
+
return optionOf(options, "max", fallback);
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
/**
|
|
@@ -129,6 +138,105 @@ export const judgeSentenceWords = (
|
|
|
129
138
|
at: spanIn(s.run, s.from, s.from + 1),
|
|
130
139
|
}));
|
|
131
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Every caption over `max` words, at its `\caption`, and every caption sentence over `maxSentence`
|
|
143
|
+
* words, at its start. Words and sentences are the body's: a formula or a citation is one word.
|
|
144
|
+
*/
|
|
145
|
+
export const judgeCaptionWords = (
|
|
146
|
+
captions: readonly Caption[],
|
|
147
|
+
max: number,
|
|
148
|
+
maxSentence: number,
|
|
149
|
+
): readonly Located[] =>
|
|
150
|
+
captions.flatMap((c) => {
|
|
151
|
+
const ss = bodySentences(c.passages);
|
|
152
|
+
return [...captionOver(c, ss, max), ...sentencesOver(ss, maxSentence)];
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
/** The caption itself, when its words run past `max`. */
|
|
156
|
+
function captionOver(
|
|
157
|
+
c: Caption,
|
|
158
|
+
ss: readonly BodySentence[],
|
|
159
|
+
max: number,
|
|
160
|
+
): readonly Located[] {
|
|
161
|
+
const words = wordsOf(ss);
|
|
162
|
+
if (words <= max) return [];
|
|
163
|
+
const head = headOf(ss.map((s) => s.text).join(" "));
|
|
164
|
+
return [{ messageId: "caption", data: { words, max, head }, at: c.span }];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Each sentence of a caption over `max` words, at its start. */
|
|
168
|
+
const sentencesOver = (
|
|
169
|
+
ss: readonly BodySentence[],
|
|
170
|
+
max: number,
|
|
171
|
+
): readonly Located[] =>
|
|
172
|
+
ss
|
|
173
|
+
.filter((s) => s.words > max)
|
|
174
|
+
.map((s) => ({
|
|
175
|
+
messageId: "captionSentence",
|
|
176
|
+
data: { words: s.words, max, head: headOf(s.text) },
|
|
177
|
+
at: spanIn(s.run, s.from, s.from + 1),
|
|
178
|
+
}));
|
|
179
|
+
|
|
180
|
+
const CAPTION_MESSAGES = {
|
|
181
|
+
caption:
|
|
182
|
+
"a caption of {{words}} words, over {{max}} — «{{head}}». A reader reads a caption in one pass with its figure; move the method into the body and keep what the figure shows.",
|
|
183
|
+
captionSentence:
|
|
184
|
+
"a caption sentence of {{words}} words, over {{max}} — «{{head}}». Cut it where a clause could stand alone.",
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/** An integer option the config sets, or the default: ESLint has validated it against the schema. */
|
|
188
|
+
const optionOf = (
|
|
189
|
+
options: readonly unknown[] | undefined,
|
|
190
|
+
key: string,
|
|
191
|
+
fallback: number,
|
|
192
|
+
): number => {
|
|
193
|
+
const v = fieldOf(options?.[0], key);
|
|
194
|
+
return typeof v === "number" ? v : fallback;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* `tex/max-caption-words`: a caption over `max` words (default 100), a caption sentence over
|
|
199
|
+
* `maxSentence` (default 40). One rule with two options, as `max-len` has `comments`: both are a
|
|
200
|
+
* caption too long, with the same reason to switch them off. Not on in any default config.
|
|
201
|
+
*/
|
|
202
|
+
const CAPTION_META: TexRuleModule["meta"] = {
|
|
203
|
+
type: "suggestion",
|
|
204
|
+
docs: {
|
|
205
|
+
description: `a caption stays at or under \`max\` words (${String(DEFAULT_MAX_CAPTION_WORDS)}) and each of its sentences at or under \`maxSentence\` (${String(DEFAULT_MAX_CAPTION_SENTENCE_WORDS)}). Off until a project turns it on`,
|
|
206
|
+
url: ruleDocsUrl("max-caption-words"),
|
|
207
|
+
},
|
|
208
|
+
schema: [
|
|
209
|
+
{
|
|
210
|
+
type: "object",
|
|
211
|
+
properties: {
|
|
212
|
+
max: { type: "integer", minimum: 0 },
|
|
213
|
+
maxSentence: { type: "integer", minimum: 0 },
|
|
214
|
+
},
|
|
215
|
+
additionalProperties: false,
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
messages: CAPTION_MESSAGES,
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const maxCaptionWordsRule = (deps: ProseDeps): TexRuleModule => ({
|
|
222
|
+
meta: CAPTION_META,
|
|
223
|
+
create(context) {
|
|
224
|
+
return {
|
|
225
|
+
root() {
|
|
226
|
+
const sc = context.sourceCode;
|
|
227
|
+
const paper = readPaper(context.filename, sc.raw ?? sc.text, deps);
|
|
228
|
+
const o = context.options;
|
|
229
|
+
const found = judgeCaptionWords(
|
|
230
|
+
deps.latex.captions(paper.text),
|
|
231
|
+
optionOf(o, "max", DEFAULT_MAX_CAPTION_WORDS),
|
|
232
|
+
optionOf(o, "maxSentence", DEFAULT_MAX_CAPTION_SENTENCE_WORDS),
|
|
233
|
+
);
|
|
234
|
+
reportInPaper(context, CAPTION_MESSAGES, paper, found);
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
|
|
132
240
|
const MESSAGES = {
|
|
133
241
|
paragraph:
|
|
134
242
|
"a paragraph of {{words}} words, over {{max}} — «{{head}}». On the page this is a wall a reader skims past. Split it where its topic turns; move a list of cases into a list, numbers into a table, detail into the appendix",
|
|
@@ -20,7 +20,9 @@ import { nodeFiles } from "./adapters/node/index.ts";
|
|
|
20
20
|
import { sourcesCodec } from "./adapters/sources-record/index.ts";
|
|
21
21
|
import {
|
|
22
22
|
bandOf,
|
|
23
|
+
negationBandOf,
|
|
23
24
|
rateOf,
|
|
25
|
+
shareOf,
|
|
24
26
|
REGISTER_MEASURES,
|
|
25
27
|
type Band,
|
|
26
28
|
type RegisterAnchor,
|
|
@@ -207,6 +209,76 @@ describe("variants of real accepted papers, one change each, leave the band on t
|
|
|
207
209
|
);
|
|
208
210
|
});
|
|
209
211
|
|
|
212
|
+
/** Where a paper's share of negated sentences stands against AIDC's band. */
|
|
213
|
+
const negationStanding = (a: RegisterAnchor): string => {
|
|
214
|
+
const band = negationBandOf(aidc.registerAnchors);
|
|
215
|
+
return band === null || a.negation === undefined
|
|
216
|
+
? "no band"
|
|
217
|
+
: standingOf(shareOf(a.negation.negated, a.negation.sentences), band);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
describe("tex/negated-sentences: AIDC's band from the same five ACSAC papers", () => {
|
|
221
|
+
it("🔴 the band is the anchors' 5.3–17.8%, widened to 3.0–21.8%", () => {
|
|
222
|
+
const band = negationBandOf(aidc.registerAnchors);
|
|
223
|
+
expect(
|
|
224
|
+
band &&
|
|
225
|
+
[band.anchorMin, band.anchorMax, band.min, band.max].map((x) =>
|
|
226
|
+
x.toFixed(1),
|
|
227
|
+
),
|
|
228
|
+
).toEqual(["5.3", "17.8", "3.0", "21.8"]);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it.each(ACSAC)(
|
|
232
|
+
"%s stands inside it",
|
|
233
|
+
{ timeout: PAPER_TIMEOUT_MS },
|
|
234
|
+
(paper) => {
|
|
235
|
+
expect(negationStanding(anchorFor(paper))).toBe("within");
|
|
236
|
+
},
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
it(
|
|
240
|
+
"🔴 secure-acsac24 with every «is», «are», «was» and «were» negated: above",
|
|
241
|
+
{ timeout: PAPER_TIMEOUT_MS },
|
|
242
|
+
() => {
|
|
243
|
+
const src = inBody(
|
|
244
|
+
sourceOf("secure-acsac24"),
|
|
245
|
+
/\b(?:is|are|was|were)\b/gu,
|
|
246
|
+
(m) => `${m} not`,
|
|
247
|
+
Number.POSITIVE_INFINITY,
|
|
248
|
+
);
|
|
249
|
+
expect(negationStanding(anchorFor("secure-acsac24", src))).toBe("above");
|
|
250
|
+
},
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
it(
|
|
254
|
+
"🔴 rr-dataset-quality-acsac24 with its negators struck out: below",
|
|
255
|
+
{ timeout: PAPER_TIMEOUT_MS },
|
|
256
|
+
() => {
|
|
257
|
+
const src = inBody(
|
|
258
|
+
sourceOf("rr-dataset-quality-acsac24"),
|
|
259
|
+
/\b(?:not|no|none|never|without|nor|neither|unable)\b|n't\b/giu,
|
|
260
|
+
() => "",
|
|
261
|
+
Number.POSITIVE_INFINITY,
|
|
262
|
+
);
|
|
263
|
+
expect(
|
|
264
|
+
negationStanding(anchorFor("rr-dataset-quality-acsac24", src)),
|
|
265
|
+
).toBe("below");
|
|
266
|
+
},
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
it("a preset whose anchors record no negation sets no band", () => {
|
|
270
|
+
expect(
|
|
271
|
+
negationBandOf(
|
|
272
|
+
aidc.registerAnchors.map((a) => ({
|
|
273
|
+
paper: a.paper,
|
|
274
|
+
words: a.words,
|
|
275
|
+
counts: a.counts,
|
|
276
|
+
})),
|
|
277
|
+
),
|
|
278
|
+
).toBeNull();
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
210
282
|
describe("judgeBand — a body's rate against a band", () => {
|
|
211
283
|
const band: Band = {
|
|
212
284
|
min: 20,
|
|
@@ -222,7 +294,9 @@ describe("judgeBand — a body's rate against a band", () => {
|
|
|
222
294
|
});
|
|
223
295
|
const body = (n: number, words = MIN_WORDS) => ({
|
|
224
296
|
words,
|
|
297
|
+
sentences: 100,
|
|
225
298
|
occurrences: Array.from({ length: n }, (_, i) => occurrence(i)),
|
|
299
|
+
rate: rateOf(n, words),
|
|
226
300
|
at: { start: 0, end: 1 },
|
|
227
301
|
});
|
|
228
302
|
const ids = (n: number, each = true, words = MIN_WORDS) =>
|
|
@@ -326,6 +400,12 @@ describe("the rules, as ESLint calls them", () => {
|
|
|
326
400
|
"\\documentclass{article}\n\\begin{document}\n\\end{document}\n",
|
|
327
401
|
latexReader,
|
|
328
402
|
);
|
|
329
|
-
expect(m).toEqual({
|
|
403
|
+
expect(m).toEqual({
|
|
404
|
+
words: 0,
|
|
405
|
+
sentences: 0,
|
|
406
|
+
occurrences: [],
|
|
407
|
+
rate: 0,
|
|
408
|
+
at: null,
|
|
409
|
+
});
|
|
330
410
|
});
|
|
331
411
|
});
|