chaffjs 0.2.0 → 0.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/dist/backends/anthropic.d.ts +24 -0
- package/dist/backends/anthropic.d.ts.map +1 -0
- package/dist/backends/anthropic.js +44 -0
- package/dist/backends/anthropic.js.map +1 -0
- package/dist/backends/openai.d.ts +29 -0
- package/dist/backends/openai.d.ts.map +1 -0
- package/dist/backends/openai.js +33 -0
- package/dist/backends/openai.js.map +1 -0
- package/dist/backends/types.d.ts +32 -0
- package/dist/backends/types.d.ts.map +1 -0
- package/dist/backends/types.js +18 -0
- package/dist/backends/types.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +8 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/eval.d.ts.map +1 -1
- package/dist/commands/eval.js +4 -1
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +60 -14
- package/dist/commands/test.js.map +1 -1
- package/dist/config/load.d.ts +4 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +10 -3
- package/dist/config/load.js.map +1 -1
- package/dist/detectors/agentless-passive.d.ts +3 -0
- package/dist/detectors/agentless-passive.d.ts.map +1 -0
- package/dist/detectors/agentless-passive.js +31 -0
- package/dist/detectors/agentless-passive.js.map +1 -0
- package/dist/detectors/char-shape.d.ts +12 -0
- package/dist/detectors/char-shape.d.ts.map +1 -0
- package/dist/detectors/char-shape.js +39 -0
- package/dist/detectors/char-shape.js.map +1 -0
- package/dist/detectors/en-shape.d.ts +19 -0
- package/dist/detectors/en-shape.d.ts.map +1 -0
- package/dist/detectors/en-shape.js +176 -0
- package/dist/detectors/en-shape.js.map +1 -0
- package/dist/detectors/index.d.ts.map +1 -1
- package/dist/detectors/index.js +33 -0
- package/dist/detectors/index.js.map +1 -1
- package/dist/detectors/lexicon.d.ts +15 -0
- package/dist/detectors/lexicon.d.ts.map +1 -0
- package/dist/detectors/lexicon.js +109 -0
- package/dist/detectors/lexicon.js.map +1 -0
- package/dist/detectors/repeated-head.d.ts.map +1 -1
- package/dist/detectors/repeated-head.js +17 -5
- package/dist/detectors/repeated-head.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts +3 -0
- package/dist/detectors/sentence-ending.d.ts.map +1 -0
- package/dist/detectors/sentence-ending.js +34 -0
- package/dist/detectors/sentence-ending.js.map +1 -0
- package/dist/detectors/signals.d.ts +6 -0
- package/dist/detectors/signals.d.ts.map +1 -0
- package/dist/detectors/signals.js +183 -0
- package/dist/detectors/signals.js.map +1 -0
- package/dist/detectors/structure.d.ts +24 -0
- package/dist/detectors/structure.d.ts.map +1 -0
- package/dist/detectors/structure.js +111 -0
- package/dist/detectors/structure.js.map +1 -0
- package/dist/detectors/token-shape.d.ts +4 -0
- package/dist/detectors/token-shape.d.ts.map +1 -0
- package/dist/detectors/token-shape.js +62 -0
- package/dist/detectors/token-shape.js.map +1 -0
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +76 -8
- package/dist/document.js.map +1 -1
- package/dist/env.d.ts +12 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +20 -0
- package/dist/env.js.map +1 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +9 -6
- package/dist/init.js.map +1 -1
- package/dist/judge.d.ts +14 -16
- package/dist/judge.d.ts.map +1 -1
- package/dist/judge.js +0 -0
- package/dist/judge.js.map +1 -1
- package/dist/levels.d.ts +1 -9
- package/dist/levels.d.ts.map +1 -1
- package/dist/levels.js +15 -3
- package/dist/levels.js.map +1 -1
- package/dist/look-at.d.ts +18 -0
- package/dist/look-at.d.ts.map +1 -0
- package/dist/look-at.js +43 -0
- package/dist/look-at.js.map +1 -0
- package/dist/plugin.d.ts +44 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/render/explain.d.ts +1 -1
- package/dist/render/explain.d.ts.map +1 -1
- package/dist/render/explain.js +12 -4
- package/dist/render/explain.js.map +1 -1
- package/dist/render/rules-json.d.ts.map +1 -1
- package/dist/render/rules-json.js +13 -5
- package/dist/render/rules-json.js.map +1 -1
- package/dist/render/semantic.d.ts +2 -1
- package/dist/render/semantic.d.ts.map +1 -1
- package/dist/render/semantic.js +35 -0
- package/dist/render/semantic.js.map +1 -1
- package/dist/rule-load.d.ts.map +1 -1
- package/dist/rule-load.js +27 -1
- package/dist/rule-load.js.map +1 -1
- package/dist/run-semantic.d.ts +22 -1
- package/dist/run-semantic.d.ts.map +1 -1
- package/dist/run-semantic.js +21 -10
- package/dist/run-semantic.js.map +1 -1
- package/dist/run.d.ts +6 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +34 -2
- package/dist/run.js.map +1 -1
- package/dist/sentence-shape.d.ts +6 -0
- package/dist/sentence-shape.d.ts.map +1 -0
- package/dist/sentence-shape.js +15 -0
- package/dist/sentence-shape.js.map +1 -0
- package/package.json +4 -3
- package/rules/adverb-overuse.yaml +28 -0
- package/rules/agentless-passive.yaml +28 -0
- package/rules/ai-tell.yaml +27 -0
- package/rules/concrete-evidence-density.yaml +25 -0
- package/rules/cushion-phrase-density.yaml +26 -0
- package/rules/double-keigo.yaml +27 -0
- package/rules/emoji-density.yaml +26 -0
- package/rules/excessive-hedging.yaml +26 -0
- package/rules/expletive-construction.yaml +27 -0
- package/rules/hiragana-fukushi.yaml +27 -0
- package/rules/max-kanji-continuous.yaml +26 -0
- package/rules/max-paragraph-length.yaml +25 -0
- package/rules/max-sentence-length.yaml +22 -0
- package/rules/ngram-repetition.yaml +25 -0
- package/rules/no-doubled-joshi.yaml +28 -0
- package/rules/no-mixed-desumasu.yaml +29 -0
- package/rules/no-nakaguro-parallel.yaml +27 -0
- package/rules/oxford-comma-consistency.yaml +26 -0
- package/rules/paragraph-length-variance.yaml +25 -0
- package/rules/preamble-length.yaml +25 -0
- package/rules/repeated-conjunction.yaml +26 -0
- package/rules/rule-of-three.yaml +25 -0
- package/rules/sasete-itadaku.yaml +27 -0
- package/rules/section-length-uniformity.yaml +25 -0
- package/rules/sentence-initial-conjunction-run.yaml +27 -0
- package/rules/taigen-dome-in-prose.yaml +27 -0
- package/rules/title-case-consistency.yaml +26 -0
- package/rules/undefined-acronym.yaml +25 -0
- package/rules/unqualified-superlative.yaml +26 -0
- package/src/backends/anthropic.ts +61 -0
- package/src/backends/openai.ts +46 -0
- package/src/backends/types.ts +38 -0
- package/src/cli.ts +8 -4
- package/src/commands/eval.ts +4 -1
- package/src/commands/test.ts +72 -14
- package/src/config/load.ts +11 -3
- package/src/detectors/agentless-passive.ts +34 -0
- package/src/detectors/char-shape.ts +47 -0
- package/src/detectors/en-shape.ts +187 -0
- package/src/detectors/index.ts +33 -0
- package/src/detectors/lexicon.ts +124 -0
- package/src/detectors/repeated-head.ts +17 -6
- package/src/detectors/sentence-ending.ts +37 -0
- package/src/detectors/signals.ts +199 -0
- package/src/detectors/structure.ts +119 -0
- package/src/detectors/token-shape.ts +81 -0
- package/src/document.ts +81 -9
- package/src/env.ts +20 -0
- package/src/init.ts +9 -6
- package/src/judge.ts +0 -0
- package/src/levels.ts +16 -4
- package/src/look-at.ts +53 -0
- package/src/plugin.ts +45 -3
- package/src/render/explain.ts +12 -4
- package/src/render/rules-json.ts +16 -5
- package/src/render/semantic.ts +38 -1
- package/src/rule-load.ts +28 -1
- package/src/run-semantic.ts +32 -11
- package/src/run.ts +36 -3
- package/src/sentence-shape.ts +22 -0
package/dist/config/load.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/config/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":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
|
|
|
1
|
+
{"version":3,"file":"agentless-passive.d.ts","sourceRoot":"","sources":["../../src/detectors/agentless-passive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA4B,MAAM,cAAc,CAAC;AAevE,eAAO,MAAM,gBAAgB,EAAE,QAkB9B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 受動のまま動作主を書かないと、誰がしたのかが文から消える。
|
|
3
|
+
* 「決定されました」は、決めた人を名指さずに決定を伝える。
|
|
4
|
+
*
|
|
5
|
+
* 受動かどうかはアダプタが Voice=Pass で印を付ける。日本語の「れる/られる」と
|
|
6
|
+
* 英語の be + 過去分詞は形が全く違うので、その判断は言語の側に置く。spec §12.1。
|
|
7
|
+
* 「名詞を修飾しているだけか」の判断も、語順が言語で逆になるため同じくアダプタ側。
|
|
8
|
+
* 動作主の語(によって / by)も言語ごとの語彙表から引く。detector は言語を知らない。
|
|
9
|
+
*/
|
|
10
|
+
const isPassive = (token) => token.features?.["Voice"] === "Pass";
|
|
11
|
+
const hasAgent = (sentence, markers) => markers.some((marker) => sentence.text.includes(marker));
|
|
12
|
+
export const agentlessPassive = (doc, options) => {
|
|
13
|
+
const markers = (options.lexicon ?? []).map((entry) => entry.pattern);
|
|
14
|
+
return doc.sentences
|
|
15
|
+
.map((sentence) => ({ sentence, passives: (sentence.tokens ?? []).filter(isPassive) }))
|
|
16
|
+
.filter(({ sentence, passives }) => passives.length >= options.limit && !hasAgent(sentence, markers))
|
|
17
|
+
.map(({ sentence, passives }) => ({
|
|
18
|
+
rule: "agentless-passive",
|
|
19
|
+
severity: "warning",
|
|
20
|
+
line: 0,
|
|
21
|
+
column: 0,
|
|
22
|
+
quote: sentence.text.trim(),
|
|
23
|
+
values: {
|
|
24
|
+
count: passives.length,
|
|
25
|
+
limit: options.limit,
|
|
26
|
+
word: passives.map((token) => token.surface).join(" "),
|
|
27
|
+
offset: passives[0]?.span.start ?? sentence.span.start,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,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;QAC3B,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ,CAAC,MAAM;YACtB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACtD,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK;SACvD;KACF,CAAC,CAAC,CAAC;AACR,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Detector } from "../plugin.ts";
|
|
2
|
+
/**
|
|
3
|
+
* 漢字が続くと、どこで語が切れるのか読み手が探すことになる。
|
|
4
|
+
* 「情報処理推進機構認定試験」は 12 字。ひらがなを 1 つ挟むだけで読める。
|
|
5
|
+
*/
|
|
6
|
+
export declare const kanjiRun: Detector;
|
|
7
|
+
/**
|
|
8
|
+
* 中黒で並べると、どこまでが 1 つの項目か分からなくなる。
|
|
9
|
+
* 「企画・開発・運用・保守体制」は、保守体制が 1 つなのか保守と体制なのか読めない。
|
|
10
|
+
*/
|
|
11
|
+
export declare const middleDot: Detector;
|
|
12
|
+
//# sourceMappingURL=char-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"char-shape.d.ts","sourceRoot":"","sources":["../../src/detectors/char-shape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,cAAc,CAAC;AAYhE;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,QAWhB,CAAC;AAIR;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,QAWjB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { proseText } from "../measure.js";
|
|
2
|
+
/**
|
|
3
|
+
* 文字の並びだけを見る検出。品詞も語彙表も要らない。
|
|
4
|
+
* 覆った箇所は空白になっているので、proseText で潰してから数える。
|
|
5
|
+
*/
|
|
6
|
+
const KANJI_RUN = /[一-鿿]+/gu;
|
|
7
|
+
const longestKanji = (sentence) => [...proseText(sentence).matchAll(KANJI_RUN)].reduce((longest, match) => (match[0].length > longest.length ? match[0] : longest), "");
|
|
8
|
+
/**
|
|
9
|
+
* 漢字が続くと、どこで語が切れるのか読み手が探すことになる。
|
|
10
|
+
* 「情報処理推進機構認定試験」は 12 字。ひらがなを 1 つ挟むだけで読める。
|
|
11
|
+
*/
|
|
12
|
+
export const kanjiRun = (doc, options) => doc.sentences
|
|
13
|
+
.map((sentence) => ({ sentence, run: longestKanji(sentence) }))
|
|
14
|
+
.filter(({ run }) => run.length > options.limit)
|
|
15
|
+
.map(({ sentence, run }) => ({
|
|
16
|
+
rule: "max-kanji-continuous",
|
|
17
|
+
severity: "warning",
|
|
18
|
+
line: 0,
|
|
19
|
+
column: 0,
|
|
20
|
+
quote: sentence.text.trim(),
|
|
21
|
+
values: { word: run, count: run.length, limit: options.limit, offset: sentence.span.start },
|
|
22
|
+
}));
|
|
23
|
+
const MIDDLE_DOT = /・/gu;
|
|
24
|
+
/**
|
|
25
|
+
* 中黒で並べると、どこまでが 1 つの項目か分からなくなる。
|
|
26
|
+
* 「企画・開発・運用・保守体制」は、保守体制が 1 つなのか保守と体制なのか読めない。
|
|
27
|
+
*/
|
|
28
|
+
export const middleDot = (doc, options) => doc.sentences
|
|
29
|
+
.map((sentence) => ({ sentence, count: [...proseText(sentence).matchAll(MIDDLE_DOT)].length }))
|
|
30
|
+
.filter(({ count }) => count > options.limit)
|
|
31
|
+
.map(({ sentence, count }) => ({
|
|
32
|
+
rule: "no-nakaguro-parallel",
|
|
33
|
+
severity: "info",
|
|
34
|
+
line: 0,
|
|
35
|
+
column: 0,
|
|
36
|
+
quote: sentence.text.trim(),
|
|
37
|
+
values: { count, limit: options.limit, offset: sentence.span.start },
|
|
38
|
+
}));
|
|
39
|
+
//# sourceMappingURL=char-shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"char-shape.js","sourceRoot":"","sources":["../../src/detectors/char-shape.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;;GAGG;AACH,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,MAAM,YAAY,GAAG,CAAC,QAAkB,EAAU,EAAE,CAClD,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;AAEvI;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAa,CAAC,GAAG,EAAE,OAAO,EAAa,EAAE,CAC5D,GAAG,CAAC,SAAS;KACV,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;KAC9D,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;KAC/C,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3B,IAAI,EAAE,sBAAsB;IAC5B,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;IAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;CAC5F,CAAC,CAAC,CAAC;AAER,MAAM,UAAU,GAAG,KAAK,CAAC;AAEzB;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAa,CAAC,GAAG,EAAE,OAAO,EAAa,EAAE,CAC7D,GAAG,CAAC,SAAS;KACV,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;KAC9F,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;KAC5C,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7B,IAAI,EAAE,sBAAsB;IAC5B,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;IAC3B,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;CACrE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Detector } from "../plugin.ts";
|
|
2
|
+
/**
|
|
3
|
+
* -ly 副詞は、動詞が弱いことの目印になる。「walked quickly」より「hurried」。
|
|
4
|
+
* 1 つずつは正しいので、件数ではなく密度で見る(bold-density と同じ)。
|
|
5
|
+
*/
|
|
6
|
+
export declare const adverbDensity: Detector;
|
|
7
|
+
export declare const expletive: Detector;
|
|
8
|
+
/**
|
|
9
|
+
* 接続詞で始まる文が続く。1 つなら効くが、続くと文が前の文の付け足しに見えて、
|
|
10
|
+
* 何が主張なのかが分からなくなる。
|
|
11
|
+
*/
|
|
12
|
+
export declare const conjunctionRun: Detector;
|
|
13
|
+
/**
|
|
14
|
+
* 見出しの大文字化が混ざっている。どちらの流儀が正しいかは決めない。spec §12.3。
|
|
15
|
+
* 見るのは文書の中で揃っているかだけで、少数派のほうを指摘する。
|
|
16
|
+
*/
|
|
17
|
+
export declare const titleCaseMix: Detector;
|
|
18
|
+
export declare const oxfordComma: Detector;
|
|
19
|
+
//# sourceMappingURL=en-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en-shape.d.ts","sourceRoot":"","sources":["../../src/detectors/en-shape.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAoD,MAAM,cAAc,CAAC;AAW/F;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,QAgB3B,CAAC;AAoBF,eAAO,MAAM,SAAS,EAAE,QAcvB,CAAC;AAQF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,QA2B5B,CAAC;AAqBF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,QAgB1B,CAAC;AAoBF,eAAO,MAAM,WAAW,EAAE,QAmBzB,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { lengthOf } from "../measure.js";
|
|
2
|
+
import { isClosed } from "../sentence-shape.js";
|
|
3
|
+
const PER = 1000;
|
|
4
|
+
/** これより短い文書では密度が暴れる。1 語で「1000 語あたり 100」になる。 */
|
|
5
|
+
const MIN_WORDS = 200;
|
|
6
|
+
const wordsIn = (doc) => doc.sentences.reduce((sum, sentence) => sum + lengthOf(sentence, "word"), 0);
|
|
7
|
+
const isLyAdverb = (token) => token.pos === "ADV" && token.surface.toLowerCase().endsWith("ly");
|
|
8
|
+
/**
|
|
9
|
+
* -ly 副詞は、動詞が弱いことの目印になる。「walked quickly」より「hurried」。
|
|
10
|
+
* 1 つずつは正しいので、件数ではなく密度で見る(bold-density と同じ)。
|
|
11
|
+
*/
|
|
12
|
+
export const adverbDensity = (doc, options) => {
|
|
13
|
+
const words = wordsIn(doc);
|
|
14
|
+
const hits = doc.sentences.flatMap((sentence) => (sentence.tokens ?? []).filter(isLyAdverb).map((token) => ({ sentence, token })));
|
|
15
|
+
const density = words === 0 ? 0 : Math.round((hits.length / words) * PER);
|
|
16
|
+
const first = hits[0];
|
|
17
|
+
if (words < MIN_WORDS || first === undefined || density <= options.limit)
|
|
18
|
+
return [];
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
rule: "adverb-overuse",
|
|
22
|
+
severity: "info",
|
|
23
|
+
line: 0,
|
|
24
|
+
column: 0,
|
|
25
|
+
quote: first.sentence.text.trim(),
|
|
26
|
+
values: { count: hits.length, density, words, limit: options.limit, offset: first.token.span.start },
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
};
|
|
30
|
+
const BE = new Set(["be", "is", "are", "was", "were"]);
|
|
31
|
+
/**
|
|
32
|
+
* There is / It is ... that は、主語を後ろへ押しやって誰が何をするのかを消す。
|
|
33
|
+
* 「There is a need to review」は、誰が必要としているのかを言っていない。
|
|
34
|
+
*/
|
|
35
|
+
const expletiveAt = (tokens) => {
|
|
36
|
+
const head = tokens.find((token) => token.pos !== "PUNCT");
|
|
37
|
+
if (head === undefined)
|
|
38
|
+
return undefined;
|
|
39
|
+
const lead = head.surface.toLowerCase();
|
|
40
|
+
if (lead !== "there" && lead !== "it")
|
|
41
|
+
return undefined;
|
|
42
|
+
const next = tokens.find((token) => token.span.start >= head.span.end && token.pos !== "PUNCT");
|
|
43
|
+
if (next === undefined || !BE.has(next.lemma ?? next.surface.toLowerCase()))
|
|
44
|
+
return undefined;
|
|
45
|
+
// "it is" は "it is raining" のような正当な用法があるので、that 節を伴うときだけ数える。
|
|
46
|
+
if (lead === "it" && !tokens.some((token) => token.surface.toLowerCase() === "that"))
|
|
47
|
+
return undefined;
|
|
48
|
+
return head;
|
|
49
|
+
};
|
|
50
|
+
export const expletive = (doc, options) => {
|
|
51
|
+
const hits = doc.sentences.flatMap((sentence) => {
|
|
52
|
+
const at = expletiveAt(sentence.tokens ?? []);
|
|
53
|
+
return at === undefined ? [] : [{ sentence, at }];
|
|
54
|
+
});
|
|
55
|
+
if (hits.length <= options.limit)
|
|
56
|
+
return [];
|
|
57
|
+
return hits.map(({ sentence, at }) => ({
|
|
58
|
+
rule: "expletive-construction",
|
|
59
|
+
severity: "info",
|
|
60
|
+
line: 0,
|
|
61
|
+
column: 0,
|
|
62
|
+
quote: sentence.text.trim(),
|
|
63
|
+
values: { word: at.surface, count: hits.length, limit: options.limit, offset: at.span.start },
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
const firstWord = (sentence) => sentence.text
|
|
67
|
+
.trim()
|
|
68
|
+
.split(/\s+/u)[0]
|
|
69
|
+
?.replace(/[^A-Za-z]/gu, "") ?? "";
|
|
70
|
+
/**
|
|
71
|
+
* 接続詞で始まる文が続く。1 つなら効くが、続くと文が前の文の付け足しに見えて、
|
|
72
|
+
* 何が主張なのかが分からなくなる。
|
|
73
|
+
*/
|
|
74
|
+
export const conjunctionRun = (doc, options) => {
|
|
75
|
+
const heads = (options.lexicon ?? []).map((entry) => entry.pattern.toLowerCase());
|
|
76
|
+
const runs = doc.sentences.filter(isClosed).reduce((acc, sentence) => {
|
|
77
|
+
const last = acc.at(-1) ?? [];
|
|
78
|
+
if (!heads.includes(firstWord(sentence).toLowerCase()))
|
|
79
|
+
return [...acc.slice(0, -1), last, []];
|
|
80
|
+
return [...acc.slice(0, -1), [...last, sentence]];
|
|
81
|
+
}, [[]]);
|
|
82
|
+
return runs
|
|
83
|
+
.filter((run) => run.length > options.limit)
|
|
84
|
+
.flatMap((run) => {
|
|
85
|
+
const first = run[0];
|
|
86
|
+
return first === undefined
|
|
87
|
+
? []
|
|
88
|
+
: [
|
|
89
|
+
{
|
|
90
|
+
rule: "sentence-initial-conjunction-run",
|
|
91
|
+
severity: "info",
|
|
92
|
+
line: 0,
|
|
93
|
+
column: 0,
|
|
94
|
+
quote: run.map((sentence) => sentence.text.trim()).join(" "),
|
|
95
|
+
values: { count: run.length, limit: options.limit, offset: first.span.start },
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const WORD = /[A-Za-z][A-Za-z'-]*/gu;
|
|
101
|
+
/** 小さい語は Title Case でも小文字のままなので、大文字化の判定から外す。 */
|
|
102
|
+
const MINOR = new Set(["a", "an", "the", "and", "or", "but", "of", "in", "on", "at", "to", "for", "with", "as", "by", "from", "is"]);
|
|
103
|
+
const isTitleCase = (heading) => {
|
|
104
|
+
const words = [...heading.matchAll(WORD)].map((match) => match[0]).filter((word) => !MINOR.has(word.toLowerCase()));
|
|
105
|
+
// 1 語の見出しは、どちらの流儀でも先頭が大文字になる。判定できない。
|
|
106
|
+
if (words.length < 2)
|
|
107
|
+
return undefined;
|
|
108
|
+
const capitalized = words.filter((word) => word[0] === word[0]?.toUpperCase()).length;
|
|
109
|
+
return capitalized === words.length;
|
|
110
|
+
};
|
|
111
|
+
const headingsOf = (sections) => sections.flatMap((section) => {
|
|
112
|
+
const title = isTitleCase(section.heading);
|
|
113
|
+
return title === undefined ? [] : [{ section, title }];
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* 見出しの大文字化が混ざっている。どちらの流儀が正しいかは決めない。spec §12.3。
|
|
117
|
+
* 見るのは文書の中で揃っているかだけで、少数派のほうを指摘する。
|
|
118
|
+
*/
|
|
119
|
+
export const titleCaseMix = (doc, options) => {
|
|
120
|
+
const judged = headingsOf(doc.sections);
|
|
121
|
+
const title = judged.filter((entry) => entry.title).length;
|
|
122
|
+
const minorityIsTitle = title <= judged.length - title;
|
|
123
|
+
const few = minorityIsTitle ? title : judged.length - title;
|
|
124
|
+
if (few === 0 || few > options.limit)
|
|
125
|
+
return [];
|
|
126
|
+
return judged
|
|
127
|
+
.filter((entry) => entry.title === minorityIsTitle)
|
|
128
|
+
.map(({ section }) => ({
|
|
129
|
+
rule: "title-case-consistency",
|
|
130
|
+
severity: "info",
|
|
131
|
+
line: 0,
|
|
132
|
+
column: 0,
|
|
133
|
+
quote: section.heading,
|
|
134
|
+
values: { count: few, limit: options.limit, offset: section.span.start },
|
|
135
|
+
}));
|
|
136
|
+
};
|
|
137
|
+
const LIST_CONJUNCTION = new Set(["and", "or"]);
|
|
138
|
+
/**
|
|
139
|
+
* 3 つ以上の並列の最後の and / or の前に読点を打つか。Oxford comma。
|
|
140
|
+
*
|
|
141
|
+
* どちらが正しいかは決めない。スタイルガイドで割れる論点に立場を取ると rule ごと無視される。
|
|
142
|
+
* 見るのは 1 つの文書で揃っているかだけ。spec §12.3。
|
|
143
|
+
*/
|
|
144
|
+
const oxfordIn = (tokens) => {
|
|
145
|
+
const at = tokens.findIndex((token) => LIST_CONJUNCTION.has(token.surface.toLowerCase()));
|
|
146
|
+
if (at < 1)
|
|
147
|
+
return undefined;
|
|
148
|
+
const before = tokens.slice(0, at);
|
|
149
|
+
// 並列が 3 つ以上あるときだけ判定できる。読点が 1 つも無ければ 2 つの並列。
|
|
150
|
+
const commas = before.filter((token) => token.surface === ",").length;
|
|
151
|
+
if (commas === 0)
|
|
152
|
+
return undefined;
|
|
153
|
+
return before.at(-1)?.surface === ",";
|
|
154
|
+
};
|
|
155
|
+
export const oxfordComma = (doc, options) => {
|
|
156
|
+
const judged = doc.sentences.flatMap((sentence) => {
|
|
157
|
+
const oxford = oxfordIn(sentence.tokens ?? []);
|
|
158
|
+
return oxford === undefined ? [] : [{ sentence, oxford }];
|
|
159
|
+
});
|
|
160
|
+
const withComma = judged.filter((entry) => entry.oxford).length;
|
|
161
|
+
const minorityUsesComma = withComma <= judged.length - withComma;
|
|
162
|
+
const few = minorityUsesComma ? withComma : judged.length - withComma;
|
|
163
|
+
if (few === 0 || few > options.limit)
|
|
164
|
+
return [];
|
|
165
|
+
return judged
|
|
166
|
+
.filter((entry) => entry.oxford === minorityUsesComma)
|
|
167
|
+
.map(({ sentence }) => ({
|
|
168
|
+
rule: "oxford-comma-consistency",
|
|
169
|
+
severity: "info",
|
|
170
|
+
line: 0,
|
|
171
|
+
column: 0,
|
|
172
|
+
quote: sentence.text.trim(),
|
|
173
|
+
values: { count: few, limit: options.limit, offset: sentence.span.start },
|
|
174
|
+
}));
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=en-shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en-shape.js","sourceRoot":"","sources":["../../src/detectors/en-shape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,+CAA+C;AAC/C,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,MAAM,OAAO,GAAG,CAAC,GAAkB,EAAU,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,GAAG,GAAG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7H,MAAM,UAAU,GAAG,CAAC,KAAY,EAAW,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEhH;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa,CAAC,GAAG,EAAE,OAAO,EAAa,EAAE;IACjE,MAAM,KAAK,GAAG,OAAO,CAAC,GA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G,KAAK,CAAC,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAChD,OAAO,MAAM;SACV,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,iBAAiB,CAAC;SACrD,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QACtB,IAAI,EAAE,0BAA0B;QAChC,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;QAC3B,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;KAC1E,CAAC,CAAC,CAAC;AACR,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/detectors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/detectors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAgB7C,kDAAkD;AAClD,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAgCxD,CAAC"}
|
package/dist/detectors/index.js
CHANGED
|
@@ -4,6 +4,14 @@ import { headingEcho } from "./heading-echo.js";
|
|
|
4
4
|
import { repeatedHead } from "./repeated-head.js";
|
|
5
5
|
import { sentenceRhythm } from "./sentence-rhythm.js";
|
|
6
6
|
import { phraseMatch } from "./phrase-match.js";
|
|
7
|
+
import { agentlessPassive } from "./agentless-passive.js";
|
|
8
|
+
import { sentenceEnding } from "./sentence-ending.js";
|
|
9
|
+
import { doubledParticle, nounEnding } from "./token-shape.js";
|
|
10
|
+
import { kanjiRun, middleDot } from "./char-shape.js";
|
|
11
|
+
import { adverbDensity, conjunctionRun, expletive, oxfordComma, titleCaseMix } from "./en-shape.js";
|
|
12
|
+
import { paragraphLength, paragraphVariance, preambleLength, ruleOfThree, sectionUniformity } from "./structure.js";
|
|
13
|
+
import { concreteEvidence, emojiDensity, ngramRepetition, undefinedAcronym } from "./signals.js";
|
|
14
|
+
import { aiTell, cushionDensity, hedgingDensity, repeatedConjunction, unqualifiedSuperlative } from "./lexicon.js";
|
|
7
15
|
/** rule 定義の how_to_find がここを引く。rule 側は実装を知らない。 */
|
|
8
16
|
export const DETECTORS = {
|
|
9
17
|
"count-per-section": countPerSection,
|
|
@@ -12,5 +20,30 @@ export const DETECTORS = {
|
|
|
12
20
|
"repeated-head": repeatedHead,
|
|
13
21
|
"sentence-rhythm": sentenceRhythm,
|
|
14
22
|
"phrase-match": phraseMatch,
|
|
23
|
+
"agentless-passive": agentlessPassive,
|
|
24
|
+
"sentence-ending": sentenceEnding,
|
|
25
|
+
"noun-ending": nounEnding,
|
|
26
|
+
"doubled-particle": doubledParticle,
|
|
27
|
+
"kanji-run": kanjiRun,
|
|
28
|
+
"middle-dot": middleDot,
|
|
29
|
+
"adverb-density": adverbDensity,
|
|
30
|
+
expletive: expletive,
|
|
31
|
+
"conjunction-run": conjunctionRun,
|
|
32
|
+
"title-case-mix": titleCaseMix,
|
|
33
|
+
"oxford-comma": oxfordComma,
|
|
34
|
+
"paragraph-length": paragraphLength,
|
|
35
|
+
"paragraph-variance": paragraphVariance,
|
|
36
|
+
"section-uniformity": sectionUniformity,
|
|
37
|
+
"rule-of-three": ruleOfThree,
|
|
38
|
+
"preamble-length": preambleLength,
|
|
39
|
+
"emoji-density": emojiDensity,
|
|
40
|
+
"ngram-repetition": ngramRepetition,
|
|
41
|
+
"undefined-acronym": undefinedAcronym,
|
|
42
|
+
"concrete-evidence": concreteEvidence,
|
|
43
|
+
"hedging-density": hedgingDensity,
|
|
44
|
+
"cushion-density": cushionDensity,
|
|
45
|
+
"unqualified-superlative": unqualifiedSuperlative,
|
|
46
|
+
"repeated-conjunction": repeatedConjunction,
|
|
47
|
+
"ai-tell": aiTell,
|
|
15
48
|
};
|
|
16
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/detectors/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/detectors/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB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B,EAAE,mBAAmB;IAC3C,SAAS,EAAE,MAAM;CAClB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Detector } from "../plugin.ts";
|
|
2
|
+
export declare const hedgingDensity: Detector;
|
|
3
|
+
export declare const cushionDensity: Detector;
|
|
4
|
+
export declare const unqualifiedSuperlative: Detector;
|
|
5
|
+
/**
|
|
6
|
+
* 段落が同じ接続詞で始まり続ける。1 つなら流れを作るが、続くとどの段落も
|
|
7
|
+
* 前の段落の付け足しに見えて、話がどこへ向かっているのか分からなくなる。
|
|
8
|
+
*/
|
|
9
|
+
export declare const repeatedConjunction: Detector;
|
|
10
|
+
/**
|
|
11
|
+
* AI 生成の signal。1 つでは何も言えないので、重みを足し合わせて文書の点にする。
|
|
12
|
+
* 単独で断じない。§20.2 の複合シグナルの入口で、これだけで「AI が書いた」とは言わない。
|
|
13
|
+
*/
|
|
14
|
+
export declare const aiTell: Detector;
|
|
15
|
+
//# sourceMappingURL=lexicon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexicon.d.ts","sourceRoot":"","sources":["../../src/detectors/lexicon.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAoC,MAAM,cAAc,CAAC;AAsC/E,eAAO,MAAM,cAAc,UAAmC,CAAC;AAC/D,eAAO,MAAM,cAAc,UAAwC,CAAC;AAQpE,eAAO,MAAM,sBAAsB,EAAE,QAYpC,CAAC;AAQF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,QA2BjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,QAiBpB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { proseText } from "../measure.js";
|
|
2
|
+
import { wordsOf } from "./structure.js";
|
|
3
|
+
const PER = 1000;
|
|
4
|
+
/** 密度を見る rule は短い文書を測らない。単位は言語で違うので床も分ける。 */
|
|
5
|
+
const FLOOR = { word: 200, char: 500 };
|
|
6
|
+
const hitsFor = (doc, patterns) => doc.sentences.flatMap((sentence) => {
|
|
7
|
+
const text = sentence.text.toLowerCase();
|
|
8
|
+
return patterns.filter((pattern) => text.includes(pattern.toLowerCase())).map((matched) => ({ sentence, matched }));
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* 単位長あたりの出現率。件数で数えると長い文書ほど当たる(bold-density と同じ)。
|
|
12
|
+
* rule の id は呼び出し側が持つ。detector は「密度が閾値を超えたか」しか知らない。
|
|
13
|
+
*/
|
|
14
|
+
const densityRule = (rule) => (doc, options) => {
|
|
15
|
+
const patterns = (options.lexicon ?? []).map((entry) => entry.pattern);
|
|
16
|
+
const hits = hitsFor(doc, patterns);
|
|
17
|
+
const length = wordsOf(doc);
|
|
18
|
+
const rate = length === 0 ? 0 : Math.round((hits.length / length) * PER);
|
|
19
|
+
const first = hits[0];
|
|
20
|
+
if (length < FLOOR[doc.lengthUnit] || first === undefined || rate <= options.limit)
|
|
21
|
+
return [];
|
|
22
|
+
return hits.map((hit) => ({
|
|
23
|
+
rule,
|
|
24
|
+
severity: "warning",
|
|
25
|
+
line: 0,
|
|
26
|
+
column: 0,
|
|
27
|
+
quote: hit.sentence.text.trim(),
|
|
28
|
+
values: { matched: hit.matched, count: hits.length, density: rate, limit: options.limit, offset: hit.sentence.span.start },
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
export const hedgingDensity = densityRule("excessive-hedging");
|
|
32
|
+
export const cushionDensity = densityRule("cushion-phrase-density");
|
|
33
|
+
/**
|
|
34
|
+
* 限定のない最上級。「最も速い」だけでは、何と比べて最もなのかが無い。
|
|
35
|
+
* 同じ文に比較対象や条件があれば、それは主張であって誇張ではない。
|
|
36
|
+
*/
|
|
37
|
+
const QUALIFIER = /\d|より|に比べ|のうち|among|than|compared|based on|according/iu;
|
|
38
|
+
export const unqualifiedSuperlative = (doc, options) => {
|
|
39
|
+
const patterns = (options.lexicon ?? []).map((entry) => entry.pattern);
|
|
40
|
+
const bare = hitsFor(doc, patterns).filter((hit) => !QUALIFIER.test(hit.sentence.text));
|
|
41
|
+
if (bare.length < options.limit)
|
|
42
|
+
return [];
|
|
43
|
+
return bare.map((hit) => ({
|
|
44
|
+
rule: "unqualified-superlative",
|
|
45
|
+
severity: "warning",
|
|
46
|
+
line: 0,
|
|
47
|
+
column: 0,
|
|
48
|
+
quote: hit.sentence.text.trim(),
|
|
49
|
+
values: { matched: hit.matched, count: bare.length, limit: options.limit, offset: hit.sentence.span.start },
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
const openerOf = (doc, patterns) => doc.paragraphs.map((paragraph) => {
|
|
53
|
+
const head = paragraph.sentences[0]?.text.trim().toLowerCase() ?? "";
|
|
54
|
+
return patterns.find((pattern) => head.startsWith(pattern.toLowerCase()));
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* 段落が同じ接続詞で始まり続ける。1 つなら流れを作るが、続くとどの段落も
|
|
58
|
+
* 前の段落の付け足しに見えて、話がどこへ向かっているのか分からなくなる。
|
|
59
|
+
*/
|
|
60
|
+
export const repeatedConjunction = (doc, options) => {
|
|
61
|
+
const patterns = (options.lexicon ?? []).map((entry) => entry.pattern);
|
|
62
|
+
const openers = openerOf(doc, patterns);
|
|
63
|
+
const runs = openers.reduce((acc, opener, index) => {
|
|
64
|
+
if (opener === undefined)
|
|
65
|
+
return { runs: [...acc.runs, acc.current], current: [] };
|
|
66
|
+
return { runs: acc.runs, current: [...acc.current, index] };
|
|
67
|
+
}, { runs: [], current: [] });
|
|
68
|
+
return [...runs.runs, runs.current]
|
|
69
|
+
.filter((run) => run.length > options.limit)
|
|
70
|
+
.flatMap((run) => {
|
|
71
|
+
const at = doc.paragraphs[run[0] ?? 0];
|
|
72
|
+
return at === undefined
|
|
73
|
+
? []
|
|
74
|
+
: [
|
|
75
|
+
{
|
|
76
|
+
rule: "repeated-conjunction",
|
|
77
|
+
severity: "warning",
|
|
78
|
+
line: 0,
|
|
79
|
+
column: 0,
|
|
80
|
+
quote: at.sentences[0]?.text.trim() ?? "",
|
|
81
|
+
values: { count: run.length, limit: options.limit, offset: at.span.start },
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* AI 生成の signal。1 つでは何も言えないので、重みを足し合わせて文書の点にする。
|
|
88
|
+
* 単独で断じない。§20.2 の複合シグナルの入口で、これだけで「AI が書いた」とは言わない。
|
|
89
|
+
*/
|
|
90
|
+
export const aiTell = (doc, options) => {
|
|
91
|
+
const weights = new Map((options.lexicon ?? []).map((entry) => [entry.pattern.toLowerCase(), entry.weight ?? 1]));
|
|
92
|
+
const body = doc.sentences.map(proseText).join(" ").toLowerCase();
|
|
93
|
+
const found = [...weights.entries()].filter(([pattern]) => body.includes(pattern));
|
|
94
|
+
const score = Math.round(found.reduce((sum, [, weight]) => sum + weight, 0) * 10);
|
|
95
|
+
const first = doc.sentences.find((sentence) => found.some(([pattern]) => sentence.text.toLowerCase().includes(pattern)));
|
|
96
|
+
if (first === undefined || score <= options.limit)
|
|
97
|
+
return [];
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
rule: "ai-tell",
|
|
101
|
+
severity: "info",
|
|
102
|
+
line: 0,
|
|
103
|
+
column: 0,
|
|
104
|
+
quote: first.text.trim(),
|
|
105
|
+
values: { word: found.map(([pattern]) => pattern).join("、"), count: found.length, density: score, limit: options.limit, offset: first.span.start },
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=lexicon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexicon.js","sourceRoot":"","sources":["../../src/detectors/lexicon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,MAAM,GAAG,GAAG,IAAI,C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AAC;YACP,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE;YACxB,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE;SACnJ;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repeated-head.d.ts","sourceRoot":"","sources":["../../src/detectors/repeated-head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"repeated-head.d.ts","sourceRoot":"","sources":["../../src/detectors/repeated-head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAiC,MAAM,cAAc,CAAC;AA6B5E,eAAO,MAAM,YAAY,EAAE,QAUpB,CAAC"}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
const HEAD_CHARS = 6;
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const HEAD_WORDS = 3;
|
|
3
|
+
/**
|
|
4
|
+
* 書き出しの「同じさ」を測る単位は言語で違う。日本語は文字、英語は語。
|
|
5
|
+
* 文字で切ると "We continued" が "Wecont" になり、引用がそのまま読み手に出る。
|
|
6
|
+
*/
|
|
7
|
+
const headOf = (sentence, unit) => {
|
|
8
|
+
const text = sentence.text.trim();
|
|
9
|
+
if (unit === "char")
|
|
10
|
+
return text.replace(/\s+/gu, "").slice(0, HEAD_CHARS);
|
|
11
|
+
return text.split(/\s+/u).slice(0, HEAD_WORDS).join(" ");
|
|
12
|
+
};
|
|
13
|
+
const runsOf = (sentences, unit) => sentences.reduce((acc, sentence) => {
|
|
14
|
+
const head = headOf(sentence, unit);
|
|
5
15
|
const last = acc.at(-1);
|
|
6
|
-
|
|
16
|
+
// 短すぎる書き出しは「同じ」と言えない。単位ぶん揃って初めて連なりと見る。
|
|
17
|
+
const full = unit === "char" ? head.length === HEAD_CHARS : head.split(" ").length === HEAD_WORDS;
|
|
18
|
+
if (last !== undefined && last.head === head && full) {
|
|
7
19
|
return [...acc.slice(0, -1), { head, members: [...last.members, sentence] }];
|
|
8
20
|
}
|
|
9
21
|
return [...acc, { head, members: [sentence] }];
|
|
10
22
|
}, []);
|
|
11
|
-
export const repeatedHead = (doc, options) => runsOf(doc.sentences)
|
|
23
|
+
export const repeatedHead = (doc, options) => runsOf(doc.sentences, doc.lengthUnit)
|
|
12
24
|
.filter((run) => run.members.length > options.limit)
|
|
13
25
|
.map((run) => ({
|
|
14
26
|
rule: "repeated-sentence-head",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repeated-head.js","sourceRoot":"","sources":["../../src/detectors/repeated-head.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,MAAM,MAAM,GAAG,CAAC,QAAkB,EAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"repeated-head.js","sourceRoot":"","sources":["../../src/detectors/repeated-head.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,QAAkB,EAAE,IAAgB,EAAU,EAAE;IAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC3E,OAAO,IAAI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