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
|
@@ -1,56 +1,39 @@
|
|
|
1
1
|
/** The captions of a document: the text a reader sees under a figure or a table. */
|
|
2
|
-
import {
|
|
2
|
+
import { hasAtLeast } from "remeda";
|
|
3
|
+
import type { Caption } from "../../domain/tex-document.ts";
|
|
3
4
|
import { isDefinition, isUnrendered } from "./hidden.ts";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
+
inPlace,
|
|
6
7
|
isNode,
|
|
8
|
+
macroPlace,
|
|
7
9
|
mandatory,
|
|
8
|
-
textOf,
|
|
9
10
|
visited,
|
|
10
11
|
type Macro,
|
|
11
12
|
type Node,
|
|
12
13
|
} from "./nodes.ts";
|
|
13
14
|
import type { ParsedTex } from "./parse.ts";
|
|
15
|
+
import { proseOfNodes } from "./prose.ts";
|
|
14
16
|
|
|
15
17
|
const isCaption = (n: Node): n is Macro =>
|
|
16
18
|
n.type === "macro" && n.content === "caption";
|
|
17
19
|
|
|
18
|
-
/** Math a reader sees as symbols: it counts as one word, and says nothing else. */
|
|
19
|
-
const MATH_NODES: ReadonlySet<Node["type"]> = new Set<Node["type"]>([
|
|
20
|
-
"inlinemath",
|
|
21
|
-
"displaymath",
|
|
22
|
-
"mathenv",
|
|
23
|
-
]);
|
|
24
|
-
const MATH_WORD = "math";
|
|
25
|
-
|
|
26
|
-
/** The escapes of a character LaTeX sets for itself: `\%` is a percent sign the reader sees. */
|
|
27
|
-
const ESCAPED: ReadonlySet<string> = new Set(["%", "&", "#", "$", "_"]);
|
|
28
|
-
|
|
29
|
-
/** What a reader sees of a caption's nodes: its words, its escapes, and one word for each formula. */
|
|
30
|
-
const captionText = (nodes: readonly Node[]): string =>
|
|
31
|
-
nodes
|
|
32
|
-
.map((n) => {
|
|
33
|
-
if (MATH_NODES.has(n.type)) return MATH_WORD;
|
|
34
|
-
if (n.type === "macro" && ESCAPED.has(n.content)) return n.content;
|
|
35
|
-
return n.type === "group" ? captionText(n.content) : textOf([n]);
|
|
36
|
-
})
|
|
37
|
-
.join("");
|
|
38
|
-
|
|
39
20
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
21
|
+
* Every `\caption` a reader sees, in document order, as prose read the way the body is (a citation
|
|
22
|
+
* or a formula is a mark, so one word) with the span of the `\caption` and its arguments. Its last mandatory
|
|
23
|
+
* argument, whatever optional argument (`\caption[Short]{…}`), star or space comes before it;
|
|
24
|
+
* nothing commented out, in code or in a macro's definition; a caption with no word in it is left out.
|
|
44
25
|
*/
|
|
45
|
-
export function
|
|
26
|
+
export function captionProse(t: ParsedTex): readonly Caption[] {
|
|
46
27
|
return visited(
|
|
47
28
|
t.root,
|
|
48
29
|
(v, parent) => isUnrendered(v, parent) || isDefinition(v),
|
|
49
30
|
)
|
|
50
31
|
.filter(isNode)
|
|
51
32
|
.filter(isCaption)
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
.flatMap((m) => {
|
|
34
|
+
const passages = proseOfNodes(t, mandatory(m).at(-1)?.content ?? []);
|
|
35
|
+
return hasAtLeast(passages, 1)
|
|
36
|
+
? inPlace(macroPlace(m), (span) => [{ passages, span }])
|
|
37
|
+
: [];
|
|
38
|
+
});
|
|
56
39
|
}
|
|
@@ -704,6 +704,17 @@ describe("bodyEmphasis — each style, and edge cases", () => {
|
|
|
704
704
|
).toEqual(["bold/inline: this"]);
|
|
705
705
|
});
|
|
706
706
|
|
|
707
|
+
it("🔴 each phrase names the command that set it: a macro, or the declaration opening its group", () => {
|
|
708
|
+
// Guards: \emph and \textit fold into one style, and tex/term-before-definition reads only \emph.
|
|
709
|
+
expect(
|
|
710
|
+
bodyEmphasis(
|
|
711
|
+
parseLatex(
|
|
712
|
+
"\\begin{document}\nA \\emph{b} c \\textit{d} e {\\em f} g {\\itshape h} i \\textbf{j}.\n\\end{document}",
|
|
713
|
+
),
|
|
714
|
+
).map((e) => `${e.command}: ${e.text}`),
|
|
715
|
+
).toEqual(["emph: b", "textit: d", "em: f", "itshape: h", "textbf: j"]);
|
|
716
|
+
});
|
|
717
|
+
|
|
707
718
|
it("the span is the macro with its argument, where the source has it", () => {
|
|
708
719
|
const src = "\\begin{document}\nWe \\textbf{see it}.\n\\end{document}";
|
|
709
720
|
const [e] = bodyEmphasis(parseLatex(src));
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
* (`ParsedTex`, minted by `parseLatex` alone).
|
|
22
22
|
*/
|
|
23
23
|
import type { LatexReader } from "../../ports/latex.ts";
|
|
24
|
-
import { abstractText } from "./abstract.ts";
|
|
24
|
+
import { abstractSpan, abstractText } from "./abstract.ts";
|
|
25
25
|
import {
|
|
26
26
|
documentClassOf,
|
|
27
27
|
parseTemplate,
|
|
28
28
|
replaceDocumentClass,
|
|
29
29
|
} from "./document-class.ts";
|
|
30
30
|
import { citeKeysOf, macroTextsOf, registeredNumbersOf } from "./facts.ts";
|
|
31
|
+
import { captionProse } from "./captions.ts";
|
|
31
32
|
import { headingsOf } from "./headings.ts";
|
|
32
33
|
import { documentBodyOf, includesOf } from "./includes.ts";
|
|
33
34
|
import { outlineOf } from "./outline.ts";
|
|
@@ -52,7 +53,7 @@ export {
|
|
|
52
53
|
textOf,
|
|
53
54
|
} from "./nodes.ts";
|
|
54
55
|
export { documentBodyOf, includesOf } from "./includes.ts";
|
|
55
|
-
export {
|
|
56
|
+
export { captionProse } from "./captions.ts";
|
|
56
57
|
export { headingsOf } from "./headings.ts";
|
|
57
58
|
export { outlineOf } from "./outline.ts";
|
|
58
59
|
export { parseLatex, type ParsedTex } from "./parse.ts";
|
|
@@ -68,6 +69,7 @@ export const latexReader: LatexReader = {
|
|
|
68
69
|
renderedRuns: (src) => renderedRuns(parseLatex(src)),
|
|
69
70
|
bodyProse: (src) => bodyProse(parseLatex(src)),
|
|
70
71
|
bodyEmphasis: (src) => bodyEmphasis(parseLatex(src)),
|
|
72
|
+
captions: (src) => captionProse(parseLatex(src)),
|
|
71
73
|
includes: (src) => includesOf(parseLatex(src)),
|
|
72
74
|
documentBody: (src) => documentBodyOf(parseLatex(src)),
|
|
73
75
|
template: parseTemplate,
|
|
@@ -75,6 +77,7 @@ export const latexReader: LatexReader = {
|
|
|
75
77
|
layoutOverrides: (src) => layoutOverridesOf(parseLatex(src)),
|
|
76
78
|
filecontents: (src, jobname) => filecontentsOf(parseLatex(src), jobname),
|
|
77
79
|
abstractText,
|
|
80
|
+
abstractSpan,
|
|
78
81
|
citeKeys: (src) => citeKeysOf(parseLatex(src)),
|
|
79
82
|
registeredNumbers: registeredNumbersOf,
|
|
80
83
|
macroTexts: macroTextsOf,
|
|
@@ -296,6 +296,7 @@ const EMPHASIS_DECLARATIONS: ReadonlyMap<string, EmphasisStyle> = new Map([
|
|
|
296
296
|
/** An emphasised phrase over `place`, typesetting what `inner` typesets; nothing when it has no place or no text. */
|
|
297
297
|
const emphasisOf = (
|
|
298
298
|
style: EmphasisStyle,
|
|
299
|
+
command: string,
|
|
299
300
|
place: Place,
|
|
300
301
|
inner: readonly Event[],
|
|
301
302
|
): readonly Event[] =>
|
|
@@ -306,7 +307,7 @@ const emphasisOf = (
|
|
|
306
307
|
: [
|
|
307
308
|
{
|
|
308
309
|
kind: "emphasis",
|
|
309
|
-
emphasis: { style, place: "inline", text, span },
|
|
310
|
+
emphasis: { style, command, place: "inline", text, span },
|
|
310
311
|
},
|
|
311
312
|
];
|
|
312
313
|
});
|
|
@@ -317,26 +318,28 @@ function formattingEvents(t: ParsedTex, m: Macro): readonly Event[] {
|
|
|
317
318
|
const style = EMPHASIS_MACROS.get(m.content);
|
|
318
319
|
return style === undefined
|
|
319
320
|
? inner
|
|
320
|
-
: [...emphasisOf(style, macroPlace(m), inner), ...inner];
|
|
321
|
+
: [...emphasisOf(style, m.content, macroPlace(m), inner), ...inner];
|
|
321
322
|
}
|
|
322
323
|
|
|
323
|
-
/** The
|
|
324
|
-
function
|
|
324
|
+
/** The declaration a group opens with (`{\bfseries …}`) and the style it sets, or undefined for none. */
|
|
325
|
+
function openingDeclaration(
|
|
326
|
+
list: readonly Node[],
|
|
327
|
+
): { readonly command: string; readonly style: EmphasisStyle } | undefined {
|
|
325
328
|
const first = list.find(
|
|
326
329
|
(n) => n.type !== "whitespace" && n.type !== "comment",
|
|
327
330
|
);
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
+
if (first?.type !== "macro") return undefined;
|
|
332
|
+
const style = EMPHASIS_DECLARATIONS.get(first.content);
|
|
333
|
+
return style === undefined ? undefined : { command: first.content, style };
|
|
331
334
|
}
|
|
332
335
|
|
|
333
336
|
/** A group's events: what it typesets, and — when it opens with an emphasis declaration — the phrase. */
|
|
334
337
|
function groupEvents(t: ParsedTex, g: NodeOf<"group">): readonly Event[] {
|
|
335
338
|
const inner = walkList(t, g.content);
|
|
336
|
-
const
|
|
337
|
-
return
|
|
339
|
+
const d = openingDeclaration(g.content);
|
|
340
|
+
return d === undefined
|
|
338
341
|
? inner
|
|
339
|
-
: [...emphasisOf(style, placeOf(g), inner), ...inner];
|
|
342
|
+
: [...emphasisOf(d.style, d.command, placeOf(g), inner), ...inner];
|
|
340
343
|
}
|
|
341
344
|
|
|
342
345
|
function macroEvents(t: ParsedTex, m: Macro): readonly Event[] {
|
|
@@ -518,7 +521,7 @@ const asOpening = (node: Node, events: readonly Event[]): readonly Event[] => {
|
|
|
518
521
|
const n = unwrapped(node);
|
|
519
522
|
const emphasises =
|
|
520
523
|
(n.type === "macro" && EMPHASIS_MACROS.has(n.content)) ||
|
|
521
|
-
(n.type === "group" &&
|
|
524
|
+
(n.type === "group" && openingDeclaration(n.content) !== undefined);
|
|
522
525
|
return emphasises && own?.kind === "emphasis"
|
|
523
526
|
? [
|
|
524
527
|
{ kind: "emphasis", emphasis: { ...own.emphasis, place: "opening" } },
|
|
@@ -606,6 +609,15 @@ const startOf = (p: Passage): number => {
|
|
|
606
609
|
return first.kind === "text" ? first.segment.at : first.span.start;
|
|
607
610
|
};
|
|
608
611
|
|
|
612
|
+
/**
|
|
613
|
+
* What a list of nodes typesets, as passages: the prose of an argument read on its own (a caption).
|
|
614
|
+
* Nothing opens a paragraph here, so a bold label at its start stays prose.
|
|
615
|
+
*/
|
|
616
|
+
export const proseOfNodes = (
|
|
617
|
+
t: ParsedTex,
|
|
618
|
+
nodes: readonly Node[],
|
|
619
|
+
): readonly Passage[] => passagesOf(walkList(t, nodes)).filter(hasProse);
|
|
620
|
+
|
|
609
621
|
/**
|
|
610
622
|
* The body's prose, in document order: the content of the `document` environment (the whole
|
|
611
623
|
* source when there is none), up to the first back-matter node.
|
package/src/cli.ts
CHANGED
|
@@ -87,6 +87,7 @@ import {
|
|
|
87
87
|
texVenueRules,
|
|
88
88
|
} from "./tex-venue-rules.ts";
|
|
89
89
|
import { claimProvenanceRule } from "./claim-provenance.ts";
|
|
90
|
+
import { termDefinitionRules } from "./term-definition-rules.ts";
|
|
90
91
|
import { registerRule } from "./register.ts";
|
|
91
92
|
import {
|
|
92
93
|
REGISTER_BAND_RULE_LEVELS,
|
|
@@ -97,6 +98,7 @@ import {
|
|
|
97
98
|
maxParagraphNumbersRule,
|
|
98
99
|
maxParagraphWordsRule,
|
|
99
100
|
maxSentenceWordsRule,
|
|
101
|
+
maxCaptionWordsRule,
|
|
100
102
|
} from "./readability.ts";
|
|
101
103
|
import {
|
|
102
104
|
paperRules,
|
|
@@ -220,6 +222,7 @@ import {
|
|
|
220
222
|
recordTold,
|
|
221
223
|
} from "./hooks-notice.ts";
|
|
222
224
|
import { unwiredHooks } from "./hooks-settings.ts";
|
|
225
|
+
import { linkSkills, unlinkedSkills, type LinkReport } from "./link-skills.ts";
|
|
223
226
|
import {
|
|
224
227
|
lintEditedHook,
|
|
225
228
|
type LintResult,
|
|
@@ -455,6 +458,8 @@ const REGISTER_AND_CASE_RULES = {
|
|
|
455
458
|
"max-paragraph-words": maxParagraphWordsRule(TEX_RULE_DEPS),
|
|
456
459
|
"max-paragraph-numbers": maxParagraphNumbersRule(TEX_RULE_DEPS),
|
|
457
460
|
"max-sentence-words": maxSentenceWordsRule(TEX_RULE_DEPS),
|
|
461
|
+
"max-caption-words": maxCaptionWordsRule(TEX_RULE_DEPS),
|
|
462
|
+
...termDefinitionRules(TEX_RULE_DEPS),
|
|
458
463
|
};
|
|
459
464
|
|
|
460
465
|
/**
|
|
@@ -1451,8 +1456,13 @@ interface HookOptions {
|
|
|
1451
1456
|
readonly projectDir?: string;
|
|
1452
1457
|
/** The installed paperlint version the notice names. */
|
|
1453
1458
|
readonly version?: string;
|
|
1459
|
+
/** What `paperlint doctor` reads to find unlinked skills; the disk by default. */
|
|
1460
|
+
readonly skillLinks?: (root: string) => LinkReport;
|
|
1454
1461
|
}
|
|
1455
1462
|
|
|
1463
|
+
const readSkillLinks = (root: string): LinkReport =>
|
|
1464
|
+
linkSkills(root, { write: false });
|
|
1465
|
+
|
|
1456
1466
|
const defaultStdin = (): string => readFileSync(0, "utf8");
|
|
1457
1467
|
const defaultOut = (text: string): void => {
|
|
1458
1468
|
process.stdout.write(text);
|
|
@@ -1502,10 +1512,12 @@ function pendingNotice(io: ResolvedHookOptions): Pending | null {
|
|
|
1502
1512
|
try {
|
|
1503
1513
|
const root = hookRoot(io);
|
|
1504
1514
|
const { missing, byHand } = unwiredHooks(root);
|
|
1515
|
+
const skills = unlinkedSkills((io.skillLinks ?? readSkillLinks)(root));
|
|
1505
1516
|
const version = io.version ?? packageVersion();
|
|
1506
|
-
return missing.length === 0
|
|
1517
|
+
return (missing.length === 0 && skills.length === 0) ||
|
|
1518
|
+
!notYetTold(nodeFiles, root, version)
|
|
1507
1519
|
? null
|
|
1508
|
-
: { text: noticeText(version, missing, byHand), root, version };
|
|
1520
|
+
: { text: noticeText(version, missing, byHand, skills), root, version };
|
|
1509
1521
|
} catch (e) {
|
|
1510
1522
|
io.err(
|
|
1511
1523
|
`paperlint: the unwired-hooks check did not run: ${firstLine(messageOf(e))}`,
|
|
@@ -1525,10 +1537,16 @@ const touchesAPaper = (payload: string): boolean => {
|
|
|
1525
1537
|
};
|
|
1526
1538
|
|
|
1527
1539
|
/** `paperlint lint`'s one stderr line when the project's hooks are only partly wired. Never throws. */
|
|
1528
|
-
function hooksLine(
|
|
1540
|
+
function hooksLine(
|
|
1541
|
+
root: string,
|
|
1542
|
+
err: typeof console.error,
|
|
1543
|
+
skillLinks: (root: string) => LinkReport,
|
|
1544
|
+
): void {
|
|
1529
1545
|
try {
|
|
1530
1546
|
const { missing } = unwiredHooks(root);
|
|
1531
|
-
|
|
1547
|
+
const skills = unlinkedSkills(skillLinks(root));
|
|
1548
|
+
if (missing.length > 0 || skills.length > 0)
|
|
1549
|
+
err(lintLine(packageVersion(), missing, skills));
|
|
1532
1550
|
} catch {
|
|
1533
1551
|
// The report above is the verdict; this line is advice, and a broken settings read is not worth a second one.
|
|
1534
1552
|
}
|
|
@@ -2234,6 +2252,7 @@ export async function run(
|
|
|
2234
2252
|
now = () => performance.now(),
|
|
2235
2253
|
checkReferences = onlineReferences,
|
|
2236
2254
|
loadTexLanguage = loadLatexLanguage,
|
|
2255
|
+
skillLinks = readSkillLinks,
|
|
2237
2256
|
}: {
|
|
2238
2257
|
log?: typeof console.log;
|
|
2239
2258
|
err?: typeof console.error;
|
|
@@ -2250,6 +2269,8 @@ export async function run(
|
|
|
2250
2269
|
* fake: no test depends on Crossref, Semantic Scholar or DBLP answering.
|
|
2251
2270
|
*/
|
|
2252
2271
|
checkReferences?: CheckReferences;
|
|
2272
|
+
/** The skills report `lint`'s stderr line reads; a test hands a fixed one. */
|
|
2273
|
+
skillLinks?: (root: string) => LinkReport;
|
|
2253
2274
|
} = {},
|
|
2254
2275
|
): Promise<number> {
|
|
2255
2276
|
const a = parseArgs(argv);
|
|
@@ -2404,7 +2425,7 @@ export async function run(
|
|
|
2404
2425
|
.map((d) => join(d, MAIN))
|
|
2405
2426
|
.filter((f) => existsSync(f)),
|
|
2406
2427
|
});
|
|
2407
|
-
hooksLine(root, err);
|
|
2428
|
+
hooksLine(root, err, skillLinks);
|
|
2408
2429
|
// On stderr, so `--json` leaves stdout a clean array.
|
|
2409
2430
|
timingLines({
|
|
2410
2431
|
files: results.length,
|
|
@@ -11,7 +11,10 @@ import {
|
|
|
11
11
|
claimEmphasis,
|
|
12
12
|
contrastFrames,
|
|
13
13
|
excerpt,
|
|
14
|
+
negatedSentences,
|
|
15
|
+
negationBandOf,
|
|
14
16
|
rateOf,
|
|
17
|
+
shareOf,
|
|
15
18
|
relationMarkers,
|
|
16
19
|
type RegisterAnchor,
|
|
17
20
|
} from "./register.ts";
|
|
@@ -140,6 +143,68 @@ describe("bandOf — the anchors' range, widened by two Poisson standard deviati
|
|
|
140
143
|
});
|
|
141
144
|
});
|
|
142
145
|
|
|
146
|
+
describe("negatedSentences — the sentences that hold a negator, each once", () => {
|
|
147
|
+
const negated = (body: string): readonly string[] =>
|
|
148
|
+
negatedSentences(sentencesOf(body)).map((o) => o.match);
|
|
149
|
+
|
|
150
|
+
it("🔴 each negator of the list, whole words, case ignored; a sentence with two counts once", () => {
|
|
151
|
+
expect(
|
|
152
|
+
negated(
|
|
153
|
+
"It is not run. No gate fires. None passed. It never blocks. We cannot tell. It isn't kept. They don't run. Neither holds. Nor this. It runs without a gate. It fails to stop. The gate failed to stop it. It is unable to read. It is not here and never was.",
|
|
154
|
+
),
|
|
155
|
+
).toEqual([
|
|
156
|
+
"It is not run.",
|
|
157
|
+
"No gate fires.",
|
|
158
|
+
"None passed.",
|
|
159
|
+
"It never blocks.",
|
|
160
|
+
"We cannot tell.",
|
|
161
|
+
"It isn't kept.",
|
|
162
|
+
"They don't run.",
|
|
163
|
+
"Neither holds.",
|
|
164
|
+
"Nor this.",
|
|
165
|
+
"It runs without a gate.",
|
|
166
|
+
"It fails to stop.",
|
|
167
|
+
"The gate failed to stop it.",
|
|
168
|
+
"It is unable to read.",
|
|
169
|
+
"It is not here and never was.",
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("🔴 silent on words that only contain one: note, know, another, nothing, failure, notion, snow", () => {
|
|
174
|
+
expect(
|
|
175
|
+
negated(
|
|
176
|
+
"Note the knot. We know another notion. Nothing failed here. A failure to load. The snow fell. Nones and nevermore.",
|
|
177
|
+
),
|
|
178
|
+
).toEqual([]);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe("negationBandOf — the share of negated sentences the anchors set", () => {
|
|
183
|
+
const anchor = (negation?: RegisterAnchor["negation"]): RegisterAnchor => ({
|
|
184
|
+
paper: "p",
|
|
185
|
+
words: 1000,
|
|
186
|
+
counts: { contrast_frames: 0, claim_emphasis: 0, relation_markers: 0 },
|
|
187
|
+
...(negation === undefined ? {} : { negation }),
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("🔴 the anchors' range in percent, widened by two Poisson standard deviations of the edge anchor", () => {
|
|
191
|
+
// 25 of 100: 25 %, sd 5 → max 35. 9 of 100: 9 %, sd 3 → min 3.
|
|
192
|
+
expect(
|
|
193
|
+
negationBandOf([
|
|
194
|
+
anchor({ sentences: 100, negated: 25 }),
|
|
195
|
+
anchor({ sentences: 100, negated: 9 }),
|
|
196
|
+
anchor(),
|
|
197
|
+
]),
|
|
198
|
+
).toEqual({ min: 3, max: 35, anchorMin: 9, anchorMax: 25, anchors: 2 });
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("no anchor that records it, no band; a body of no sentences has a share of zero", () => {
|
|
202
|
+
expect(negationBandOf([anchor(), anchor()])).toBeNull();
|
|
203
|
+
expect(shareOf(3, 0)).toBe(0);
|
|
204
|
+
expect(shareOf(1, 4)).toBe(25);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
143
208
|
describe("excerpt — the words around an occurrence, as a finding quotes them", () => {
|
|
144
209
|
it("the match with its neighbours, cut at a word, an ellipsis where the sentence goes on", () => {
|
|
145
210
|
const s =
|
package/src/domain/register.ts
CHANGED
|
@@ -42,6 +42,14 @@ export interface RegisterAnchor {
|
|
|
42
42
|
readonly paper: string;
|
|
43
43
|
readonly words: number;
|
|
44
44
|
readonly counts: Readonly<Record<RegisterMeasureName, number>>;
|
|
45
|
+
/**
|
|
46
|
+
* Its body's sentences, and how many hold a negator (`negatedSentences`). A share of sentences,
|
|
47
|
+
* not a rate per words; absent from a preset written before the measure, which sets no band for it.
|
|
48
|
+
*/
|
|
49
|
+
readonly negation?: {
|
|
50
|
+
readonly sentences: number;
|
|
51
|
+
readonly negated: number;
|
|
52
|
+
};
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
/** How far the band reaches past the anchors: this many Poisson standard deviations. */
|
|
@@ -64,25 +72,27 @@ export interface Band {
|
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
/** One anchor's rate of a measure, and how far one standard deviation of its count reaches. */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
sd: rateOf(Math.sqrt(Math.max(count, 1)), a.words),
|
|
72
|
-
};
|
|
73
|
-
};
|
|
75
|
+
interface Point {
|
|
76
|
+
readonly rate: number;
|
|
77
|
+
readonly sd: number;
|
|
78
|
+
}
|
|
74
79
|
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
):
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
/**
|
|
81
|
+
* A count over a base, as a rate `per` units of it, with its Poisson standard deviation. A preset's
|
|
82
|
+
* schema requires a base of at least one word and one sentence.
|
|
83
|
+
*/
|
|
84
|
+
const pointOf = (count: number, base: number, per: number): Point => ({
|
|
85
|
+
rate: (per * count) / base,
|
|
86
|
+
sd: (per * Math.sqrt(Math.max(count, 1))) / base,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/** The band a set of anchors' points sets; null when there is none. */
|
|
90
|
+
function bandFrom(points: readonly Point[]): Band | null {
|
|
91
|
+
const low = points.reduce<Point | null>(
|
|
82
92
|
(lo, r) => (lo === null || r.rate < lo.rate ? r : lo),
|
|
83
93
|
null,
|
|
84
94
|
);
|
|
85
|
-
const high =
|
|
95
|
+
const high = points.reduce<Point | null>(
|
|
86
96
|
(hi, r) => (hi === null || r.rate > hi.rate ? r : hi),
|
|
87
97
|
null,
|
|
88
98
|
);
|
|
@@ -92,10 +102,39 @@ export function bandOf(
|
|
|
92
102
|
max: high.rate + NOISE_SDS * high.sd,
|
|
93
103
|
anchorMin: low.rate,
|
|
94
104
|
anchorMax: high.rate,
|
|
95
|
-
anchors:
|
|
105
|
+
anchors: points.length,
|
|
96
106
|
};
|
|
97
107
|
}
|
|
98
108
|
|
|
109
|
+
/** The band the anchors set for a measure; null when there are no anchors. */
|
|
110
|
+
export const bandOf = (
|
|
111
|
+
anchors: readonly RegisterAnchor[],
|
|
112
|
+
m: RegisterMeasureName,
|
|
113
|
+
): Band | null =>
|
|
114
|
+
bandFrom(anchors.map((a) => pointOf(a.counts[m], a.words, PER)));
|
|
115
|
+
|
|
116
|
+
/** Percent: a share of sentences is read per hundred. */
|
|
117
|
+
export const PERCENT = 100;
|
|
118
|
+
|
|
119
|
+
/** A share of `n` as a percent; 0 of none. */
|
|
120
|
+
export const shareOf = (count: number, n: number): number =>
|
|
121
|
+
n === 0 ? 0 : (PERCENT * count) / n;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The band the anchors set for the share of sentences holding a negator: over the anchors that
|
|
125
|
+
* record it, widened like every other band; null when none does.
|
|
126
|
+
*/
|
|
127
|
+
export const negationBandOf = (
|
|
128
|
+
anchors: readonly RegisterAnchor[],
|
|
129
|
+
): Band | null =>
|
|
130
|
+
bandFrom(
|
|
131
|
+
anchors.flatMap((a) =>
|
|
132
|
+
a.negation === undefined
|
|
133
|
+
? []
|
|
134
|
+
: [pointOf(a.negation.negated, a.negation.sentences, PERCENT)],
|
|
135
|
+
),
|
|
136
|
+
);
|
|
137
|
+
|
|
99
138
|
// ── sentences, as every register measure reads them ───────────────────────────────
|
|
100
139
|
|
|
101
140
|
/** The characters a mark or math stands as in a sentence's text. */
|
|
@@ -191,6 +230,14 @@ const CONTRAST_FRAME = anyOf([
|
|
|
191
230
|
const RELATION_MARKERS =
|
|
192
231
|
/(?<![\p{L}])(?:therefore|thus|hence|consequently|as a result|because|since|this means|this implies|which explains|in turn|that is,|i\.e\.|in contrast|by contrast|however|nevertheless|nonetheless|whereas|in other words|for this reason|it follows|accordingly|specifically,|in particular,|for example|for instance|e\.g\.)(?![\p{L}])/giu;
|
|
193
232
|
|
|
233
|
+
/**
|
|
234
|
+
* A negator: the list the earlier prose counter used (not, no, none, never, cannot, n't,
|
|
235
|
+
* neither, nor, without, fail to, unable), whole words, case ignored. `n't` ends a word
|
|
236
|
+
* («don't», «isn't»), so it is matched there; the script's own pattern for it never matched.
|
|
237
|
+
*/
|
|
238
|
+
const NEGATOR =
|
|
239
|
+
/(?<![\p{L}])(?:not|no|none|never|cannot|neither|nor|without|unable|fail(?:s|ed)?\s+to)(?![\p{L}])|(?<=\p{L})n['’]t(?![\p{L}])/giu;
|
|
240
|
+
|
|
194
241
|
/** How many characters of context an excerpt keeps on each side of a match. */
|
|
195
242
|
const CONTEXT = 40;
|
|
196
243
|
|
|
@@ -237,6 +284,15 @@ export const relationMarkers = (
|
|
|
237
284
|
ss: readonly BodySentence[],
|
|
238
285
|
): readonly Occurrence[] => occurrences(ss, RELATION_MARKERS);
|
|
239
286
|
|
|
287
|
+
/**
|
|
288
|
+
* The sentences that hold a negator, one occurrence each: its first negator, with where it stands.
|
|
289
|
+
* What the share of negated sentences counts.
|
|
290
|
+
*/
|
|
291
|
+
export const negatedSentences = (
|
|
292
|
+
ss: readonly BodySentence[],
|
|
293
|
+
): readonly Occurrence[] =>
|
|
294
|
+
ss.flatMap((s) => occurrences([s], NEGATOR).slice(0, 1));
|
|
295
|
+
|
|
240
296
|
/** A phrase this long or longer states something rather than names it. */
|
|
241
297
|
export const CLAIM_WORDS = 6;
|
|
242
298
|
|