paperlint 18.2.1 β 18.3.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/.github/dependabot.yml +17 -0
- package/.github/workflows/ci.yml +30 -5
- package/CLAUDE.md +2 -1
- package/dist/domain/register.d.ts +1 -1
- package/dist/domain/register.d.ts.map +1 -1
- package/dist/domain/sentences.d.ts +3 -11
- package/dist/domain/sentences.d.ts.map +1 -1
- package/dist/domain/sentences.js +53 -8
- package/dist/domain/sentences.js.map +1 -1
- package/dist/eslint-rules/CLAUDE.md.spec.js +2 -2
- package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
- package/dist/folder-venue-rule.js +1 -1
- package/dist/readability.d.ts +12 -9
- package/dist/readability.d.ts.map +1 -1
- package/dist/readability.js +3 -3
- package/dist/readability.js.map +1 -1
- package/docs/design/paper-sources.md +1 -1
- package/docs/e2e.md +2 -2
- package/docs/optional-rules.md +2 -2
- package/docs/rules/pdf/body-size.md +1 -1
- package/docs/rules/tex/heading-case.md +2 -2
- package/docs/rules/tex/max-paragraph-numbers.md +13 -7
- package/docs/rules/tex/max-paragraph-words.md +17 -28
- package/docs/rules/tex/max-sentence-words.md +3 -2
- package/docs/rules/tex/negated-sentences.md +2 -2
- package/docs/rules/tex/register.md +1 -1
- package/docs/rules/tex/term-before-definition.md +1 -1
- package/docs/rules.md +3 -3
- package/docs/venues.md +1 -1
- package/docs/website.md +61 -5
- package/eslint-rules/CLAUDE.md +3 -3
- package/eslint-rules/CLAUDE.md.spec.ts +2 -2
- package/eslint.config.mjs +15 -4
- package/fixtures/real-papers.test.ts +24 -19
- package/package.json +4 -5
- package/presets/acm-sigconf.jsonc +1 -1
- package/presets/aidc-2026.jsonc +4 -4
- package/presets/aidc-2026.md +1 -1
- package/presets/ase-2026.md +1 -1
- package/presets/ieee-conference.jsonc +1 -1
- package/presets/msr-2027.jsonc +1 -1
- package/presets/neurips-style.jsonc +2 -2
- package/presets/neurips-style.md +1 -1
- package/presets/sp-2027.md +1 -1
- package/presets/venue-profile.schema.json +1 -1
- package/scripts/check.ts +9 -1
- package/scripts/coverage-config.test.ts +2 -0
- package/scripts/grow-real-papers/archive.test.ts +294 -0
- package/scripts/grow-real-papers/archive.ts +287 -0
- package/scripts/grow-real-papers/collect.test.ts +329 -0
- package/scripts/grow-real-papers/collect.ts +316 -0
- package/scripts/grow-real-papers/http.test.ts +95 -0
- package/scripts/grow-real-papers/http.ts +76 -0
- package/scripts/grow-real-papers/main.test.ts +295 -0
- package/scripts/grow-real-papers/main.ts +221 -0
- package/scripts/grow-real-papers/paper.test.ts +305 -0
- package/scripts/grow-real-papers/paper.ts +241 -0
- package/scripts/grow-real-papers/rules.test.ts +222 -0
- package/scripts/grow-real-papers/rules.ts +250 -0
- package/scripts/grow-real-papers/sources.test.ts +275 -0
- package/scripts/grow-real-papers/sources.ts +239 -0
- package/scripts/grow-real-papers/testkit.ts +79 -0
- package/src/domain/register.ts +1 -1
- package/src/domain/sentences.test.ts +128 -0
- package/src/domain/sentences.ts +60 -11
- package/src/folder-venue-rule.test.ts +1 -1
- package/src/folder-venue-rule.ts +1 -1
- package/src/readability.test.ts +82 -41
- package/src/readability.ts +12 -9
- package/src/register-bands.test.ts +4 -4
- package/src/rule-cases.test.ts +6 -6
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one sentence splitter, on plain text: where `Intl.Segmenter` cuts, the break it withholds
|
|
3
|
+
* before a lowercase start (#543), and the full stops that end no sentence.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { CITATION, MATH, REFERENCE, sentences } from "./sentences.ts";
|
|
7
|
+
|
|
8
|
+
/** The sentences of `text`, as text. */
|
|
9
|
+
const cut = (text: string): readonly string[] =>
|
|
10
|
+
sentences(text).map(([from, to]) => text.slice(from, to));
|
|
11
|
+
|
|
12
|
+
describe("sentences β a sentence that opens in lowercase (#543)", () => {
|
|
13
|
+
it("π΄ a typed lowercase name opens a sentence of its own", () => {
|
|
14
|
+
expect(
|
|
15
|
+
cut("First sentence has four. fp16 and bf16 are formats. Next one here."),
|
|
16
|
+
).toEqual([
|
|
17
|
+
"First sentence has four. ",
|
|
18
|
+
"fp16 and bf16 are formats. ",
|
|
19
|
+
"Next one here.",
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("π΄ a number before the full stop changes nothing: `16 GB. fp16 β¦` is two sentences", () => {
|
|
24
|
+
expect(cut("It did not fit in 16 GB. fp16 is the format.")).toEqual([
|
|
25
|
+
"It did not fit in 16 GB. ",
|
|
26
|
+
"fp16 is the format.",
|
|
27
|
+
]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("π΄ a citation or reference that opens the sentence is its subject, and stays with it", () => {
|
|
31
|
+
expect(
|
|
32
|
+
cut(
|
|
33
|
+
`Weights are quantised. ${CITATION} applied it. ${REFERENCE} lists all.`,
|
|
34
|
+
),
|
|
35
|
+
).toEqual([
|
|
36
|
+
"Weights are quantised. ",
|
|
37
|
+
`${CITATION} applied it. `,
|
|
38
|
+
`${REFERENCE} lists all.`,
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("π΄ what a macro left out leaves a lowercase start, and the break is still there", () => {
|
|
43
|
+
expect(cut("We test that evidence. makes it explicit.")).toEqual([
|
|
44
|
+
"We test that evidence. ",
|
|
45
|
+
"makes it explicit.",
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("π΄ a sentence that opens with a digit and then lowercase words is its own: `69% of β¦`", () => {
|
|
50
|
+
expect(cut("It is creation-control. 69% of the files differ.")).toEqual([
|
|
51
|
+
"It is creation-control. ",
|
|
52
|
+
"69% of the files differ.",
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("π΄ math that opens a sentence goes with it", () => {
|
|
57
|
+
expect(cut(`The bound is tight. ${MATH} is small here.`)).toEqual([
|
|
58
|
+
"The bound is tight. ",
|
|
59
|
+
`${MATH} is small here.`,
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe("sentences β a full stop before a lowercase word that ends nothing", () => {
|
|
65
|
+
it.each([
|
|
66
|
+
["a listed abbreviation", "We use tools, e.g. linters and fuzzers."],
|
|
67
|
+
["a dotted abbreviation", "We draw i.i.d. samples from it."],
|
|
68
|
+
["a dotted abbreviation", "This is, a.k.a. the drift, a problem."],
|
|
69
|
+
["a dotted abbreviation", "It is minimal w.r.t. the order."],
|
|
70
|
+
["a dotted abbreviation in capitals", "Masters or Ph.D. students joined."],
|
|
71
|
+
["an initial", "Bai, Y. et al. report it."],
|
|
72
|
+
["an initial after a hyphenated one", "Hsieh, C.-P. et al. report it."],
|
|
73
|
+
["`etc.`", "Linters, fuzzers, etc. are tools."],
|
|
74
|
+
["a numbered thing's short name", "As in Eqn. 3 we see it."],
|
|
75
|
+
["a numbered thing's short name, lowercase", "The loss (eq. 2) is small."],
|
|
76
|
+
["a company's", "Chase & Co. and its affiliates."],
|
|
77
|
+
["a common truncation", "It took longer (avg. 3 steps more)."],
|
|
78
|
+
["a common truncation", "A small MLP (embedding dim. 64) is used."],
|
|
79
|
+
["a lowercase reference", "For flows see refs. 4 and 5 there."],
|
|
80
|
+
["an ellipsis", "We tried one, two... and then stopped."],
|
|
81
|
+
["a full stop inside brackets", "Displacement (Disp.) is the shift."],
|
|
82
|
+
["a decimal", "The rate is 2.5 per run."],
|
|
83
|
+
[
|
|
84
|
+
"inline enumerators",
|
|
85
|
+
"We consider two cases: 1. the rate is 40%, and 2. the rate is 60%.",
|
|
86
|
+
],
|
|
87
|
+
["an enumerator in brackets", "Two steps (1. parse, 2. check) run."],
|
|
88
|
+
])("%s: %s", (_, text) => {
|
|
89
|
+
expect(cut(text)).toEqual([text]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("a number that ends a sentence still ends it before a lowercase word", () => {
|
|
93
|
+
expect(cut("The total was 40. fp16 then halves it.")).toEqual([
|
|
94
|
+
"The total was 40. ",
|
|
95
|
+
"fp16 then halves it.",
|
|
96
|
+
]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("before a capital, `etc.` and an initial end a sentence as before", () => {
|
|
100
|
+
expect(cut("Linters, fuzzers, etc. The rest is manual.")).toEqual([
|
|
101
|
+
"Linters, fuzzers, etc. ",
|
|
102
|
+
"The rest is manual.",
|
|
103
|
+
]);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe("sentences β what the segmenter already did, unchanged", () => {
|
|
108
|
+
it("a break after a listed abbreviation is undone", () => {
|
|
109
|
+
expect(cut("As in Fig. 3, it holds. See Sec. Two for more.")).toEqual([
|
|
110
|
+
"As in Fig. 3, it holds. ",
|
|
111
|
+
"See Sec. Two for more.",
|
|
112
|
+
]);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("a citation set right after the full stop belongs to the sentence it ends", () => {
|
|
116
|
+
expect(cut(`It grew 900%. ${CITATION} Then it fell.`)).toEqual([
|
|
117
|
+
`It grew 900%. ${CITATION}`,
|
|
118
|
+
" Then it fell.",
|
|
119
|
+
]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("a question or an exclamation ends a sentence before a lowercase word, as the segmenter has it", () => {
|
|
123
|
+
expect(cut("Does it hold? yes, always.")).toEqual([
|
|
124
|
+
"Does it hold? ",
|
|
125
|
+
"yes, always.",
|
|
126
|
+
]);
|
|
127
|
+
});
|
|
128
|
+
});
|
package/src/domain/sentences.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* them the same way (`tex/claim-provenance` judges each; `tex/register` counts them).
|
|
4
4
|
*
|
|
5
5
|
* A passage becomes one text: its prose as itself, and each mark (a citation, a cross-reference) or
|
|
6
|
-
* math as one character no prose contains, where it stands. `Intl.Segmenter` cuts that text
|
|
7
|
-
*
|
|
8
|
-
* full stop
|
|
6
|
+
* math as one character no prose contains, where it stands. `Intl.Segmenter` cuts that text, and the
|
|
7
|
+
* break it withholds before a sentence that opens in lowercase is put back; a break after an
|
|
8
|
+
* abbreviation is undone, and marks set right after a full stop belong to the sentence the full stop
|
|
9
|
+
* ends β unless a lowercase word follows them, which makes them the next sentence's subject.
|
|
9
10
|
*/
|
|
11
|
+
import { sortBy, unique } from "remeda";
|
|
10
12
|
import type { Passage, ProsePiece, Segment, TextRun } from "./tex-document.ts";
|
|
11
13
|
|
|
12
14
|
/** What stands in a sentence's text for a mark: characters no prose contains (private use). */
|
|
@@ -41,25 +43,72 @@ const ABBREVIATION =
|
|
|
41
43
|
|
|
42
44
|
const SEGMENTER = new Intl.Segmenter("en", { granularity: "sentence" });
|
|
43
45
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
+
/**
|
|
47
|
+
* A full stop, the closing quotes after it and the spaces after those, when the next letter is
|
|
48
|
+
* lowercase. Rule SB8 of UAX #29 withholds the break there, so `Intl.Segmenter` runs `16 GB. fp16
|
|
49
|
+
* is β¦` into one sentence (#543); so it does when a mark, or a macro the reader leaves out, opens the
|
|
50
|
+
* next sentence (`\citet{x} shows`). Between the spaces and that letter stands only what SB8 skips:
|
|
51
|
+
* marks, math, digits, punctuation that ends no sentence. A bracket right after the full stop keeps
|
|
52
|
+
* it inside the sentence (`(Disp.) is`).
|
|
53
|
+
*/
|
|
54
|
+
const LOWERCASE_OPENING = /\.['"ββ]*\s+(?=[^\p{L}.!?]*\p{Ll})/gu;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A full stop that ends no sentence before a lowercase word: a dotted abbreviation (`i.i.d.`,
|
|
58
|
+
* `w.r.t.`, `Ph.D.`), an initial (`Y.`, the `P.` of `C.-P.`), an ellipsis, the short name of a
|
|
59
|
+
* numbered thing (`Art. 5(c)`, `Eqn. 3`, `eq. 2`, `see refs. 4`), a company's (`Co.`, `Inc.`) or a
|
|
60
|
+
* common truncation (`etc.`, `avg.`, `dim.`), or an inline enumerator (`cases: 1. the`, `and 2. the`,
|
|
61
|
+
* `(1. parse`). Before a capital each of these may end a sentence, so the
|
|
62
|
+
* segmenter's own breaks after them stay. Matched against the text up to and including the full
|
|
63
|
+
* stop, at most `WINDOW` characters of it.
|
|
64
|
+
*/
|
|
65
|
+
const ABBREVIATION_BEFORE_LOWERCASE =
|
|
66
|
+
/(?:\p{L}\.\p{L}{1,3}|(?:^|[^\p{L}])(?:\p{Lu}|Appx|Art|Def|Thm|Lem|Prop|Alg|Ch|Vol|pp|Refs?|Eqns?|eqn|eqs?|refs?|Co|Inc|Ltd|Corp|etc|avg|func|dim)|(?:^|[:;,(]\s*|\b(?:and|or)\s+)\d{1,2}|\.\.)\.$/u;
|
|
67
|
+
|
|
68
|
+
/** Enough text before a full stop to hold the longest abbreviation above and the character before it. */
|
|
69
|
+
const WINDOW = 8;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Marks, and the spaces among them, that open a segment: a `\cite` or a footnote set after the full
|
|
73
|
+
* stop β not when a lowercase word follows them, which makes them the subject of the sentence they open.
|
|
74
|
+
*/
|
|
75
|
+
const LEADING_MARKS = new RegExp(
|
|
76
|
+
`^[\\s${CITATION}${REFERENCE}]*[${CITATION}${REFERENCE}](?![^\\p{L}.!?]*\\p{Ll})`,
|
|
77
|
+
"u",
|
|
78
|
+
);
|
|
46
79
|
|
|
47
80
|
/** `[from, to)` of a text. */
|
|
48
81
|
export type Range = readonly [number, number];
|
|
49
82
|
|
|
83
|
+
/** Where `Intl.Segmenter` starts a sentence, and where it withheld a start before a lowercase word. */
|
|
84
|
+
const startsOf = (text: string): readonly number[] => {
|
|
85
|
+
const segmented = [...SEGMENTER.segment(text)].map((s) => s.index);
|
|
86
|
+
const withheld = [...text.matchAll(LOWERCASE_OPENING)].flatMap((m) =>
|
|
87
|
+
ABBREVIATION_BEFORE_LOWERCASE.test(
|
|
88
|
+
text.slice(Math.max(0, m.index + 1 - WINDOW), m.index + 1),
|
|
89
|
+
)
|
|
90
|
+
? []
|
|
91
|
+
: [m.index + m[0].length],
|
|
92
|
+
);
|
|
93
|
+
return sortBy(unique([...segmented, ...withheld]), (at) => at);
|
|
94
|
+
};
|
|
95
|
+
|
|
50
96
|
/**
|
|
51
|
-
* The sentences of `text`, as `[from, to)` ranges. A break
|
|
52
|
-
*
|
|
97
|
+
* The sentences of `text`, as `[from, to)` ranges. A break the segmenter withheld before a lowercase
|
|
98
|
+
* word is put back, a break after an abbreviation is undone, and marks standing right after a full
|
|
99
|
+
* stop belong to the sentence the full stop ends.
|
|
53
100
|
*/
|
|
54
101
|
export function sentences(text: string): readonly Range[] {
|
|
55
|
-
|
|
102
|
+
const starts = startsOf(text);
|
|
103
|
+
return starts.reduce<readonly Range[]>((acc, start, i) => {
|
|
104
|
+
const end = starts[i + 1] ?? text.length;
|
|
56
105
|
const prev = acc.at(-1);
|
|
57
|
-
|
|
58
|
-
if (prev === undefined) return [[s.index, end]];
|
|
106
|
+
if (prev === undefined) return [[start, end]];
|
|
59
107
|
const before = acc.slice(0, -1);
|
|
60
108
|
if (ABBREVIATION.test(text.slice(...prev)))
|
|
61
109
|
return [...before, [prev[0], end]];
|
|
62
|
-
const split =
|
|
110
|
+
const split =
|
|
111
|
+
start + (LEADING_MARKS.exec(text.slice(start, end))?.[0].length ?? 0);
|
|
63
112
|
return split < end
|
|
64
113
|
? [...before, [prev[0], split], [split, end]]
|
|
65
114
|
: [...before, [prev[0], end]];
|
|
@@ -269,7 +269,7 @@ describe("paper/folder-venue-leftover β silent", () => {
|
|
|
269
269
|
});
|
|
270
270
|
|
|
271
271
|
it("a paper on a bare template family declares no venue: a venue in its folder may be its own", () => {
|
|
272
|
-
// The accepted ACSAC papers in fixtures/
|
|
272
|
+
// The accepted ACSAC papers in fixtures/real-papers/accepted/ are exactly this: `β¦-acsac24` folders
|
|
273
273
|
// extending ieee-conference, while ACSAC is a shipped venue, the parent conference of AIDC.
|
|
274
274
|
expect(
|
|
275
275
|
lint("secure-acsac24", { extends: "paperlint:ieee-conference" }),
|
package/src/folder-venue-rule.ts
CHANGED
|
@@ -95,7 +95,7 @@ export function judgeFolder(
|
|
|
95
95
|
* A template family (`acm-sigconf`, `ieee-conference`), as the preset declares itself (`"type":
|
|
96
96
|
* "family"`), which a paper for a venue paperlint has no preset for extends directly. Such a paper
|
|
97
97
|
* declares a format, not a venue, so a venue in its folder name may be its own: the accepted ACSAC
|
|
98
|
-
* papers in `fixtures/
|
|
98
|
+
* papers in `fixtures/real-papers/accepted/` extend `ieee-conference` from folders named `β¦-acsac24`, and
|
|
99
99
|
* ACSAC is a shipped venue, the parent conference of `aidc-2026`.
|
|
100
100
|
*/
|
|
101
101
|
const isFamily = (preset: Preset): boolean => preset.identity.type === "family";
|
package/src/readability.test.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { latexReader } from "./adapters/latex/index.ts";
|
|
|
7
7
|
import { memoryFiles } from "./adapters/memory/index.ts";
|
|
8
8
|
import { sourcesCodec } from "./adapters/sources-record/index.ts";
|
|
9
9
|
import {
|
|
10
|
+
DEFAULT_MAX_PARAGRAPH_NUMBERS,
|
|
10
11
|
DEFAULT_MAX_PARAGRAPH_WORDS,
|
|
11
12
|
judgeCaptionWords,
|
|
12
13
|
judgeParagraphNumbers,
|
|
@@ -44,21 +45,21 @@ const found = (body: string) =>
|
|
|
44
45
|
).map((f) => f.data);
|
|
45
46
|
|
|
46
47
|
describe("tex/max-paragraph-words β a paragraph over the ceiling, and only that", () => {
|
|
47
|
-
it("π΄
|
|
48
|
+
it("π΄ 251 words: fires, with the count, the ceiling and the paragraph's first words", () => {
|
|
48
49
|
// Guards: the case that was a false green once β a long single sentence tripped a sentence
|
|
49
50
|
// ceiling and never the paragraph one. Here every sentence is at most ten words.
|
|
50
|
-
expect(found(paragraph(
|
|
51
|
+
expect(found(paragraph(251))).toEqual([
|
|
51
52
|
{
|
|
52
|
-
words:
|
|
53
|
-
max:
|
|
53
|
+
words: 251,
|
|
54
|
+
max: 250,
|
|
54
55
|
head: "The rule reads the body and counts whatβ¦",
|
|
55
56
|
},
|
|
56
57
|
]);
|
|
57
58
|
});
|
|
58
59
|
|
|
59
|
-
it("
|
|
60
|
-
// Guards: the ceiling is inclusive β
|
|
61
|
-
expect(found(paragraph(
|
|
60
|
+
it("250 words and a short paragraph: silent", () => {
|
|
61
|
+
// Guards: the ceiling is inclusive β 250 is allowed.
|
|
62
|
+
expect(found(paragraph(250))).toEqual([]);
|
|
62
63
|
expect(found(paragraph(30))).toEqual([]);
|
|
63
64
|
});
|
|
64
65
|
|
|
@@ -89,9 +90,9 @@ describe("maxOf β the ceiling a config sets", () => {
|
|
|
89
90
|
it("the option when it is set, the default otherwise", () => {
|
|
90
91
|
// Guards: ESLint has validated the option; anything else falls back to the default.
|
|
91
92
|
expect(maxOf([{ max: 120 }])).toBe(120);
|
|
92
|
-
expect(maxOf([])).toBe(
|
|
93
|
-
expect(maxOf(undefined)).toBe(
|
|
94
|
-
expect(maxOf(["warn"])).toBe(
|
|
93
|
+
expect(maxOf([])).toBe(250);
|
|
94
|
+
expect(maxOf(undefined)).toBe(250);
|
|
95
|
+
expect(maxOf(["warn"])).toBe(250);
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
|
|
@@ -128,13 +129,13 @@ describe("the rule, through its create()", () => {
|
|
|
128
129
|
};
|
|
129
130
|
|
|
130
131
|
it("reports at the paragraph's first line, with its message id", () => {
|
|
131
|
-
expect(reported(paragraph(
|
|
132
|
+
expect(reported(paragraph(260))).toEqual([
|
|
132
133
|
{
|
|
133
134
|
loc: { start: { line: 3, column: 0 }, end: { line: 3, column: 0 } },
|
|
134
135
|
messageId: "paragraph",
|
|
135
136
|
data: {
|
|
136
|
-
words:
|
|
137
|
-
max:
|
|
137
|
+
words: 260,
|
|
138
|
+
max: 250,
|
|
138
139
|
head: "The rule reads the body and counts whatβ¦",
|
|
139
140
|
},
|
|
140
141
|
},
|
|
@@ -143,65 +144,67 @@ describe("the rule, through its create()", () => {
|
|
|
143
144
|
|
|
144
145
|
it("a source without a raw text is read from its text", () => {
|
|
145
146
|
// Guards: ESLint's source code may carry no `raw`; the rule falls back to `text`.
|
|
146
|
-
expect(reported(paragraph(
|
|
147
|
+
expect(reported(paragraph(260), [], false)).toHaveLength(1);
|
|
147
148
|
});
|
|
148
149
|
|
|
149
|
-
it("an option moves the ceiling:
|
|
150
|
-
expect(reported(paragraph(
|
|
151
|
-
expect(reported(paragraph(
|
|
150
|
+
it("an option moves the ceiling: 240 words fire under max 120, not under the default", () => {
|
|
151
|
+
expect(reported(paragraph(240), [{ max: 120 }])).toHaveLength(1);
|
|
152
|
+
expect(reported(paragraph(240))).toHaveLength(0);
|
|
152
153
|
});
|
|
153
154
|
});
|
|
154
155
|
|
|
155
156
|
/** What the numbers judge finds in `body` at the default ceiling. */
|
|
156
157
|
const numbersFound = (body: string) => {
|
|
157
158
|
const src = doc(body);
|
|
158
|
-
return judgeParagraphNumbers(
|
|
159
|
-
(
|
|
160
|
-
|
|
159
|
+
return judgeParagraphNumbers(
|
|
160
|
+
latexReader.bodyProse(src),
|
|
161
|
+
DEFAULT_MAX_PARAGRAPH_NUMBERS,
|
|
162
|
+
).map((f) => f.data);
|
|
161
163
|
};
|
|
162
164
|
|
|
163
165
|
describe("tex/max-paragraph-numbers", () => {
|
|
164
|
-
it("π΄
|
|
165
|
-
const
|
|
166
|
-
"We ran 1 and 2.5 and 30\\% and 4,000 and \\numA{} and \\numTotal and 7 and 8.";
|
|
167
|
-
expect(numbersFound(
|
|
168
|
-
expect(numbersFound(`${
|
|
169
|
-
{ numbers:
|
|
166
|
+
it("π΄ eleven numbers fire, ten stay quiet; citations and references are not numbers, a hand-typed place is", () => {
|
|
167
|
+
const ten =
|
|
168
|
+
"We ran 1 and 2.5 and 30\\% and 4,000 and \\numA{} and \\numTotal and 7 and 8 and 9 and 10.";
|
|
169
|
+
expect(numbersFound(ten)).toEqual([]);
|
|
170
|
+
expect(numbersFound(`${ten} Then 11.`)).toEqual([
|
|
171
|
+
{ numbers: 11, max: 10, head: "We ran 1 and 2.5 and 30% andβ¦" },
|
|
170
172
|
]);
|
|
171
173
|
// Guards: a citation key and a reference are not quantities.
|
|
172
|
-
expect(
|
|
173
|
-
|
|
174
|
-
)
|
|
174
|
+
expect(numbersFound(`${ten} See \\cite{k2024} and \\ref{sec:1}.`)).toEqual(
|
|
175
|
+
[],
|
|
176
|
+
);
|
|
175
177
|
// A place typed by hand is a number like any other; written with \\ref it is not.
|
|
176
|
-
expect(numbersFound(`${
|
|
177
|
-
{ numbers:
|
|
178
|
+
expect(numbersFound(`${ten} See Section 3.2.`)).toEqual([
|
|
179
|
+
{ numbers: 11, max: 10, head: "We ran 1 and 2.5 and 30% andβ¦" },
|
|
178
180
|
]);
|
|
179
|
-
expect(numbersFound(`${
|
|
181
|
+
expect(numbersFound(`${ten} See Section \\ref{sec:x}.`)).toEqual([]);
|
|
180
182
|
});
|
|
181
183
|
|
|
182
|
-
/**
|
|
183
|
-
const
|
|
184
|
+
/** Ten numbers a reader sees, none of them a `\numβ¦` macro. */
|
|
185
|
+
const TEN =
|
|
186
|
+
"We ran 1 and 2 and 3 and 4 and 5 and 6 and 7 and 8 and 9 and 10 times.";
|
|
184
187
|
|
|
185
|
-
it("π΄ a `\\numβ¦` macro in the paragraph's prose counts: the
|
|
186
|
-
expect(numbersFound(`${
|
|
187
|
-
{ numbers:
|
|
188
|
+
it("π΄ a `\\numβ¦` macro in the paragraph's prose counts: the eleventh fires", () => {
|
|
189
|
+
expect(numbersFound(`${TEN} Then \\numFoo{} more.`)).toEqual([
|
|
190
|
+
{ numbers: 11, max: 10, head: "We ran 1 and 2 and 3 andβ¦" },
|
|
188
191
|
]);
|
|
189
192
|
});
|
|
190
193
|
|
|
191
194
|
it("π΄ a `\\numβ¦` macro inside inline math is math, not prose: not counted", () => {
|
|
192
195
|
// Guards: the source between the paragraph's first and last piece holds the macro.
|
|
193
|
-
expect(numbersFound(`${
|
|
196
|
+
expect(numbersFound(`${TEN} Then $\\num{9}$ more.`)).toEqual([]);
|
|
194
197
|
});
|
|
195
198
|
|
|
196
199
|
it("π΄ a `\\numβ¦` macro on a commented-out line is not counted", () => {
|
|
197
200
|
// Guards: a comment changes nothing on the page, so it cannot add a number.
|
|
198
|
-
expect(numbersFound(`${
|
|
201
|
+
expect(numbersFound(`${TEN}\n% \\numFoo\nThen more.`)).toEqual([]);
|
|
199
202
|
});
|
|
200
203
|
|
|
201
204
|
it("π΄ a `\\numβ¦` macro in a footnote counts for the footnote, not for the paragraph it hangs from", () => {
|
|
202
205
|
// Guards: a footnote is a passage of its own; its numbers are its own.
|
|
203
206
|
expect(
|
|
204
|
-
numbersFound(`${
|
|
207
|
+
numbersFound(`${TEN}\\footnote{See \\numFoo{}.} Then more.`),
|
|
205
208
|
).toEqual([]);
|
|
206
209
|
});
|
|
207
210
|
});
|
|
@@ -225,6 +228,44 @@ describe("tex/max-sentence-words", () => {
|
|
|
225
228
|
),
|
|
226
229
|
).toHaveLength(1);
|
|
227
230
|
});
|
|
231
|
+
|
|
232
|
+
it("π΄ a sentence that opens in lowercase is its own (#543): the 82-word Β«sentenceΒ» of arXiv 2611.09573v1 is two", () => {
|
|
233
|
+
// The source as the paper has it (sections/02_models_and_data.tex): `16\,GB. fp16 β¦`. The
|
|
234
|
+
// segmenter withholds a break before a lowercase word; read as one sentence it is 82 words.
|
|
235
|
+
const body = [
|
|
236
|
+
"We did not pursue these formats: they need",
|
|
237
|
+
"calibration and low-precision implementations of every operation, and in",
|
|
238
|
+
"tests with Aurora they were either slower than bf16 or did not fit in",
|
|
239
|
+
"16\\,GB. fp16 and bf16 are the",
|
|
240
|
+
"reduced-precision formats that most users of these models can apply",
|
|
241
|
+
"directly: they need no calibration, and fast fp16 arithmetic is",
|
|
242
|
+
"available on NVIDIA GPUs from 2017 on, bf16 arithmetic from 2020 on",
|
|
243
|
+
"\\citep{nvidia2017volta, nvidia2020ampere}, and both on current consumer and",
|
|
244
|
+
"data-centre models.",
|
|
245
|
+
].join("\n");
|
|
246
|
+
expect(sFound(body)).toEqual([]);
|
|
247
|
+
expect(
|
|
248
|
+
judgeSentenceWords(latexReader.bodyProse(doc(body)), 40).map(
|
|
249
|
+
(f) => f.data,
|
|
250
|
+
),
|
|
251
|
+
).toEqual([
|
|
252
|
+
{
|
|
253
|
+
words: 48,
|
|
254
|
+
max: 40,
|
|
255
|
+
head: "fp16 and bf16 are the reduced-precision formats thatβ¦",
|
|
256
|
+
},
|
|
257
|
+
]);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("π΄ a `\\citet` that opens a sentence after a full stop starts it, and counts as its word", () => {
|
|
261
|
+
const w = (n: number) => Array.from({ length: n }, () => "w").join(" ");
|
|
262
|
+
expect(
|
|
263
|
+
sFound(`${w(29)} quantised. \\citet{b} applied ${w(26)} end.`),
|
|
264
|
+
).toEqual([]);
|
|
265
|
+
expect(
|
|
266
|
+
sFound(`${w(29)} quantised. \\citet{b} applied ${w(53)} end.`),
|
|
267
|
+
).toEqual([{ words: 56, max: 55, head: "applied w w w w w w wβ¦" }]);
|
|
268
|
+
});
|
|
228
269
|
});
|
|
229
270
|
|
|
230
271
|
describe("the new rules, through create()", () => {
|
|
@@ -253,7 +294,7 @@ describe("the new rules, through create()", () => {
|
|
|
253
294
|
const long = Array.from({ length: 60 }, () => "word").join(" ");
|
|
254
295
|
expect(run(maxSentenceWordsRule(deps), `${long}.`)).toHaveLength(1);
|
|
255
296
|
expect(
|
|
256
|
-
run(maxParagraphNumbersRule(deps), "1 2 3 4 5 6 7 8 9."),
|
|
297
|
+
run(maxParagraphNumbersRule(deps), "1 2 3 4 5 6 7 8 9 10 11."),
|
|
257
298
|
).toHaveLength(1);
|
|
258
299
|
expect(run(maxParagraphWordsRule(deps), "Short.")).toHaveLength(0);
|
|
259
300
|
});
|
package/src/readability.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THE PARAGRAPH CEILING β `tex/max-paragraph-words`, a rule of the `tex` plugin over the body's
|
|
3
|
-
* prose: a paragraph runs past `max` words (default
|
|
3
|
+
* prose: a paragraph runs past `max` words (default 250).
|
|
4
4
|
*
|
|
5
5
|
* ββ OFF BY DEFAULT βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
6
6
|
* No call for papers states a paragraph limit, so no venue is a source for the number. The rule is
|
|
7
7
|
* registered and silent until a project turns it on in its `rules`, as `tex/heading-case` is. The
|
|
8
8
|
* name and the `max` option follow ESLint's own `max-lines`, `max-len`, `max-statements`.
|
|
9
9
|
*
|
|
10
|
-
* ββ WHERE
|
|
11
|
-
* The
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* ββ WHERE 250 COMES FROM βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
+
* The 99th percentile of paragraph length over the accepted real papers in
|
|
12
|
+
* `fixtures/real-papers/accepted/` (96 papers with at least 2,500 body words, 7,994 paragraphs,
|
|
13
|
+
* measured with this rule's counter): p99 is 252, so 250 leaves about 1% of accepted paragraphs
|
|
14
|
+
* over it. The author chose it on 2026-11-20. It rests on what 99% of accepted paragraphs pass, not
|
|
15
|
+
* on reviewer evidence: a pilot on ICLR 2025 presentation scores found no link between long
|
|
16
|
+
* paragraphs and the score (inconclusive). The measurement is on the rule's page. A paragraph is
|
|
17
|
+
* at most `max` words; 250 is allowed.
|
|
15
18
|
*
|
|
16
19
|
* ββ WHAT IT READS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
17
20
|
* The body's prose through the `LatexReader` port (`bodyProse`): paragraphs, list items and
|
|
@@ -40,10 +43,10 @@ import {
|
|
|
40
43
|
} from "./tex-venue-rules.ts";
|
|
41
44
|
|
|
42
45
|
/** The ceiling when the config sets none: the largest paragraph that does not fire. */
|
|
43
|
-
export const DEFAULT_MAX_PARAGRAPH_WORDS =
|
|
46
|
+
export const DEFAULT_MAX_PARAGRAPH_WORDS = 250;
|
|
44
47
|
|
|
45
|
-
/** The numbers ceiling when the config sets none:
|
|
46
|
-
export const DEFAULT_MAX_PARAGRAPH_NUMBERS =
|
|
48
|
+
/** The numbers ceiling when the config sets none: an eleventh number fires. */
|
|
49
|
+
export const DEFAULT_MAX_PARAGRAPH_NUMBERS = 10;
|
|
47
50
|
|
|
48
51
|
/** The sentence ceiling when the config sets none: a 56th word fires. */
|
|
49
52
|
export const DEFAULT_MAX_SENTENCE_WORDS = 55;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The register band rules on REAL papers β the accepted ones in `fixtures/
|
|
2
|
+
* The register band rules on REAL papers β the accepted ones in `fixtures/real-papers/accepted/`, and
|
|
3
3
|
* variants derived from their sources, one change each:
|
|
4
4
|
*
|
|
5
5
|
* - every anchor the AIDC preset records is re-measured from its fixture and must equal the preset's
|
|
@@ -43,7 +43,7 @@ import { withRecord } from "../test/recorded-fixture.ts";
|
|
|
43
43
|
import { useTempDir, writeTree } from "../test/support.ts";
|
|
44
44
|
|
|
45
45
|
const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
46
|
-
const CORPUS = join(ROOT, "fixtures", "
|
|
46
|
+
const CORPUS = join(ROOT, "fixtures", "real-papers", "accepted");
|
|
47
47
|
|
|
48
48
|
/** The AIDC preset, resolved as a paper extending it would resolve it. */
|
|
49
49
|
const aidc = (() => {
|
|
@@ -218,14 +218,14 @@ const negationStanding = (a: RegisterAnchor): string => {
|
|
|
218
218
|
};
|
|
219
219
|
|
|
220
220
|
describe("tex/negated-sentences: AIDC's band from the same five ACSAC papers", () => {
|
|
221
|
-
it("π΄ the band is the anchors' 5.2β17.8%, widened to 2.9β21.
|
|
221
|
+
it("π΄ the band is the anchors' 5.2β17.8%, widened to 2.9β21.7%", () => {
|
|
222
222
|
const band = negationBandOf(aidc.registerAnchors);
|
|
223
223
|
expect(
|
|
224
224
|
band &&
|
|
225
225
|
[band.anchorMin, band.anchorMax, band.min, band.max].map((x) =>
|
|
226
226
|
x.toFixed(1),
|
|
227
227
|
),
|
|
228
|
-
).toEqual(["5.2", "17.8", "2.9", "21.
|
|
228
|
+
).toEqual(["5.2", "17.8", "2.9", "21.7"]);
|
|
229
229
|
});
|
|
230
230
|
|
|
231
231
|
it.each(ACSAC)(
|
package/src/rule-cases.test.ts
CHANGED
|
@@ -1373,21 +1373,21 @@ const CASES: Readonly<Record<string, RuleCases>> = {
|
|
|
1373
1373
|
// below): its cases turn it on in the paper's paperlint.json, as study/declare-sample's do.
|
|
1374
1374
|
"tex/max-paragraph-words": {
|
|
1375
1375
|
reports: {
|
|
1376
|
-
tree: paper(tex(wordsParagraph(
|
|
1376
|
+
tree: paper(tex(wordsParagraph(251)), MAX_PARAGRAPH_WORDS_ON),
|
|
1377
1377
|
file: TEX_FILE,
|
|
1378
1378
|
severity: 1,
|
|
1379
1379
|
line: 3,
|
|
1380
1380
|
},
|
|
1381
|
-
silent: paper(tex(wordsParagraph(
|
|
1381
|
+
silent: paper(tex(wordsParagraph(250)), MAX_PARAGRAPH_WORDS_ON),
|
|
1382
1382
|
},
|
|
1383
1383
|
"tex/max-paragraph-numbers": {
|
|
1384
1384
|
reports: {
|
|
1385
|
-
tree: paper(tex(numbersParagraph(
|
|
1385
|
+
tree: paper(tex(numbersParagraph(11)), CEILINGS_ON),
|
|
1386
1386
|
file: TEX_FILE,
|
|
1387
1387
|
severity: 1,
|
|
1388
1388
|
line: 3,
|
|
1389
1389
|
},
|
|
1390
|
-
silent: paper(tex(numbersParagraph(
|
|
1390
|
+
silent: paper(tex(numbersParagraph(10)), CEILINGS_ON),
|
|
1391
1391
|
},
|
|
1392
1392
|
"tex/max-sentence-words": {
|
|
1393
1393
|
reports: {
|
|
@@ -1842,10 +1842,10 @@ describe("tex/max-paragraph-words is off by default", () => {
|
|
|
1842
1842
|
});
|
|
1843
1843
|
|
|
1844
1844
|
describe("the other two ceilings are off by default", () => {
|
|
1845
|
-
it("
|
|
1845
|
+
it("eleven numbers and a 56-word sentence produce nothing under the default config", async () => {
|
|
1846
1846
|
const ids = async (tree: Record<string, string>) =>
|
|
1847
1847
|
(await lintTree(tree)).map((m) => m.ruleId);
|
|
1848
|
-
const body = `${numbersParagraph(
|
|
1848
|
+
const body = `${numbersParagraph(11)} ${longSentence(56)}`;
|
|
1849
1849
|
const off = await ids(paper(tex(body)));
|
|
1850
1850
|
expect(off).not.toContain("tex/max-paragraph-numbers");
|
|
1851
1851
|
expect(off).not.toContain("tex/max-sentence-words");
|