chaffjs 0.26.0 → 0.27.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/dist/ai-score/human-shares.js +59 -59
- package/dist/ai-score/human-shares.js.map +1 -1
- package/dist/capitals-with-small.d.ts +8 -0
- package/dist/capitals-with-small.d.ts.map +1 -0
- package/dist/capitals-with-small.js +20 -0
- package/dist/capitals-with-small.js.map +1 -0
- package/dist/derived/relative-weekdays.d.ts +16 -0
- package/dist/derived/relative-weekdays.d.ts.map +1 -0
- package/dist/derived/relative-weekdays.js +52 -0
- package/dist/derived/relative-weekdays.js.map +1 -0
- package/dist/detectors/change-rate.d.ts +3 -0
- package/dist/detectors/change-rate.d.ts.map +1 -0
- package/dist/detectors/change-rate.js +102 -0
- package/dist/detectors/change-rate.js.map +1 -0
- package/dist/detectors/derived-numbers.d.ts.map +1 -1
- package/dist/detectors/derived-numbers.js +3 -7
- package/dist/detectors/derived-numbers.js.map +1 -1
- package/dist/detectors/document-date.d.ts +4 -0
- package/dist/detectors/document-date.d.ts.map +1 -0
- package/dist/detectors/document-date.js +12 -0
- package/dist/detectors/document-date.js.map +1 -0
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +16 -11
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/registry/change-rate.d.ts +3 -0
- package/dist/detectors/registry/change-rate.d.ts.map +1 -0
- package/dist/detectors/registry/change-rate.js +3 -0
- package/dist/detectors/registry/change-rate.js.map +1 -0
- package/dist/detectors/registry/version-mismatch.d.ts +3 -0
- package/dist/detectors/registry/version-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/version-mismatch.js +3 -0
- package/dist/detectors/registry/version-mismatch.js.map +1 -0
- package/dist/detectors/relative-dates.d.ts.map +1 -1
- package/dist/detectors/relative-dates.js +3 -1
- package/dist/detectors/relative-dates.js.map +1 -1
- package/dist/detectors/relative-day-words.d.ts +4 -0
- package/dist/detectors/relative-day-words.d.ts.map +1 -0
- package/dist/detectors/relative-day-words.js +105 -0
- package/dist/detectors/relative-day-words.js.map +1 -0
- package/dist/detectors/structure-tree.d.ts +4 -1
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +65 -3
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/version-mismatch.d.ts +3 -0
- package/dist/detectors/version-mismatch.d.ts.map +1 -0
- package/dist/detectors/version-mismatch.js +19 -0
- package/dist/detectors/version-mismatch.js.map +1 -0
- package/dist/structure/change-rate.d.ts +33 -0
- package/dist/structure/change-rate.d.ts.map +1 -0
- package/dist/structure/change-rate.js +71 -0
- package/dist/structure/change-rate.js.map +1 -0
- package/dist/structure/list-numbering.d.ts +17 -0
- package/dist/structure/list-numbering.d.ts.map +1 -0
- package/dist/structure/list-numbering.js +27 -0
- package/dist/structure/list-numbering.js.map +1 -0
- package/dist/structure/percent-sum-prose.d.ts +7 -0
- package/dist/structure/percent-sum-prose.d.ts.map +1 -0
- package/dist/structure/percent-sum-prose.js +44 -0
- package/dist/structure/percent-sum-prose.js.map +1 -0
- package/dist/structure/version-mismatch.d.ts +23 -0
- package/dist/structure/version-mismatch.d.ts.map +1 -0
- package/dist/structure/version-mismatch.js +74 -0
- package/dist/structure/version-mismatch.js.map +1 -0
- package/dist/structure/weekday.d.ts +21 -2
- package/dist/structure/weekday.d.ts.map +1 -1
- package/dist/structure/weekday.js +70 -8
- package/dist/structure/weekday.js.map +1 -1
- package/package.json +3 -3
- package/rules/agreement-slip.yaml +2 -2
- package/rules/change-rate-mismatch.yaml +44 -0
- package/rules/date-weekday-mismatch.yaml +4 -4
- package/rules/max-sentence-length.yaml +1 -0
- package/rules/numbering-gap.yaml +4 -4
- package/rules/one-sentence-paragraph-run.yaml +1 -0
- package/rules/orthographic-variant.yaml +3 -3
- package/rules/percent-sum-mismatch.yaml +4 -4
- package/rules/relative-date-mismatch.yaml +4 -4
- package/rules/undefined-acronym.yaml +1 -0
- package/rules/version-mismatch.yaml +77 -0
- package/src/ai-score/human-shares.ts +59 -59
- package/src/capitals-with-small.ts +23 -0
- package/src/derived/relative-weekdays.ts +65 -0
- package/src/detectors/change-rate.ts +122 -0
- package/src/detectors/derived-numbers.ts +3 -11
- package/src/detectors/document-date.ts +18 -0
- package/src/detectors/orthographic-variant.ts +8 -4
- package/src/detectors/registry/change-rate.ts +4 -0
- package/src/detectors/registry/version-mismatch.ts +4 -0
- package/src/detectors/relative-dates.ts +3 -1
- package/src/detectors/relative-day-words.ts +126 -0
- package/src/detectors/structure-tree.ts +76 -4
- package/src/detectors/version-mismatch.ts +23 -0
- package/src/structure/change-rate.ts +103 -0
- package/src/structure/list-numbering.ts +34 -0
- package/src/structure/percent-sum-prose.ts +54 -0
- package/src/structure/version-mismatch.ts +103 -0
- package/src/structure/weekday.ts +83 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-mismatch.d.ts","sourceRoot":"","sources":["../../src/detectors/version-mismatch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAW,MAAM,cAAc,CAAC;AAKtD,eAAO,MAAM,eAAe,EAAE,QAc7B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { versionMismatches } from "../structure/version-mismatch.js";
|
|
2
|
+
import { codeFences } from "./code-fences.js";
|
|
3
|
+
import { quoteAt } from "./structure-tree.js";
|
|
4
|
+
export const versionMismatch = (doc) => {
|
|
5
|
+
const words = {
|
|
6
|
+
ranges: (doc.lexicons["version-range"] ?? []).map((entry) => ({ word: entry.pattern, position: entry.position ?? "before" })),
|
|
7
|
+
versionWords: (doc.lexicons["version-lead"] ?? []).map((entry) => entry.pattern),
|
|
8
|
+
};
|
|
9
|
+
const blocks = codeFences(doc.source).map((fence) => ({ start: fence.start, code: fence.lines.join("\n") }));
|
|
10
|
+
return versionMismatches(doc.source, doc.prose ?? doc.source, blocks, words).map((issue) => ({
|
|
11
|
+
rule: "version-mismatch",
|
|
12
|
+
severity: "warning",
|
|
13
|
+
line: 0,
|
|
14
|
+
column: 0,
|
|
15
|
+
quote: quoteAt(doc.source, issue.offset),
|
|
16
|
+
values: { ...issue.values, offset: issue.offset },
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=version-mismatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-mismatch.js","sourceRoot":"","sources":["../../src/detectors/version-mismatch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAqC,MAAM,kCAAkC,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAa,CAAC,GAAG,EAAa,EAAE;IAC1D,MAAM,KAAK,GAAiB;QAC1B,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAa,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC,CAAC;QACxI,YAAY,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;KACjF,CAAC;IACF,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7G,OAAO,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3F,IAAI,EAAE,kBAAkB;QACxB,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACxC,MAAM,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;KAClD,CAAC,CAAC,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
import type { StructureIssue } from "./issues.ts";
|
|
3
|
+
/** A value with its unit as the sentence compares it (円, 社, $, companies) and the step it is written to (1 for 1,200; 1億 for 12億). */
|
|
4
|
+
export type Figure = Span & {
|
|
5
|
+
readonly value: number;
|
|
6
|
+
readonly unit: string;
|
|
7
|
+
readonly step: number;
|
|
8
|
+
};
|
|
9
|
+
/** A percentage, with the number of decimals written. */
|
|
10
|
+
export type Rate = Span & {
|
|
11
|
+
readonly value: number;
|
|
12
|
+
readonly decimals: number;
|
|
13
|
+
};
|
|
14
|
+
/** A word that says which way the value moved (増加, up: 1; 減少, down: -1). */
|
|
15
|
+
export type Direction = Span & {
|
|
16
|
+
readonly sign: 1 | -1;
|
|
17
|
+
};
|
|
18
|
+
/** A word that marks a value: the earlier one after it (「1,000社から」) or before it ("from 1,000"), the later one (「1,200社に」, "to 1,200"). */
|
|
19
|
+
export type BaseMark = Span & {
|
|
20
|
+
readonly position: "before" | "after";
|
|
21
|
+
};
|
|
22
|
+
export type ChangeText = {
|
|
23
|
+
readonly sentences: readonly Span[];
|
|
24
|
+
readonly figures: readonly Figure[];
|
|
25
|
+
readonly rates: readonly Rate[];
|
|
26
|
+
readonly directions: readonly Direction[];
|
|
27
|
+
readonly marks: readonly BaseMark[];
|
|
28
|
+
/** Words that mark the later value ("to", 「に」). */
|
|
29
|
+
readonly targets: readonly BaseMark[];
|
|
30
|
+
};
|
|
31
|
+
/** Each sentence with one rate of change, one direction, one marked earlier value and one other value in its unit, that disagree. */
|
|
32
|
+
export declare const changeRateMismatches: (text: ChangeText) => StructureIssue[];
|
|
33
|
+
//# sourceMappingURL=change-rate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-rate.d.ts","sourceRoot":"","sources":["../../src/structure/change-rate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,sIAAsI;AACtI,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACrG,yDAAyD;AACzD,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAChF,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;CAAE,CAAC;AACzD,2IAA2I;AAC3I,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IACpC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;CACvC,CAAC;AA8EF,qIAAqI;AACrI,eAAO,MAAM,oBAAoB,GAAI,MAAM,UAAU,KAAG,cAAc,EAAmE,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** How far a direction word may stand from the rate (「20%の増加」「20%増えました」, "an increase of 20%", "up 20%"). */
|
|
2
|
+
const DIRECTION_REACH = 8;
|
|
3
|
+
/** How far a base mark may stand from its value ("from $10" has the currency sign between). */
|
|
4
|
+
const MARK_GAP = 3;
|
|
5
|
+
/**
|
|
6
|
+
* How far the earlier value may stand from the rate (「1,000社から20%」「10億円に比べて20%」"20% from $10 million"). Further
|
|
7
|
+
* away, the rate is of something else in the sentence (「100店から120店に増え、売上は15%増えた」).
|
|
8
|
+
*/
|
|
9
|
+
const BASE_REACH = 12;
|
|
10
|
+
const PERCENT = 100;
|
|
11
|
+
const HALF = 0.5;
|
|
12
|
+
const DECIMAL_BASE = 10;
|
|
13
|
+
const within = (outer, inner) => inner.start >= outer.start && inner.end <= outer.end;
|
|
14
|
+
const distance = (left, right) => Math.max(left.start - right.end, right.start - left.end, 0);
|
|
15
|
+
const markOf = (figure, marks) => marks.find((mark) => {
|
|
16
|
+
const gap = mark.position === "after" ? mark.start - figure.end : figure.start - mark.end;
|
|
17
|
+
return gap >= 0 && gap <= MARK_GAP;
|
|
18
|
+
});
|
|
19
|
+
/** The earlier value: marked, with the value or its mark beside the rate ("up 25% compared with $1,000"). */
|
|
20
|
+
const isBaseFor = (figure, rate, marks) => {
|
|
21
|
+
const mark = markOf(figure, marks);
|
|
22
|
+
return mark !== undefined && Math.min(distance(figure, rate), distance(mark, rate)) <= BASE_REACH;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The later value is written before the rate (「1,200社となり、…20%増えました」"1,200 companies, up 20%") or marked as the
|
|
26
|
+
* value reached (「1,200社に」"to 1,200"). Another amount after the rate is about something else ("…, and revenue was $1,300").
|
|
27
|
+
*/
|
|
28
|
+
const isCurrentFor = (figure, rate, targets) => figure.end <= rate.start || markOf(figure, targets) !== undefined;
|
|
29
|
+
/** The one sign the direction words beside the rate agree on. */
|
|
30
|
+
const signNear = (rate, directions) => {
|
|
31
|
+
const signs = new Set(directions.filter((direction) => distance(direction, rate) <= DIRECTION_REACH).map((direction) => direction.sign));
|
|
32
|
+
const [sign] = signs;
|
|
33
|
+
return signs.size === 1 ? sign : undefined;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The rates of change the two values allow. Each value may be off by half the step it is written to: 12億 is anything from
|
|
37
|
+
* 11.5億 to 12.5億, so 12億 from 10億 is a rise of 9.5% to 31.6%, and only a rate outside that is a mistake.
|
|
38
|
+
*/
|
|
39
|
+
const rateRange = (base, current) => {
|
|
40
|
+
const [baseLow, baseHigh] = [base.value - base.step * HALF, base.value + base.step * HALF];
|
|
41
|
+
const [currentLow, currentHigh] = [current.value - current.step * HALF, current.value + current.step * HALF];
|
|
42
|
+
if (baseLow <= 0)
|
|
43
|
+
return undefined;
|
|
44
|
+
return [(currentLow / baseHigh - 1) * PERCENT, (currentHigh / baseLow - 1) * PERCENT];
|
|
45
|
+
};
|
|
46
|
+
const issueIn = (text, sentence) => {
|
|
47
|
+
const rates = text.rates.filter((rate) => within(sentence, rate));
|
|
48
|
+
const figures = text.figures.filter((figure) => within(sentence, figure));
|
|
49
|
+
const [rate] = rates;
|
|
50
|
+
if (rates.length !== 1 || rate === undefined)
|
|
51
|
+
return [];
|
|
52
|
+
const sign = signNear(rate, text.directions.filter((direction) => within(sentence, direction)));
|
|
53
|
+
const bases = figures.filter((figure) => isBaseFor(figure, rate, text.marks));
|
|
54
|
+
const [base] = bases;
|
|
55
|
+
if (sign === undefined || bases.length !== 1 || base === undefined)
|
|
56
|
+
return [];
|
|
57
|
+
const currents = figures.filter((figure) => figure !== base && figure.unit === base.unit && isCurrentFor(figure, rate, text.targets));
|
|
58
|
+
const [current] = currents;
|
|
59
|
+
const range = currents.length === 1 && current !== undefined ? rateRange(base, current) : undefined;
|
|
60
|
+
if (range === undefined || current === undefined)
|
|
61
|
+
return [];
|
|
62
|
+
const written = sign * rate.value;
|
|
63
|
+
const slack = HALF * DECIMAL_BASE ** -rate.decimals;
|
|
64
|
+
if (written >= range[0] - slack && written <= range[1] + slack)
|
|
65
|
+
return [];
|
|
66
|
+
const computed = Math.abs((current.value / base.value - 1) * PERCENT).toFixed(rate.decimals);
|
|
67
|
+
return [{ offset: rate.start, values: { rate: String(rate.value), computed } }];
|
|
68
|
+
};
|
|
69
|
+
/** Each sentence with one rate of change, one direction, one marked earlier value and one other value in its unit, that disagree. */
|
|
70
|
+
export const changeRateMismatches = (text) => text.sentences.flatMap((sentence) => issueIn(text, sentence));
|
|
71
|
+
//# sourceMappingURL=change-rate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-rate.js","sourceRoot":"","sources":["../../src/structure/change-rate.ts"],"names":[],"mappings":"AAyBA,6GAA6G;AAC7G,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,+FAA+F;AAC/F,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB;;;GAGG;AACH,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,IAAI,GAAG,GAAG,CAAC;AACjB,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,MAAM,GAAG,CAAC,KAAW,EAAE,KAAW,EAAW,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,K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AO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpG,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAC5D,MAAM,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;IAClC,MAAM,KAAK,GAAG,IAAI,GAAG,YAAY,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IACpD,IAAI,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK;QAAE,OAAO,EAAE,CAAC;IAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7F,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;AAClF,CAAC,CAAC;AAEF,qIAAqI;AACrI,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAgB,EAAoB,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
import type { StructureIssue } from "./issues.ts";
|
|
3
|
+
/** One item's written number: where the item starts, the number and the number as written (「4.」). */
|
|
4
|
+
export type WrittenNumber = {
|
|
5
|
+
readonly offset: number;
|
|
6
|
+
readonly number: number;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
};
|
|
9
|
+
/** The number written at the start of each item, or undefined when an item has none (a bulleted list). */
|
|
10
|
+
export declare const writtenNumbers: (source: string, itemSpans: readonly Span[]) => WrittenNumber[] | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Each item whose number is not one more than the item before it. A list that writes one number on every item (「1.」 on
|
|
13
|
+
* each, which Markdown counts up) is numbered by the renderer, not by the writer, and is not read. An item numbered 1
|
|
14
|
+
* starts a new count, as the structure rule reads a 1 that follows other items.
|
|
15
|
+
*/
|
|
16
|
+
export declare const listNumberBreaks: (items: readonly WrittenNumber[]) => StructureIssue[];
|
|
17
|
+
//# sourceMappingURL=list-numbering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-numbering.d.ts","sourceRoot":"","sources":["../../src/structure/list-numbering.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,qGAAqG;AACrG,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzG,0GAA0G;AAC1G,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,WAAW,SAAS,IAAI,EAAE,KAAG,aAAa,EAAE,GAAG,SAQ7F,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,SAAS,aAAa,EAAE,KAAG,cAAc,EAOhF,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const ITEM_NUMBER = /^(?<number>\d{1,9})(?<delimiter>[.)])[ \t]/u;
|
|
2
|
+
/** The number written at the start of each item, or undefined when an item has none (a bulleted list). */
|
|
3
|
+
export const writtenNumbers = (source, itemSpans) => {
|
|
4
|
+
const numbers = itemSpans.map((span) => {
|
|
5
|
+
const found = ITEM_NUMBER.exec(source.slice(span.start, span.end))?.groups;
|
|
6
|
+
return found === undefined
|
|
7
|
+
? undefined
|
|
8
|
+
: { offset: span.start, number: Number(found["number"]), label: `${found["number"] ?? ""}${found["delimiter"] ?? ""}` };
|
|
9
|
+
});
|
|
10
|
+
return numbers.every((entry) => entry !== undefined) ? numbers : undefined;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Each item whose number is not one more than the item before it. A list that writes one number on every item (「1.」 on
|
|
14
|
+
* each, which Markdown counts up) is numbered by the renderer, not by the writer, and is not read. An item numbered 1
|
|
15
|
+
* starts a new count, as the structure rule reads a 1 that follows other items.
|
|
16
|
+
*/
|
|
17
|
+
export const listNumberBreaks = (items) => {
|
|
18
|
+
if (new Set(items.map((item) => item.number)).size < 2)
|
|
19
|
+
return [];
|
|
20
|
+
return items.flatMap((item, index) => {
|
|
21
|
+
const previous = items[index - 1];
|
|
22
|
+
if (previous === undefined || item.number === previous.number + 1 || item.number === 1)
|
|
23
|
+
return [];
|
|
24
|
+
return [{ offset: item.offset, values: { previous: previous.label, label: item.label, expected: previous.number + 1, found: item.number } }];
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=list-numbering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-numbering.js","sourceRoot":"","sources":["../../src/structure/list-numbering.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,GAAG,6CAA6C,CAAC;AAKlE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,SAA0B,EAA+B,EAAE;IACxG,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC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AE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/I,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
import type { StructureIssue } from "./issues.ts";
|
|
3
|
+
import type { Amount } from "./total.ts";
|
|
4
|
+
import type { ShareWords } from "./percent-sum.ts";
|
|
5
|
+
/** Each sentence that names a share word and three or more unsigned percentages whose sum misses 100% by more than rounding, and by no more than BAND. */
|
|
6
|
+
export declare const proseShareMismatches: (source: string, sentences: readonly Span[], amounts: readonly Amount[], words: ShareWords) => StructureIssue[];
|
|
7
|
+
//# sourceMappingURL=percent-sum-prose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"percent-sum-prose.d.ts","sourceRoot":"","sources":["../../src/structure/percent-sum-prose.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA2CnD,0JAA0J;AAC1J,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,EAAE,WAAW,SAAS,IAAI,EAAE,EAAE,SAAS,SAAS,MAAM,EAAE,EAAE,OAAO,UAAU,KAAG,cAAc,EAI9I,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const WHOLE = 100;
|
|
2
|
+
/** A sentence names two shares in passing (「AとBで50%」); a breakdown in prose names at least three parts. */
|
|
3
|
+
const MIN_PARTS = 3;
|
|
4
|
+
/**
|
|
5
|
+
* How far from 100% a sentence may add up and still read as one whole broken down. Far below it, the sentence names only the
|
|
6
|
+
* larger parts (「Aが50%、Bが20%、Cが10%など」); far above it, the percentages are of different wholes ("55% of directors,
|
|
7
|
+
* 48% of managers") or of two periods ("45% (40% last year)"), or the total is among them (「合計100%」).
|
|
8
|
+
*/
|
|
9
|
+
const BAND = 10;
|
|
10
|
+
const HALF = 0.5;
|
|
11
|
+
const DECIMAL_BASE = 10;
|
|
12
|
+
const DECIMALS = /\.(\d+)/u;
|
|
13
|
+
/** A sign before the number (+3%, ▲2%): a change, not a part. */
|
|
14
|
+
const SIGNS = "-+−▲△";
|
|
15
|
+
const includesAny = (text, words) => {
|
|
16
|
+
const lowered = text.toLowerCase();
|
|
17
|
+
return words.some((word) => lowered.includes(word.toLowerCase()));
|
|
18
|
+
};
|
|
19
|
+
const decimalsOf = (source, amount) => DECIMALS.exec(source.slice(amount.offset, amount.end))?.[1]?.length ?? 0;
|
|
20
|
+
const isSigned = (source, amount) => SIGNS.includes(source.slice(0, amount.offset).trimEnd().at(-1) ?? " ");
|
|
21
|
+
/** The rounding the parts allow: half the last digit each, at least one point. */
|
|
22
|
+
const toleranceOf = (source, shares) => Math.max(1, shares.length * HALF * DECIMAL_BASE ** -Math.max(0, ...shares.map((share) => decimalsOf(source, share))));
|
|
23
|
+
const isBroken = (sum, tolerance) => Math.abs(sum - WHOLE) > tolerance && Math.abs(sum - WHOLE) <= BAND;
|
|
24
|
+
const issueIn = (source, sentence, percents, words) => {
|
|
25
|
+
const text = source.slice(sentence.start, sentence.end);
|
|
26
|
+
if (!includesAny(text, words.labels) || includesAny(text, words.exceptions))
|
|
27
|
+
return [];
|
|
28
|
+
const shares = percents.filter((amount) => amount.offset >= sentence.start && amount.end <= sentence.end);
|
|
29
|
+
if (shares.length < MIN_PARTS || shares.some((share) => isSigned(source, share)))
|
|
30
|
+
return [];
|
|
31
|
+
const sum = shares.reduce((total, share) => total + share.value, 0);
|
|
32
|
+
const decimals = Math.max(0, ...shares.map((share) => decimalsOf(source, share)));
|
|
33
|
+
if (!isBroken(sum, toleranceOf(source, shares)))
|
|
34
|
+
return [];
|
|
35
|
+
return [{ offset: shares[0]?.offset ?? sentence.start, values: { sum: `${sum.toFixed(decimals)}${shares[0]?.unit ?? ""}` } }];
|
|
36
|
+
};
|
|
37
|
+
/** Each sentence that names a share word and three or more unsigned percentages whose sum misses 100% by more than rounding, and by no more than BAND. */
|
|
38
|
+
export const proseShareMismatches = (source, sentences, amounts, words) => {
|
|
39
|
+
if (words.labels.length === 0)
|
|
40
|
+
return [];
|
|
41
|
+
const percents = amounts.filter((amount) => words.units.includes(amount.unit));
|
|
42
|
+
return sentences.flatMap((sentence) => issueIn(source, sentence, percents, words));
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=percent-sum-prose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"percent-sum-prose.js","sourceRoot":"","sources":["../../src/structure/percent-sum-prose.ts"],"names":[],"mappings":"AAOA,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,2GAA2G;AAC3G,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB;;;;GAIG;AACH,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,MAAM,IAAI,GAAG,GAAG,CAAC;AACjB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,iEAAiE;AACjE,MAAM,KAAK,GAAG,OAAO,CAAC;AAEtB,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,KAAwB,EAAW,EAAE;IACtE,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,MAAc,EAAU,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAA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AQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/E,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;AACrF,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StructureIssue } from "./issues.ts";
|
|
2
|
+
/** A word that makes a version a bound or a starting point, not the version installed: 「2.3.0 から」 "from 2.3.0", "20.0.0 or later". */
|
|
3
|
+
export type RangeWord = {
|
|
4
|
+
readonly word: string;
|
|
5
|
+
readonly position: "before" | "after";
|
|
6
|
+
};
|
|
7
|
+
/** What tells which versions are the block's: the bound words, and the Latin words that lead to the version installed. */
|
|
8
|
+
export type VersionWords = {
|
|
9
|
+
readonly ranges: readonly RangeWord[];
|
|
10
|
+
readonly versionWords: readonly string[];
|
|
11
|
+
};
|
|
12
|
+
/** One code block: where it starts and the text between its fences. */
|
|
13
|
+
export type CodeBlock = {
|
|
14
|
+
readonly start: number;
|
|
15
|
+
readonly code: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Each version in a code block's lead-in that differs from the one version the block shows. A block with no version, or
|
|
19
|
+
* with two (an upgrade from one to the other), says nothing to compare; a version marked as a bound, or named after another
|
|
20
|
+
* program, is not the one installed.
|
|
21
|
+
*/
|
|
22
|
+
export declare const versionMismatches: (source: string, prose: string, blocks: readonly CodeBlock[], words: VersionWords) => StructureIssue[];
|
|
23
|
+
//# sourceMappingURL=version-mismatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-mismatch.d.ts","sourceRoot":"","sources":["../../src/structure/version-mismatch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,sIAAsI;AACtI,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAA;CAAE,CAAC;AAEzF,0HAA0H;AAC1H,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/G,uEAAuE;AACvE,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAqE1E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,EAAE,QAAQ,SAAS,SAAS,EAAE,EAAE,OAAO,YAAY,KAAG,cAAc,EAU/H,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A dotted version of three parts (2.4.0, v1.12.3, 3.0.0-beta.2). Two parts (22.04, 3.1) are too often a decimal, and a
|
|
3
|
+
* first part of four digits is too often a date (2024.01.15).
|
|
4
|
+
*/
|
|
5
|
+
const VERSION = /(?<![\w.])v?(\d{1,3}\.\d{1,4}\.\d{1,4}(?:-[0-9A-Za-z.]+)?)(?![\w.]|\.\d)/gu;
|
|
6
|
+
/** How far a range word may stand from the version (a space, a "v"). */
|
|
7
|
+
const RANGE_GAP = 2;
|
|
8
|
+
const versionsIn = (text, offset = 0) => [...text.matchAll(VERSION)].map((match) => ({ start: offset + match.index, end: offset + match.index + match[0].length, version: match[1] ?? "" }));
|
|
9
|
+
const isBound = (prose, found, words) => words.some(({ word, position }) => {
|
|
10
|
+
if (word === "")
|
|
11
|
+
return false;
|
|
12
|
+
const near = position === "after"
|
|
13
|
+
? prose.slice(found.end, found.end + RANGE_GAP + word.length)
|
|
14
|
+
: prose.slice(Math.max(0, found.start - RANGE_GAP - word.length), found.start);
|
|
15
|
+
return near.toLowerCase().includes(word.toLowerCase());
|
|
16
|
+
});
|
|
17
|
+
/** The names a block pins its version to: tidyq in tidyq@2.4.0, tidyq==2.4.0, tidyq=2.4.0, tidyq:2.4.0, "tidyq": "2.4.0". */
|
|
18
|
+
const PINNED = /^([\w.-]+)(?:@|==|=|:)[v^~]?\d/u;
|
|
19
|
+
const QUOTES = /["']/gu;
|
|
20
|
+
const OPENS_WITH_NUMBER = /^[v^~]?\d/u;
|
|
21
|
+
/** Each whitespace-separated word of the code, quotes dropped; "tidyq": "2.4.0" is read as tidyq:2.4.0. */
|
|
22
|
+
const codeWords = (code) => {
|
|
23
|
+
const words = code.split(/\s+/u).map((word) => word.replaceAll(QUOTES, "").replace(/,$/u, ""));
|
|
24
|
+
return words.map((word, index) => (word.endsWith(":") && OPENS_WITH_NUMBER.test(words[index + 1] ?? "") ? `${word}${words[index + 1] ?? ""}` : word));
|
|
25
|
+
};
|
|
26
|
+
const pinnedNames = (code) => new Set(codeWords(code).flatMap((word) => PINNED.exec(word)?.[1]?.toLowerCase() ?? []));
|
|
27
|
+
const LATIN = /^[A-Za-z]/u;
|
|
28
|
+
const WORD_CHAR = /[\w.+-]/u;
|
|
29
|
+
/** How far back the word before a version is looked for. */
|
|
30
|
+
const WORD_REACH = 40;
|
|
31
|
+
/** The Latin word right before a position, if the word there is Latin: "Node.js" in "Requires Node.js 18.17.0". */
|
|
32
|
+
const latinWordBefore = (text) => {
|
|
33
|
+
const last = [...(text.trimEnd().split(/\s/u).at(-1) ?? "")];
|
|
34
|
+
const word = last.slice(0, last.findLastIndex((char) => WORD_CHAR.test(char)) + 1).join("");
|
|
35
|
+
return LATIN.test(word) ? word.toLowerCase() : undefined;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Whether a lead-in version is about the block's software. A Latin word right before it must be one of the words that lead
|
|
39
|
+
* to the version installed (version, release, install; lexicon version-lead) or the pinned software: "Requires Node.js
|
|
40
|
+
* 18.17.0" over `npm install pkg@2.4.0` names another program. A version after no Latin word (「npm から 2.3.0」) is the block's.
|
|
41
|
+
*/
|
|
42
|
+
const isAboutBlock = (prose, found, names, versionWords) => {
|
|
43
|
+
const word = latinWordBefore(prose.slice(Math.max(0, found.start - WORD_REACH), found.start));
|
|
44
|
+
return word === undefined || names.has(word) || versionWords.some((name) => name.toLowerCase() === word);
|
|
45
|
+
};
|
|
46
|
+
const BLANK_LINE = /\r?\n[ \t]*\r?\n/gu;
|
|
47
|
+
const NOT_PROSE = /^\s*(?:#|[-*+]\s|\d{1,3}[.)]\s|```|~~~|\|)/u;
|
|
48
|
+
const LETTER = /\p{L}/u;
|
|
49
|
+
/** The paragraph right above a code block: the lines up to the blank line before it. A heading, a list item, a table or a bare version above is not a lead-in. */
|
|
50
|
+
const leadInOf = (source, blockStart) => {
|
|
51
|
+
const lines = source.slice(0, blockStart).trimEnd();
|
|
52
|
+
const last = [...lines.matchAll(BLANK_LINE)].at(-1);
|
|
53
|
+
const start = last === undefined ? 0 : last.index + last[0].length;
|
|
54
|
+
const text = lines.slice(start);
|
|
55
|
+
const words = text.replace(VERSION, "");
|
|
56
|
+
return text === "" || NOT_PROSE.test(text) || !LETTER.test(words) ? undefined : { start, end: lines.length };
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Each version in a code block's lead-in that differs from the one version the block shows. A block with no version, or
|
|
60
|
+
* with two (an upgrade from one to the other), says nothing to compare; a version marked as a bound, or named after another
|
|
61
|
+
* program, is not the one installed.
|
|
62
|
+
*/
|
|
63
|
+
export const versionMismatches = (source, prose, blocks, words) => blocks.flatMap((block) => {
|
|
64
|
+
const shown = [...new Set(versionsIn(block.code).map((found) => found.version))];
|
|
65
|
+
const leadIn = leadInOf(source, block.start);
|
|
66
|
+
const [code] = shown;
|
|
67
|
+
if (shown.length !== 1 || code === undefined || leadIn === undefined)
|
|
68
|
+
return [];
|
|
69
|
+
const names = pinnedNames(block.code);
|
|
70
|
+
return versionsIn(prose.slice(leadIn.start, leadIn.end), leadIn.start)
|
|
71
|
+
.filter((found) => found.version !== code && !isBound(prose, found, words.ranges) && isAboutBlock(prose, found, names, words.versionWords))
|
|
72
|
+
.map((found) => ({ offset: found.start, values: { written: found.version, code } }));
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=version-mismatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-mismatch.js","sourceRoot":"","sources":["../../src/structure/version-mismatch.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,GAAG,4EAA4E,CAAC;AAW7F,wEAAwE;AACxE,MAAM,SAAS,GAAG,CAAC,CAAC;AAIpB,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,MAAM,GAAG,CAAC,EAAW,EAAE,CACvD,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AAEtJ,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,KAAW,EAAE,KAA2B,EAAW,EAAE,CACnF,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IAChC,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAC9B,MAAM,IAAI,GACR,QAAQ,KAAK,OAAO;QAClB,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,K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,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACjF,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACrB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAChF,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;SACnE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;SAC1I,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AACzF,CAAC,CAAC,CAAC"}
|
|
@@ -2,6 +2,25 @@ import type { StructureNode } from "../plugin.ts";
|
|
|
2
2
|
import type { StructureIssue } from "./issues.ts";
|
|
3
3
|
/** 暦の曜日。日曜日が 0。存在しない日(2月30日)は undefined。 */
|
|
4
4
|
export declare const weekdayOf: (value: string) => number | undefined;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 年の無い月日(「10-09」)に、年を書いた日付(anchor、「2026-10-06」)の前後の年のうち、anchor から 5 か月以内に収まる年を付ける。
|
|
7
|
+
* メールや議事録は、文書の日付の年を書いて、そのあとの日付の年を省く。12月の文書の「1月5日」は翌年。どの年も収まらなければ undefined。
|
|
8
|
+
*/
|
|
9
|
+
export declare const withNearestYear: (monthDay: string, anchor: string) => string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* 年の無い日付の年を決める手がかり。stamp は文書の日付(「更新日:」の段落など)、sectionStarts は見出しで分けた節の始まり、
|
|
12
|
+
* yearHeadings はそのうち見出しが年を名指す節(「## 2024年度」)の始まり。anchorable は、年を決めるのに使ってよい日付か
|
|
13
|
+
* (引用符で日付だけを挙げた例は使わない)。
|
|
14
|
+
*/
|
|
15
|
+
export type YearContext = {
|
|
16
|
+
readonly stamp?: string | undefined;
|
|
17
|
+
readonly sectionStarts: readonly number[];
|
|
18
|
+
readonly yearHeadings?: readonly number[];
|
|
19
|
+
readonly anchorable?: (node: StructureNode) => boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 書いた曜日が暦と違う日付。年の無い日付は、年を書いた日付(anchorOf)から 5 か月以内に収まる年として比べる。
|
|
23
|
+
* 年を書いた日付が文書に無いか、どの年も収まらなければ、曜日を決められないので見ない。
|
|
24
|
+
*/
|
|
25
|
+
export declare const weekdayMismatches: (tree: StructureNode, context?: YearContext) => StructureIssue[];
|
|
7
26
|
//# sourceMappingURL=weekday.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weekday.d.ts","sourceRoot":"","sources":["../../src/structure/weekday.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"weekday.d.ts","sourceRoot":"","sources":["../../src/structure/weekday.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,4CAA4C;AAC5C,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,SAMlD,CAAC;AAWF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,SAW3E,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC;CACxD,CAAC;AAgCF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,aAAa,EAAE,UAAS,WAAmC,KAAG,cAAc,EAWnH,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { inDocumentOrder } from "./issues.js";
|
|
2
2
|
// 日付と、その横に書いた曜日の食い違い。暦で決まるので、両方読めれば誤りは機械で言える。
|
|
3
3
|
const FULL_DATE = /^(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})$/u;
|
|
4
|
+
const MONTH_DAY = /^(?<m>\d{2})-(?<d>\d{2})$/u;
|
|
4
5
|
/** 暦の曜日。日曜日が 0。存在しない日(2月30日)は undefined。 */
|
|
5
6
|
export const weekdayOf = (value) => {
|
|
6
7
|
const groups = FULL_DATE.exec(value)?.groups;
|
|
@@ -10,12 +11,73 @@ export const weekdayOf = (value) => {
|
|
|
10
11
|
const date = new Date(Date.UTC(year, month - 1, day));
|
|
11
12
|
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day ? date.getUTCDay() : undefined;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const DAY_MS = 86_400_000;
|
|
15
|
+
/** 年を書いた日付から 5 か月以内なら、前後の年のどれか一つだけがそこに収まる。半年を超えると、どちらの年とも読める。 */
|
|
16
|
+
const YEAR_REACH_DAYS = 153;
|
|
17
|
+
const timeOf = (value) => {
|
|
18
|
+
const groups = FULL_DATE.exec(value)?.groups;
|
|
19
|
+
return groups === undefined || weekdayOf(value) === undefined ? undefined : Date.UTC(Number(groups["y"]), Number(groups["m"]) - 1, Number(groups["d"]));
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 年の無い月日(「10-09」)に、年を書いた日付(anchor、「2026-10-06」)の前後の年のうち、anchor から 5 か月以内に収まる年を付ける。
|
|
23
|
+
* メールや議事録は、文書の日付の年を書いて、そのあとの日付の年を省く。12月の文書の「1月5日」は翌年。どの年も収まらなければ undefined。
|
|
24
|
+
*/
|
|
25
|
+
export const withNearestYear = (monthDay, anchor) => {
|
|
26
|
+
const groups = MONTH_DAY.exec(monthDay)?.groups;
|
|
27
|
+
const anchorYear = FULL_DATE.exec(anchor)?.groups?.["y"];
|
|
28
|
+
const anchorTime = timeOf(anchor);
|
|
29
|
+
if (groups === undefined || anchorYear === undefined || anchorTime === undefined)
|
|
30
|
+
return undefined;
|
|
31
|
+
return [-1, 0, 1]
|
|
32
|
+
.map((offset) => `${String(Number(anchorYear) + offset)}-${groups["m"] ?? ""}-${groups["d"] ?? ""}`)
|
|
33
|
+
.find((candidate) => {
|
|
34
|
+
const time = timeOf(candidate);
|
|
35
|
+
return time !== undefined && Math.abs(time - anchorTime) <= YEAR_REACH_DAYS * DAY_MS;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const sectionOf = (starts, offset) => starts.filter((start) => start <= offset).length;
|
|
39
|
+
/** 文書の書き出し: 最初の見出しより前と、最初の見出しの節。メールや議事録の頭の日付(日付:、日時:)が書かれる所。 */
|
|
40
|
+
const OPENING_SECTIONS = 1;
|
|
41
|
+
/**
|
|
42
|
+
* 年の無い日付の年を決める、年を書いた日付。同じ節のすぐ前のもの(前に無ければ後ろの最初のもの)。節に無ければ文書の日付、
|
|
43
|
+
* それも無ければ書き出しの最初の日付。年度ごとの見出しの下の「1月24日(火)」はその節の年で読み、別の節の日付の年では読まない。
|
|
44
|
+
*/
|
|
45
|
+
const anchorOf = (dated, node, context) => {
|
|
46
|
+
const section = sectionOf(context.sectionStarts, node.span.start);
|
|
47
|
+
const inSection = dated.filter((other) => sectionOf(context.sectionStarts, other.span.start) === section);
|
|
48
|
+
const nearest = inSection.findLast((other) => other.span.start < node.span.start) ?? inSection[0];
|
|
49
|
+
// 見出しが年を名指す節(「## 2024年度」)の日付は、その年の中にある。節の外の日付からは決めない。
|
|
50
|
+
const sectionStart = context.sectionStarts[section - 1];
|
|
51
|
+
if (nearest === undefined && sectionStart !== undefined && (context.yearHeadings ?? []).includes(sectionStart))
|
|
52
|
+
return undefined;
|
|
53
|
+
const opening = dated.find((other) => sectionOf(context.sectionStarts, other.span.start) <= OPENING_SECTIONS);
|
|
54
|
+
const stamp = context.stamp !== undefined && FULL_DATE.test(context.stamp) ? context.stamp : undefined;
|
|
55
|
+
const fromTree = (found) => (found === undefined ? undefined : String(found.attrs["value"]));
|
|
56
|
+
return fromTree(nearest) ?? stamp ?? fromTree(opening);
|
|
57
|
+
};
|
|
58
|
+
/** 日付の年月日。年の無い日付は、近くの年を書いた日付から年を決めて付ける。決まらなければ undefined。 */
|
|
59
|
+
const fullValueOf = (dated, node, context) => {
|
|
60
|
+
const value = String(node.attrs["value"]);
|
|
61
|
+
if (!MONTH_DAY.test(value))
|
|
62
|
+
return value;
|
|
63
|
+
const anchor = anchorOf(dated, node, context);
|
|
64
|
+
return anchor === undefined ? undefined : withNearestYear(value, anchor);
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 書いた曜日が暦と違う日付。年の無い日付は、年を書いた日付(anchorOf)から 5 か月以内に収まる年として比べる。
|
|
68
|
+
* 年を書いた日付が文書に無いか、どの年も収まらなければ、曜日を決められないので見ない。
|
|
69
|
+
*/
|
|
70
|
+
export const weekdayMismatches = (tree, context = { sectionStarts: [] }) => {
|
|
71
|
+
const dates = inDocumentOrder(tree).filter((node) => node.kind === "date");
|
|
72
|
+
const anchorable = context.anchorable ?? (() => true);
|
|
73
|
+
const dated = dates.filter((node) => timeOf(String(node.attrs["value"])) !== undefined && anchorable(node));
|
|
74
|
+
return dates.flatMap((node) => {
|
|
75
|
+
const written = node.attrs["weekday"];
|
|
76
|
+
if (typeof written !== "number")
|
|
77
|
+
return [];
|
|
78
|
+
const value = fullValueOf(dated, node, context);
|
|
79
|
+
const actual = value === undefined ? undefined : weekdayOf(value);
|
|
80
|
+
return value === undefined || actual === undefined || actual === written ? [] : [{ offset: node.span.start, values: { date: value, written, actual } }];
|
|
81
|
+
});
|
|
82
|
+
};
|
|
21
83
|
//# sourceMappingURL=weekday.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weekday.js","sourceRoot":"","sources":["../../src/structure/weekday.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,8CAA8C;AAE9C,MAAM,SAAS,GAAG,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"weekday.js","sourceRoot":"","sources":["../../src/structure/weekday.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,8CAA8C;AAE9C,MAAM,SAAS,GAAG,wCAAwC,CAAC;AAC3D,MAAM,SAAS,GAAG,4BAA4B,CAAC;AAE/C,4CAA4C;AAC5C,MAAM,CAAC,MAAM,SAAS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IAC5G,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAClE,OAAO,KAAK,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1J,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chaffjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Prose validation harness. Finds what is hard to read, and never rewrites it for you.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chaff",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@anthropic-ai/sdk": "^0.125.0",
|
|
90
|
-
"@chaffjs/lang-en": "0.
|
|
91
|
-
"@chaffjs/lang-ja": "0.
|
|
90
|
+
"@chaffjs/lang-en": "0.24.0",
|
|
91
|
+
"@chaffjs/lang-ja": "0.26.0",
|
|
92
92
|
"mdast-util-from-markdown": "^2.0.3",
|
|
93
93
|
"mdast-util-frontmatter": "^2.0.1",
|
|
94
94
|
"mdast-util-gfm-table": "^2.0.0",
|
|
@@ -5,7 +5,7 @@ how_to_find: agreement-slip
|
|
|
5
5
|
requires: [pos]
|
|
6
6
|
languages: [en]
|
|
7
7
|
extra_word_lists: [singular-determiner, plural-determiner, invariant-noun, count-adjective, dependent-possessive, finite-auxiliary, misnumbered-phrase]
|
|
8
|
-
severity:
|
|
8
|
+
severity: info
|
|
9
9
|
|
|
10
10
|
name:
|
|
11
11
|
ja: 語の形が合っていない
|
|
@@ -31,7 +31,7 @@ how_to_fix:
|
|
|
31
31
|
ja: 限定詞か名詞のどちらかに揃えてください(a significant change / significant changes)。所有の語なら、主語の語に直してください(Your can → You can、their is → there is)。
|
|
32
32
|
en: Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their is" becomes "there is").
|
|
33
33
|
|
|
34
|
-
levels: { strict:
|
|
34
|
+
levels: { strict: warning, normal: info, relaxed: info }
|
|
35
35
|
|
|
36
36
|
use_for: [blog, business, technical, legal, docs, academic, literature, speech]
|
|
37
37
|
off_for:
|