chaffjs 0.40.0 → 0.42.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.d.ts.map +1 -1
- package/dist/ai-score/human-shares.js +1 -0
- package/dist/ai-score/human-shares.js.map +1 -1
- package/dist/composite-signals.d.ts +6 -0
- package/dist/composite-signals.d.ts.map +1 -0
- package/dist/composite-signals.js +23 -0
- package/dist/composite-signals.js.map +1 -0
- package/dist/detectors/acronym-context.d.ts +4 -0
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +45 -0
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/acronym-file-type.d.ts +14 -0
- package/dist/detectors/acronym-file-type.d.ts.map +1 -0
- package/dist/detectors/acronym-file-type.js +26 -0
- package/dist/detectors/acronym-file-type.js.map +1 -0
- package/dist/detectors/acronym-series.d.ts +5 -0
- package/dist/detectors/acronym-series.d.ts.map +1 -1
- package/dist/detectors/acronym-series.js +18 -3
- package/dist/detectors/acronym-series.js.map +1 -1
- package/dist/detectors/ai-phrasing.d.ts.map +1 -1
- package/dist/detectors/ai-phrasing.js +7 -1
- package/dist/detectors/ai-phrasing.js.map +1 -1
- package/dist/detectors/ai-structure.d.ts +2 -1
- package/dist/detectors/ai-structure.d.ts.map +1 -1
- package/dist/detectors/ai-structure.js +23 -8
- package/dist/detectors/ai-structure.js.map +1 -1
- package/dist/detectors/bibliography-entry.d.ts +3 -0
- package/dist/detectors/bibliography-entry.d.ts.map +1 -0
- package/dist/detectors/bibliography-entry.js +15 -0
- package/dist/detectors/bibliography-entry.js.map +1 -0
- package/dist/detectors/char-shape.d.ts +1 -0
- package/dist/detectors/char-shape.d.ts.map +1 -1
- package/dist/detectors/char-shape.js +13 -8
- package/dist/detectors/char-shape.js.map +1 -1
- package/dist/detectors/closing-cliche.d.ts.map +1 -1
- package/dist/detectors/closing-cliche.js +2 -1
- package/dist/detectors/closing-cliche.js.map +1 -1
- package/dist/detectors/contraction-mention.d.ts +2 -0
- package/dist/detectors/contraction-mention.d.ts.map +1 -1
- package/dist/detectors/contraction-mention.js +5 -2
- package/dist/detectors/contraction-mention.js.map +1 -1
- package/dist/detectors/contraction-mix.d.ts.map +1 -1
- package/dist/detectors/contraction-mix.js +12 -4
- package/dist/detectors/contraction-mix.js.map +1 -1
- package/dist/detectors/contraction-set-apart.d.ts +14 -0
- package/dist/detectors/contraction-set-apart.d.ts.map +1 -0
- package/dist/detectors/contraction-set-apart.js +42 -0
- package/dist/detectors/contraction-set-apart.js.map +1 -0
- package/dist/detectors/counter-edge.d.ts +11 -0
- package/dist/detectors/counter-edge.d.ts.map +1 -1
- package/dist/detectors/counter-edge.js +29 -0
- package/dist/detectors/counter-edge.js.map +1 -1
- package/dist/detectors/densest-stretch.d.ts +11 -0
- package/dist/detectors/densest-stretch.d.ts.map +1 -0
- package/dist/detectors/densest-stretch.js +14 -0
- package/dist/detectors/densest-stretch.js.map +1 -0
- package/dist/detectors/doubled-word.d.ts.map +1 -1
- package/dist/detectors/doubled-word.js +8 -4
- package/dist/detectors/doubled-word.js.map +1 -1
- package/dist/detectors/fullwidth-alnum.d.ts +3 -0
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
- package/dist/detectors/fullwidth-alnum.js +11 -2
- package/dist/detectors/fullwidth-alnum.js.map +1 -1
- package/dist/detectors/gram-furniture.d.ts +9 -5
- package/dist/detectors/gram-furniture.d.ts.map +1 -1
- package/dist/detectors/gram-furniture.js +30 -13
- package/dist/detectors/gram-furniture.js.map +1 -1
- package/dist/detectors/gram-heading.d.ts +9 -0
- package/dist/detectors/gram-heading.d.ts.map +1 -0
- package/dist/detectors/gram-heading.js +20 -0
- package/dist/detectors/gram-heading.js.map +1 -0
- package/dist/detectors/gram-openers.d.ts +11 -0
- package/dist/detectors/gram-openers.d.ts.map +1 -1
- package/dist/detectors/gram-openers.js +42 -1
- package/dist/detectors/gram-openers.js.map +1 -1
- package/dist/detectors/gram-predicate.d.ts.map +1 -1
- package/dist/detectors/gram-predicate.js +19 -1
- package/dist/detectors/gram-predicate.js.map +1 -1
- package/dist/detectors/gram-repetition.d.ts.map +1 -1
- package/dist/detectors/gram-repetition.js +36 -10
- package/dist/detectors/gram-repetition.js.map +1 -1
- package/dist/detectors/gram-spread.d.ts +6 -0
- package/dist/detectors/gram-spread.d.ts.map +1 -0
- package/dist/detectors/gram-spread.js +18 -0
- package/dist/detectors/gram-spread.js.map +1 -0
- package/dist/detectors/kanji-run-pieces.d.ts +4 -0
- package/dist/detectors/kanji-run-pieces.d.ts.map +1 -1
- package/dist/detectors/kanji-run-pieces.js +7 -0
- package/dist/detectors/kanji-run-pieces.js.map +1 -1
- package/dist/detectors/known-correction.d.ts.map +1 -1
- package/dist/detectors/known-correction.js +11 -9
- package/dist/detectors/known-correction.js.map +1 -1
- package/dist/detectors/lexicon.d.ts +2 -2
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +15 -5
- package/dist/detectors/lexicon.js.map +1 -1
- package/dist/detectors/list-lead-in.d.ts +2 -2
- package/dist/detectors/list-lead-in.d.ts.map +1 -1
- package/dist/detectors/list-lead-in.js +46 -11
- package/dist/detectors/list-lead-in.js.map +1 -1
- package/dist/detectors/list-run.d.ts.map +1 -1
- package/dist/detectors/list-run.js +16 -2
- package/dist/detectors/list-run.js.map +1 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +17 -2
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/phrase-match.d.ts.map +1 -1
- package/dist/detectors/phrase-match.js +3 -2
- package/dist/detectors/phrase-match.js.map +1 -1
- package/dist/detectors/quoted-pattern.d.ts +2 -0
- package/dist/detectors/quoted-pattern.d.ts.map +1 -0
- package/dist/detectors/quoted-pattern.js +13 -0
- package/dist/detectors/quoted-pattern.js.map +1 -0
- package/dist/detectors/reference-entry.d.ts +5 -0
- package/dist/detectors/reference-entry.d.ts.map +1 -1
- package/dist/detectors/reference-entry.js +6 -1
- package/dist/detectors/reference-entry.js.map +1 -1
- package/dist/detectors/relative-pronoun-mix.d.ts.map +1 -1
- package/dist/detectors/relative-pronoun-mix.js +7 -3
- package/dist/detectors/relative-pronoun-mix.js.map +1 -1
- package/dist/detectors/sentence-parts.d.ts +5 -0
- package/dist/detectors/sentence-parts.d.ts.map +1 -1
- package/dist/detectors/sentence-parts.js +8 -0
- package/dist/detectors/sentence-parts.js.map +1 -1
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +41 -7
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/superlative-context.d.ts +2 -1
- package/dist/detectors/superlative-context.d.ts.map +1 -1
- package/dist/detectors/superlative-context.js +9 -2
- package/dist/detectors/superlative-context.js.map +1 -1
- package/dist/detectors/title-list.d.ts +7 -0
- package/dist/detectors/title-list.d.ts.map +1 -0
- package/dist/detectors/title-list.js +14 -0
- package/dist/detectors/title-list.js.map +1 -0
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +5 -1
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/unknown-word-context.d.ts +2 -0
- package/dist/detectors/unknown-word-context.d.ts.map +1 -1
- package/dist/detectors/unknown-word-context.js +4 -0
- package/dist/detectors/unknown-word-context.js.map +1 -1
- package/dist/detectors/unknown-word.d.ts.map +1 -1
- package/dist/detectors/unknown-word.js +10 -3
- package/dist/detectors/unknown-word.js.map +1 -1
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/rule-of-three.d.ts +5 -1
- package/dist/rule-of-three.d.ts.map +1 -1
- package/dist/rule-of-three.js +11 -2
- package/dist/rule-of-three.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -2
- package/dist/run.js.map +1 -1
- package/dist/structure-shape/faq-sections.d.ts +7 -0
- package/dist/structure-shape/faq-sections.d.ts.map +1 -0
- package/dist/structure-shape/faq-sections.js +14 -0
- package/dist/structure-shape/faq-sections.js.map +1 -0
- package/dist/structure-shape/features.d.ts.map +1 -1
- package/dist/structure-shape/features.js +5 -3
- package/dist/structure-shape/features.js.map +1 -1
- package/dist/structure-shape/template-outline.d.ts +7 -0
- package/dist/structure-shape/template-outline.d.ts.map +1 -1
- package/dist/structure-shape/template-outline.js +10 -0
- package/dist/structure-shape/template-outline.js.map +1 -1
- package/dist/topic-clause.d.ts.map +1 -1
- package/dist/topic-clause.js +23 -1
- package/dist/topic-clause.js.map +1 -1
- package/package.json +3 -3
- package/rules/ai-generated-composite.yaml +2 -2
- package/rules/ai-structure.yaml +4 -4
- package/rules/ai-tell.yaml +2 -2
- package/rules/closing-cliche.yaml +3 -3
- package/rules/colon-lead-in.yaml +3 -2
- package/rules/contraction-consistency.yaml +4 -2
- package/rules/contrast-framing.yaml +3 -3
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/max-kanji-continuous.yaml +4 -3
- package/rules/ngram-repetition.yaml +2 -2
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/no-mixed-desumasu.yaml +2 -2
- package/rules/oxford-comma-consistency.yaml +2 -2
- package/rules/rule-of-three.yaml +2 -2
- package/rules/topic-predicate-distance.yaml +2 -2
- package/rules/undefined-acronym.yaml +5 -2
- package/rules/unknown-word.yaml +2 -2
- package/rules/unqualified-superlative.yaml +1 -1
- package/src/ai-score/human-shares.ts +1 -0
- package/src/composite-signals.ts +27 -0
- package/src/detectors/acronym-context.ts +58 -0
- package/src/detectors/acronym-file-type.ts +33 -0
- package/src/detectors/acronym-series.ts +22 -3
- package/src/detectors/ai-phrasing.ts +7 -1
- package/src/detectors/ai-structure.ts +24 -12
- package/src/detectors/bibliography-entry.ts +18 -0
- package/src/detectors/char-shape.ts +12 -7
- package/src/detectors/closing-cliche.ts +6 -1
- package/src/detectors/contraction-mention.ts +6 -2
- package/src/detectors/contraction-mix.ts +16 -4
- package/src/detectors/contraction-set-apart.ts +52 -0
- package/src/detectors/counter-edge.ts +35 -0
- package/src/detectors/densest-stretch.ts +21 -0
- package/src/detectors/doubled-word.ts +10 -10
- package/src/detectors/fullwidth-alnum.ts +19 -3
- package/src/detectors/gram-furniture.ts +36 -13
- package/src/detectors/gram-heading.ts +27 -0
- package/src/detectors/gram-openers.ts +54 -1
- package/src/detectors/gram-predicate.ts +24 -1
- package/src/detectors/gram-repetition.ts +44 -9
- package/src/detectors/gram-spread.ts +19 -0
- package/src/detectors/kanji-run-pieces.ts +10 -0
- package/src/detectors/known-correction.ts +15 -8
- package/src/detectors/lexicon.ts +17 -5
- package/src/detectors/list-lead-in.ts +59 -11
- package/src/detectors/list-run.ts +16 -2
- package/src/detectors/oxford-comma.ts +17 -2
- package/src/detectors/phrase-match.ts +3 -2
- package/src/detectors/quoted-pattern.ts +14 -0
- package/src/detectors/reference-entry.ts +8 -1
- package/src/detectors/relative-pronoun-mix.ts +5 -3
- package/src/detectors/sentence-parts.ts +15 -0
- package/src/detectors/signals.ts +47 -7
- package/src/detectors/superlative-context.ts +10 -2
- package/src/detectors/title-list.ts +21 -0
- package/src/detectors/token-shape.ts +20 -16
- package/src/detectors/unknown-word-context.ts +6 -0
- package/src/detectors/unknown-word.ts +10 -2
- package/src/plugin.ts +2 -0
- package/src/rule-of-three.ts +16 -2
- package/src/run.ts +4 -2
- package/src/structure-shape/faq-sections.ts +24 -0
- package/src/structure-shape/features.ts +5 -3
- package/src/structure-shape/template-outline.ts +12 -0
- package/src/topic-clause.ts +25 -1
package/src/detectors/signals.ts
CHANGED
|
@@ -7,10 +7,14 @@ import { isExplained } from "./acronym-compound.ts";
|
|
|
7
7
|
import { statedAcronyms } from "./acronym-definition.ts";
|
|
8
8
|
import { isBracketed, isInHeading, isNamePart } from "./acronym-lone.ts";
|
|
9
9
|
import { linkedListTerms } from "./acronym-link.ts";
|
|
10
|
+
import { headingSeries } from "./acronym-series.ts";
|
|
11
|
+
import { citationSpans } from "./acronym-name.ts";
|
|
12
|
+
import { referenceEntryLabels } from "./reference-entry.ts";
|
|
10
13
|
import { caseVariantsIn, spelledOutAcronyms, writtenAsWordIn } from "./acronym-mention.ts";
|
|
11
14
|
import { conjugatedForms } from "./conjugated-form.ts";
|
|
12
15
|
import { knownByDocument } from "./acronym-known.ts";
|
|
13
16
|
import { explainedInText, headingsSpellingOut } from "./acronym-gloss.ts";
|
|
17
|
+
import { fileTypeNames, type AcronymUse } from "./acronym-file-type.ts";
|
|
14
18
|
import { nameSpans } from "../team-names.ts";
|
|
15
19
|
import { DASH, introducesList, opensLine } from "./lead-in-dash.ts";
|
|
16
20
|
import type { Detector, Finding, ProseDocument, Sentence } from "../plugin.ts";
|
|
@@ -25,6 +29,11 @@ export const MIN_DOCUMENT_LENGTH = { word: 200, char: 500 };
|
|
|
25
29
|
|
|
26
30
|
const bodyOf = (doc: ProseDocument): string => doc.sentences.map(proseText).join(" ");
|
|
27
31
|
|
|
32
|
+
/** 全角の英数字を半角に(ICO(Initial Coin Offering)の ICO を ICO と読む)。1 文字ずつ置き換えるので位置は変わらない。 */
|
|
33
|
+
const FULL_WIDTH_ALNUM = /[A-Za-z0-9]/gu;
|
|
34
|
+
const FULL_WIDTH_OFFSET = 0xfee0;
|
|
35
|
+
const halfWidth = (text: string): string => text.replaceAll(FULL_WIDTH_ALNUM, (character) => String.fromCharCode(character.charCodeAt(0) - FULL_WIDTH_OFFSET));
|
|
36
|
+
|
|
28
37
|
type Hit = { readonly sentence: Sentence; readonly offset: number };
|
|
29
38
|
|
|
30
39
|
const findIn = (doc: ProseDocument, pattern: RegExp): Hit[] =>
|
|
@@ -142,6 +151,14 @@ const acronymsOf = (doc: ProseDocument, notation: NotAcronymSpans): AcronymHit[]
|
|
|
142
151
|
.filter(({ hit }) => !isEmphasised(hit.sentence, hit.offset));
|
|
143
152
|
});
|
|
144
153
|
|
|
154
|
+
/** 略語のすぐ前と後ろの文字列と、後ろに始まる語の品詞。 */
|
|
155
|
+
const fileUseOf = ({ word, hit }: AcronymHit): AcronymUse => {
|
|
156
|
+
const start = hit.offset - hit.sentence.span.start;
|
|
157
|
+
const next = (hit.sentence.tokens ?? []).find((token) => token.span.start >= hit.offset + word.length);
|
|
158
|
+
const { text } = hit.sentence;
|
|
159
|
+
return { word, preceding: text.slice(Math.max(0, start - 2), start), following: text.slice(start + word.length), nextPos: next?.pos };
|
|
160
|
+
};
|
|
161
|
+
|
|
145
162
|
/** 略語ごとの、最初に現れた所。 */
|
|
146
163
|
const firstHits = (hits: readonly AcronymHit[]): Map<string, Hit> => {
|
|
147
164
|
const seen = new Map<string, Hit>();
|
|
@@ -175,6 +192,13 @@ const expandsInHeading = (heading: string, acronym: string, expandedAt: Expanded
|
|
|
175
192
|
|
|
176
193
|
const patternsOf = (doc: ProseDocument, id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
177
194
|
|
|
195
|
+
/**
|
|
196
|
+
* 法令集の名前(CFR)を、この文書が引用の形(12 CFR 1005.20)で書いているなら、引用の外(the List of CFR Sections Affected)でも
|
|
197
|
+
* 読み手の知る名前と読む。引用の形で書いていない文書の CFR は略語のまま数える。
|
|
198
|
+
*/
|
|
199
|
+
const citedSeriesOf = (doc: ProseDocument, body: string): string[] =>
|
|
200
|
+
patternsOf(doc, "citation-series").filter((series) => citationSpans(body, [series]).length > 0 || titledCodeSpans(body, [series]).length > 0);
|
|
201
|
+
|
|
178
202
|
const notationOf = (doc: ProseDocument): NotAcronymSpans => lexiconNotationOf((id) => patternsOf(doc, id));
|
|
179
203
|
|
|
180
204
|
/** 定義の語。定義の動詞は、語彙表の形(という)と、この文書で活用して書かれた形(といいます)の両方で照らす。 */
|
|
@@ -184,6 +208,13 @@ const definitionWordsOf = (doc: ProseDocument): DefinitionWords => {
|
|
|
184
208
|
return { markers: patternsOf(doc, "definition-marker"), verbs: [...verbs, ...conjugatedForms(doc.sentences, verbs)], alternatives };
|
|
185
209
|
};
|
|
186
210
|
|
|
211
|
+
/** 数える略語のすべての所。文書全体で読む書き方の範囲(所在地、文献一覧)と、編と区分で引く法令集(21 CFR subpart J)の中は外す。 */
|
|
212
|
+
const countedHitsOf = (doc: ProseDocument): AcronymHit[] =>
|
|
213
|
+
outsideSpans(acronymsOf(doc, notationOf(doc)), [
|
|
214
|
+
...sourceNotAcronymSpans(doc.source, (id) => patternsOf(doc, id)),
|
|
215
|
+
...titledCodeSpans(doc.source, patternsOf(doc, "citation-series")),
|
|
216
|
+
]);
|
|
217
|
+
|
|
187
218
|
const acronymFinding = (acronym: string, hit: Hit, count: number, limit: number): Finding => ({
|
|
188
219
|
rule: "undefined-acronym",
|
|
189
220
|
severity: "info",
|
|
@@ -203,7 +234,7 @@ const isNamePartAt = (acronym: string, hit: Hit): boolean => {
|
|
|
203
234
|
* 書き手が展開する文書では、展開の抜けは抜けとして読める。名前の一部の略語(SRI International)は、そのときも指さない。
|
|
204
235
|
*/
|
|
205
236
|
export const undefinedAcronym: Detector = (doc, options): Finding[] => {
|
|
206
|
-
const body = bodyOf(doc);
|
|
237
|
+
const body = halfWidth(bodyOf(doc));
|
|
207
238
|
// HTTP のメソッド名(GET)と SQL のキーワード(VIEW)は略語ではなく、税の名前(VAT、GST)は読み手が名前として知るので、通じる略語と同じく展開を求めない。
|
|
208
239
|
// 並べた名前(JAXA)も、繋いだ略語(JAXA-ISAS)の片割れとして説明済みに数える。
|
|
209
240
|
// 文書が自分で知らせた語(select を書いた文書の SELECT、リンクで引いた講演の場 [Jane Roe, FOSDEM 2024](…))も同じ。
|
|
@@ -211,6 +242,7 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
|
|
|
211
242
|
...(options.lexicon ?? []).map((entry) => entry.pattern),
|
|
212
243
|
...knownByDocument(doc.source, doc.links).concat(patternsOf(doc, "http-method"), patternsOf(doc, "sql-keyword"), patternsOf(doc, "tax-code")),
|
|
213
244
|
...(doc.names ?? []),
|
|
245
|
+
...citedSeriesOf(doc, body),
|
|
214
246
|
]);
|
|
215
247
|
const expandedAt = expansionAt(definitionWordsOf(doc));
|
|
216
248
|
const stated = statedAcronyms(doc.source, { statements: patternsOf(doc, "definition-statement"), markers: patternsOf(doc, "definition-marker") });
|
|
@@ -222,8 +254,20 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
|
|
|
222
254
|
);
|
|
223
255
|
// 略語のすぐ後ろのダッシュで挟んだ同格(the VIX—a measure of …—)、同じ文の前に書いた名前(Small Business Administration … SBA)、
|
|
224
256
|
// 2 つ以上の番号で引く続き物の名前(BCP 78、BCP 14)も、略語の説明と読む。
|
|
225
|
-
|
|
226
|
-
const headings = doc.sections.map((section) => section.heading);
|
|
257
|
+
// 文献一覧の見出し語([UNIX] The Open Group, "The Single UNIX Specification")と、見出しに番号で立てた書簡の続き物(### SR 26-8: …)も。
|
|
258
|
+
const headings = doc.sections.map((section) => halfWidth(section.heading));
|
|
259
|
+
const counted = countedHitsOf(doc);
|
|
260
|
+
// ファイルの種類の名前としてだけ書いた大文字(the MAP files、MAPファイル)も、展開を待つ略語ではない。
|
|
261
|
+
const entries = new Set([
|
|
262
|
+
...fileTypeNames(counted.map(fileUseOf), patternsOf(doc, "file-noun")),
|
|
263
|
+
...termEntryAcronyms(doc.source),
|
|
264
|
+
...stated,
|
|
265
|
+
...linkedListTerms(doc.source),
|
|
266
|
+
...spelled,
|
|
267
|
+
...explainedInText(body, doc.sentences),
|
|
268
|
+
...referenceEntryLabels(doc.source),
|
|
269
|
+
...headingSeries(headings),
|
|
270
|
+
]);
|
|
227
271
|
// 見出しが略語の名前を書き出していれば(## Federal Open Market Committee の下の FOMC)、説明済み。
|
|
228
272
|
const spelledInHeading = headingsSpellingOut(headings);
|
|
229
273
|
const explainedAsWritten = (word: string): boolean =>
|
|
@@ -242,10 +286,6 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
|
|
|
242
286
|
explained.set(word, known);
|
|
243
287
|
return known;
|
|
244
288
|
};
|
|
245
|
-
const counted = outsideSpans(acronymsOf(doc, notationOf(doc)), [
|
|
246
|
-
...sourceNotAcronymSpans(doc.source, (id) => patternsOf(doc, id)),
|
|
247
|
-
...titledCodeSpans(doc.source, patternsOf(doc, "citation-series")),
|
|
248
|
-
]);
|
|
249
289
|
const hits = outsideSpans(
|
|
250
290
|
counted,
|
|
251
291
|
unreportedAcronymSpans(doc.source, doc.sentences, doc.links, (id) => patternsOf(doc, id)),
|
|
@@ -73,15 +73,23 @@ const verbAt = (tokens: readonly Token[], range: TokenRange, end: number): numbe
|
|
|
73
73
|
return end - 1 > range.end && isVerbal(tokens[end - 1]) ? end - 1 : undefined;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
/** The first token after the verb at `at` and the auxiliaries and verbs that follow it (are addressed, should be fixed). */
|
|
77
|
+
const pastVerbs = (tokens: readonly Token[], at: number): number => {
|
|
78
|
+
const rest = tokens.slice(at + 1).findIndex((token) => !isVerbal(token));
|
|
79
|
+
return rest < 0 ? tokens.length : at + 1 + rest;
|
|
80
|
+
};
|
|
81
|
+
|
|
76
82
|
/**
|
|
77
83
|
* 最上級の名詞句が主語で、述語がどれかを指しているか(The best plan is the one you keep・The most important divergence is
|
|
78
|
-
* the second
|
|
84
|
+
* the second)、順番のどこに来るかを言うか(the most critical vulnerabilities are addressed first)。どれが一番なのかを決める
|
|
85
|
+
* 言い方で、一番だという主張ではない。
|
|
79
86
|
*/
|
|
80
87
|
export const pointsAtReferent = (tokens: readonly Token[], range: TokenRange, referents: Lexicon): boolean => {
|
|
81
88
|
const end = phraseEnd(tokens, range.end);
|
|
82
89
|
const at = verbAt(tokens, range, end);
|
|
83
90
|
if (at === undefined) return false;
|
|
84
|
-
const
|
|
91
|
+
const object = pastVerbs(tokens, at);
|
|
92
|
+
const next = tokens[object]?.pos === "DET" ? object + 1 : object;
|
|
85
93
|
return isWord(tokens[next], referents);
|
|
86
94
|
};
|
|
87
95
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// A list of titles written in sentence case (The bridge witch, The story of bubble gum, The law of finance and regulation). Pure.
|
|
2
|
+
import type { Token } from "../plugin.ts";
|
|
3
|
+
|
|
4
|
+
/** Items that open with a capitalised article after a comma or colon: a title's first word, not the writer's sentence. */
|
|
5
|
+
const TITLE_ITEMS = 2;
|
|
6
|
+
|
|
7
|
+
const ITEM_BREAKS: ReadonlySet<string> = new Set([",", ":"]);
|
|
8
|
+
|
|
9
|
+
const isCapitalised = (token: Token | undefined): boolean => /^\p{Lu}/u.test(token?.surface ?? "");
|
|
10
|
+
|
|
11
|
+
const opensTitle = (tokens: readonly Token[], at: number): boolean =>
|
|
12
|
+
at > 0 && tokens[at]?.pos === "DET" && isCapitalised(tokens[at]) && ITEM_BREAKS.has(tokens[at - 1]?.surface ?? "");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Whether the and / or at `at` is inside one of the titles: the sentence lists titles (two or more items open with a capitalised
|
|
16
|
+
* article mid-sentence) and the word after the and / or is lower case. The joint between two titles is followed by a capital.
|
|
17
|
+
*/
|
|
18
|
+
export const insideSentenceCaseTitle = (tokens: readonly Token[]): ((at: number) => boolean) => {
|
|
19
|
+
const titles = tokens.filter((__token, at) => opensTitle(tokens, at)).length;
|
|
20
|
+
return (at) => titles >= TITLE_ITEMS && /^\p{Ll}/u.test(tokens[at + 1]?.surface ?? "");
|
|
21
|
+
};
|
|
@@ -8,6 +8,7 @@ import { honorificGroupParticles } from "../honorific-group.ts";
|
|
|
8
8
|
import { setPhraseParticles } from "../set-phrase-particles.ts";
|
|
9
9
|
import { noteSentences } from "../note-paragraphs.ts";
|
|
10
10
|
import { documentNameSpans } from "./particle-run-names.ts";
|
|
11
|
+
import { isFlattenedTable } from "./sentence-parts.ts";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* 文末が名詞で終わる(体言止め)。箇条書きでは普通だが、本文では文が途中で切れて読める。
|
|
@@ -117,20 +118,23 @@ export const doubledParticle: Detector = (doc, options): Finding[] => {
|
|
|
117
118
|
setPhrases: (doc.lexicons[SET_PHRASE_LEXICON] ?? []).map((entry) => entry.pattern),
|
|
118
119
|
};
|
|
119
120
|
const prose = doc.prose ?? doc.source;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
121
|
+
// 平らにした表の文は、見出しのセル(役員の兼任等・営業上の取引・設備の賃貸借)の切れ目が見えず、別のセルの「の」が一つの連なりに見える。
|
|
122
|
+
return doc.sentences
|
|
123
|
+
.filter((sentence) => !isFlattenedTable(sentence.text))
|
|
124
|
+
.flatMap((sentence) => {
|
|
125
|
+
const tokens = chainTokens(sentence.tokens ?? [], numbering, phrases);
|
|
126
|
+
const quoted = [...quotedIn(sentence), ...titles];
|
|
127
|
+
const longRuns = (skipped: readonly Span[]): Run[] => runsOf(tokens, nesting, breaks, skipped).filter((run) => run.tokens.length > options.limit);
|
|
128
|
+
const found = longRuns(quoted);
|
|
129
|
+
// 文書の名前を読むのは長い連なりのある文だけ。名前は位置ごとに読むので、全部の文で読むと遅い。
|
|
130
|
+
const runs = found.length === 0 ? found : longRuns([...quoted, ...documentNameSpans(prose, sentence.span, doc.namedDocument)]);
|
|
131
|
+
return runs.map((run) => ({
|
|
132
|
+
rule: "no-doubled-joshi",
|
|
133
|
+
severity: "warning" as const,
|
|
134
|
+
line: 0,
|
|
135
|
+
column: 0,
|
|
136
|
+
quote: sentence.text.trim(),
|
|
137
|
+
values: { word: run.surface, count: run.tokens.length, limit: options.limit, offset: run.tokens[0]?.span.start ?? sentence.span.start },
|
|
138
|
+
}));
|
|
139
|
+
});
|
|
136
140
|
};
|
|
@@ -117,6 +117,12 @@ const VERSION_AFTER = /^[ \t]+v?\d+\.\d+\.\d+/u;
|
|
|
117
117
|
/** The word names what a release number follows (golang 1.21.5): a product or a tool, written as its makers write it. */
|
|
118
118
|
export const beforeVersion = (source: string, offset: number, word: string): boolean => VERSION_AFTER.test(source.slice(offset + word.length));
|
|
119
119
|
|
|
120
|
+
/** A journal's volume and issue (22 (3), 5(2)), after spaces. */
|
|
121
|
+
const VOLUME_AFTER = /^[ \t]+\d+[ \t]*\(\d+\)/u;
|
|
122
|
+
|
|
123
|
+
/** The word ends a journal's title before its volume and issue (Biochemia medica 22 (3)): the title as the journal writes it, often Latin. */
|
|
124
|
+
export const beforeVolume = (source: string, offset: number, word: string): boolean => VOLUME_AFTER.test(source.slice(offset + word.length));
|
|
125
|
+
|
|
120
126
|
/** Two words of one length that differ in one letter only. */
|
|
121
127
|
const oneLetterApart = (left: string, right: string): boolean =>
|
|
122
128
|
left.length === right.length && [...left].filter((letter, index) => letter !== right.charAt(index)).length === 1;
|
|
@@ -6,6 +6,7 @@ import { quoteAt } from "./structure-tree.ts";
|
|
|
6
6
|
import {
|
|
7
7
|
addressWordsOf,
|
|
8
8
|
beforeVersion,
|
|
9
|
+
beforeVolume,
|
|
9
10
|
besideForeignWord,
|
|
10
11
|
hasDrugStem,
|
|
11
12
|
hasSiblingName,
|
|
@@ -53,9 +54,16 @@ export const codeWordsOf = (source: string): Set<string> => {
|
|
|
53
54
|
/** 辞書の語か、派生した語に活用の語尾を付けた語(operationalises、rightsized)か、四字以上の辞書の語二つを続けた語(crowdwork)。 */
|
|
54
55
|
const isFormedWord = (word: string, speller: Speller): boolean => isKnownWord(word, speller) || hasTwoEndings(word, speller) || isClosedCompound(word, speller);
|
|
55
56
|
|
|
56
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* 置かれた場所から、名前や用語と分かる語。名指した語("mailto"、(jchaplin))、検索語の並び(vaccin*)、外国語の句(bête noire)、
|
|
59
|
+
* 版の番号の前(golang 1.21.5)、誌の巻と号の前(Biochemia medica 22 (3))。
|
|
60
|
+
*/
|
|
57
61
|
const isTermByPlace = (source: string, offset: number, word: string): boolean =>
|
|
58
|
-
isMention(source, offset, word) ||
|
|
62
|
+
isMention(source, offset, word) ||
|
|
63
|
+
inSearchTermList(source, offset) ||
|
|
64
|
+
besideForeignWord(source, offset, word) ||
|
|
65
|
+
beforeVersion(source, offset, word) ||
|
|
66
|
+
beforeVolume(source, offset, word);
|
|
59
67
|
|
|
60
68
|
/**
|
|
61
69
|
* 辞書に無い英語の語で、一字違いの辞書の語があるもの(recieve → receive)。辞書は adapter が持ち、無い言語では動かない。
|
package/src/plugin.ts
CHANGED
|
@@ -75,6 +75,8 @@ export type LexiconEntry = {
|
|
|
75
75
|
readonly first_year?: number | undefined;
|
|
76
76
|
/** The genres or groups the entry holds in (legal, blog/tech). Without them, every genre. A detector reads them with entriesForGenre. */
|
|
77
77
|
readonly genres?: readonly string[] | undefined;
|
|
78
|
+
/** The entry counts only in a heading: a title phrase that body text uses plainly. A detector that reads headings honours it. */
|
|
79
|
+
readonly heading_only?: boolean | undefined;
|
|
78
80
|
/** pattern を adapter が語に分けたもの。品詞が読めるときだけ core が入れる。語彙表を書く側は書かない。 */
|
|
79
81
|
readonly tokens?: readonly Token[] | undefined;
|
|
80
82
|
};
|
package/src/rule-of-three.ts
CHANGED
|
@@ -4,13 +4,15 @@ import type { BulletList } from "./plugin.ts";
|
|
|
4
4
|
* rule-of-three の数え方。箇条書きのうち、ちょうど 3 項目のものがどれだけあるか。
|
|
5
5
|
* すぐ下の行が「など」「etc.」で始まる箇条書きは、書いた 3 つより多くあると書き手が言っている。ちょうど 3 項目とは数えない。
|
|
6
6
|
* 箇条書きが少ないと、1 つで割合が大きく動く(4 つなら 25 ポイント)。そのときは全部が 3 項目のときだけ報告する。
|
|
7
|
+
* 2 つでも測る。生成文の報告書は「要因 3 つ」「提言 3 つ」の 2 つの箇条書きで終わることが多く、人の文書で 2 つとも 3 項目は少ない。
|
|
8
|
+
* 本文の最初の文より前の箇条書き(題・日付・見出しのすぐ下の要点や概要)は数えない。項目の数はサイトの型が決めている。
|
|
7
9
|
*/
|
|
8
10
|
export type ThreeShare = { readonly count: number; readonly total: number; readonly share: number; readonly first: BulletList };
|
|
9
11
|
|
|
10
12
|
const PERCENT = 100;
|
|
11
13
|
const THREE = 3;
|
|
12
14
|
/** これより少ない箇条書きは測らない。 */
|
|
13
|
-
const MIN_LISTS =
|
|
15
|
+
const MIN_LISTS = 2;
|
|
14
16
|
/** これより少ない箇条書きでは、割合では判断せず、全部が 3 項目のときだけ報告する。 */
|
|
15
17
|
export const MIN_LISTS_FOR_SHARE = 5;
|
|
16
18
|
|
|
@@ -36,11 +38,23 @@ export const continuesBeyond = (source: string, list: BulletList, openWords: rea
|
|
|
36
38
|
return openWords.some((word) => startsWithWord(next, word));
|
|
37
39
|
};
|
|
38
40
|
|
|
41
|
+
/** 見出し・箇条書きの項目・表の行。本文の文ではない。 */
|
|
42
|
+
const NOT_PROSE_LINE = /^\s*(?:#{1,6}\s|[=-]{3,}\s*$|(?:[-*+]|\d+[.)])\s|\|)/u;
|
|
43
|
+
/** 文の終わり(句点・ピリオド・コロン)で閉じる行。閉じ括弧や強調の記号が後ろに付いてもよい。 */
|
|
44
|
+
const SENTENCE_END = /[.。!?!?::][\s"'”’」』))*_]*$/u;
|
|
45
|
+
|
|
46
|
+
const isProseLine = (line: string): boolean => !NOT_PROSE_LINE.test(line) && SENTENCE_END.test(line.trim());
|
|
47
|
+
|
|
48
|
+
/** 本文の最初の文がある行の頭。それより前は題・日付・見出しだけ。文が無ければ文書の終わり。 */
|
|
49
|
+
export const firstProseOffset = (source: string): number => [...source.matchAll(/^.*$/gmu)].find(([line]) => isProseLine(line))?.index ?? source.length;
|
|
50
|
+
|
|
39
51
|
const isExactlyThree = (source: string, list: BulletList, openWords: readonly string[]): boolean =>
|
|
40
52
|
list.items.length === THREE && !continuesBeyond(source, list, openWords);
|
|
41
53
|
|
|
42
54
|
/** 報告するときの数。報告しないときは undefined。 */
|
|
43
|
-
export const threeShare = (source: string,
|
|
55
|
+
export const threeShare = (source: string, allLists: readonly BulletList[], openWords: readonly string[], limit: number): ThreeShare | undefined => {
|
|
56
|
+
const bodyStart = firstProseOffset(source);
|
|
57
|
+
const lists = allLists.filter((list) => list.span.start >= bodyStart);
|
|
44
58
|
const threes = lists.filter((list) => isExactlyThree(source, list, openWords));
|
|
45
59
|
const first = threes[0];
|
|
46
60
|
if (lists.length < MIN_LISTS || first === undefined) return undefined;
|
package/src/run.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { PatternTimeout } from "./custom/pattern-timeout.ts";
|
|
|
19
19
|
import { PluginRuleFailure } from "./extension/module-detector.ts";
|
|
20
20
|
import { failureReason } from "./extension/failure-text.ts";
|
|
21
21
|
import { tagCoverage } from "./tag-coverage.ts";
|
|
22
|
+
import { compositeSignals } from "./composite-signals.ts";
|
|
22
23
|
|
|
23
24
|
export type Skipped = {
|
|
24
25
|
readonly rule: string;
|
|
@@ -210,9 +211,10 @@ export const place = (starts: readonly number[], finding: Finding): Finding => {
|
|
|
210
211
|
* まとめるために消すと本物の指摘が見えなくなる。
|
|
211
212
|
*/
|
|
212
213
|
const compositeOf = (rule: RuleDefinition, found: readonly Finding[], limit: number, starts: readonly number[], language: string): Finding[] => {
|
|
213
|
-
const fired = rule.from
|
|
214
|
+
const fired = compositeSignals(rule.from, found);
|
|
214
215
|
if (fired.length < limit) return [];
|
|
215
|
-
|
|
216
|
+
// 数えなかった signal も含めて、最初に出た所に置く。同じ形を 1 種に数えても、指摘の位置は動かない。
|
|
217
|
+
const first = found.find((finding) => rule.from.includes(finding.rule));
|
|
216
218
|
return [
|
|
217
219
|
place(starts, {
|
|
218
220
|
rule: rule.id,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Lexicon, Section } from "../plugin.ts";
|
|
2
|
+
import { containsWord, headingWords } from "./heading-words.ts";
|
|
3
|
+
|
|
4
|
+
/** A heading still open at a point of the outline: its depth, and whether it is a question-and-answer heading. */
|
|
5
|
+
type Open = { readonly depth: number; readonly faq: boolean };
|
|
6
|
+
|
|
7
|
+
const isFaqHeading = (heading: string, faqHeadings: Lexicon): boolean =>
|
|
8
|
+
faqHeadings.some((entry) => containsWord(headingWords(heading), entry.pattern.toLowerCase()));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether each section stands under a question-and-answer heading (FAQ, よくある質問), at any depth below it. An FAQ's
|
|
12
|
+
* headings are its readers' questions, so the form they take is not the writer's.
|
|
13
|
+
*/
|
|
14
|
+
export const underFaq = (headed: readonly Section[], faqHeadings: Lexicon): boolean[] =>
|
|
15
|
+
headed
|
|
16
|
+
.reduce<{ readonly open: readonly Open[]; readonly under: readonly boolean[] }>(
|
|
17
|
+
(outline, section) => {
|
|
18
|
+
const ancestors = outline.open.filter((open) => open.depth < section.depth);
|
|
19
|
+
const faq = isFaqHeading(section.heading, faqHeadings);
|
|
20
|
+
return { open: [...ancestors, { depth: section.depth, faq }], under: [...outline.under, ancestors.some((open) => open.faq)] };
|
|
21
|
+
},
|
|
22
|
+
{ open: [], under: [] },
|
|
23
|
+
)
|
|
24
|
+
.under.slice();
|
|
@@ -5,6 +5,7 @@ import { boldLabelItems } from "../detectors/bold-label.ts";
|
|
|
5
5
|
import { MIN_DOCUMENT_LENGTH } from "../detectors/signals.ts";
|
|
6
6
|
import { bookendOf, headingFormOf, headingWords, proConPairs } from "./heading-words.ts";
|
|
7
7
|
import { restatementPercent } from "./restatement.ts";
|
|
8
|
+
import { underFaq } from "./faq-sections.ts";
|
|
8
9
|
|
|
9
10
|
/** The structure measures, in the order they are shown. */
|
|
10
11
|
export const FEATURE_IDS = [
|
|
@@ -116,9 +117,10 @@ const mostCommon = (forms: readonly string[]): string | undefined => {
|
|
|
116
117
|
return [...counts.entries()].toSorted((left, right) => right[1] - left[1])[0]?.[0];
|
|
117
118
|
};
|
|
118
119
|
|
|
119
|
-
const headingForms = (doc: ProseDocument, words: readonly string[]): FeatureValue => {
|
|
120
|
+
const headingForms = (doc: ProseDocument, headed: readonly Section[], words: readonly string[]): FeatureValue => {
|
|
120
121
|
const bookends = lexiconOf(doc, "bookend-heading");
|
|
121
|
-
const
|
|
122
|
+
const asked = underFaq(headed, lexiconOf(doc, "faq-heading"));
|
|
123
|
+
const body = words.filter((heading, index) => asked[index] !== true && bookendOf(heading, bookends) === undefined);
|
|
122
124
|
if (body.length < MIN_HEADINGS) return notMeasured("heading-forms", "too-few-headings");
|
|
123
125
|
const forms = body.flatMap((heading) => headingFormOf(heading, lexiconOf(doc, "heading-form"))?.pattern ?? []);
|
|
124
126
|
return measured("heading-forms", percentOf(forms.length, body.length), mostCommon(forms));
|
|
@@ -177,7 +179,7 @@ export const structureFeaturesOf = (doc: ProseDocument): FeatureValue[] => {
|
|
|
177
179
|
headingDensity(doc, headed),
|
|
178
180
|
shortSections(doc, headed),
|
|
179
181
|
sectionUniformity(doc),
|
|
180
|
-
headingForms(doc, words),
|
|
182
|
+
headingForms(doc, headed, words),
|
|
181
183
|
threeSubsections(headed),
|
|
182
184
|
bookends(doc, words),
|
|
183
185
|
closingRestatement(doc, headed),
|
|
@@ -32,3 +32,15 @@ export const templateSectionsOf = (headings: readonly string[], lexicon: Lexicon
|
|
|
32
32
|
|
|
33
33
|
/** Whether the outline is the template: enough of its sections stand as headings. */
|
|
34
34
|
export const isTemplateOutline = (sections: readonly string[]): boolean => sections.length >= TEMPLATE_SECTIONS;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The share of the headings that must be template sections before the template is the whole outline. A real proposal
|
|
38
|
+
* that uses the template's sections keeps them among headings of its own; a generated one has little else.
|
|
39
|
+
*/
|
|
40
|
+
export const WHOLE_TEMPLATE_SHARE = 0.75;
|
|
41
|
+
|
|
42
|
+
/** Whether the template outline is the whole outline: nearly every heading is one of its sections, the writer's own words nearly absent. */
|
|
43
|
+
export const isWholeTemplateOutline = (headings: readonly string[], lexicon: Lexicon): boolean => {
|
|
44
|
+
const inTemplate = headings.filter((words) => sectionOf(words, lexicon) !== undefined).length;
|
|
45
|
+
return isTemplateOutline(templateSectionsOf(headings, lexicon)) && inTemplate >= headings.length * WHOLE_TEMPLATE_SHARE;
|
|
46
|
+
};
|
package/src/topic-clause.ts
CHANGED
|
@@ -215,6 +215,29 @@ const closesWithItemMark = (tokens: readonly Token[], at: number): boolean => {
|
|
|
215
215
|
return next !== -1 && CIRCLED.test(tokens[next]?.surface ?? "");
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
/** A copula, past or not, just before at: 日本であった, 日本だ, 日本です. */
|
|
219
|
+
const copulaEndsBefore = (tokens: readonly Token[], at: number): boolean => {
|
|
220
|
+
const end = tokens[at - 1]?.surface === "た" && tokens[at - 1]?.pos === "AUX" ? at - 1 : at;
|
|
221
|
+
const before = tokens[end - 1];
|
|
222
|
+
return copulaBefore(tokens, end) || (before?.surface === "だ" && before.lemma === "だ");
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/** The nominaliser の a cleft's topic stands on (来てほしいのは). */
|
|
226
|
+
const isCleftTopic = (tokens: readonly Token[], topic: number): boolean =>
|
|
227
|
+
tokens[topic - 1]?.surface === "の" && tokens[topic - 1]?.features?.["NounType"] === "Dependent";
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 来てほしいのは…日本であったというような調査の結果、…: a cleft whose focus the copula names, with no subject of its own between,
|
|
231
|
+
* inside a clause that という makes a noun's content, and that noun phrase ends at a comma. The cleft is said within the
|
|
232
|
+
* phrase; the rest of the sentence is about something else. という followed by a comma (〜であるという、…考えです) goes on.
|
|
233
|
+
*/
|
|
234
|
+
const closesCleftInNounPhrase = (tokens: readonly Token[], topic: number, at: number, last: number): boolean => {
|
|
235
|
+
if (tokens[at]?.surface !== "という" || !isCleftTopic(tokens, topic) || !copulaEndsBefore(tokens, at)) return false;
|
|
236
|
+
if (subjectBetween(tokens, topic, at)) return false;
|
|
237
|
+
const comma = tokens.findIndex((token, index) => index > at && index < last && isComma(token));
|
|
238
|
+
return comma > at + 1 && isOwnNoun(tokens[comma - 1]);
|
|
239
|
+
};
|
|
240
|
+
|
|
218
241
|
/**
|
|
219
242
|
* The index of the word that ends the topic's own clause, between the topic and the sentence's last word, or undefined when the
|
|
220
243
|
* topic's predicate is the one the sentence ends on.
|
|
@@ -227,7 +250,8 @@ export const topicClauseEnd = (tokens: readonly Token[], topic: number, last: nu
|
|
|
227
250
|
closesFirstClauseWithNoun(tokens, topic, at, last) ||
|
|
228
251
|
closesWithPoliteGa(tokens, topic, at, last) ||
|
|
229
252
|
closesAfterPredicate(tokens, topic, at, words) ||
|
|
230
|
-
closesWithItemMark(tokens, at)
|
|
253
|
+
closesWithItemMark(tokens, at) ||
|
|
254
|
+
closesCleftInNounPhrase(tokens, topic, at, last);
|
|
231
255
|
const end = tokens.findIndex((_, at) => at > topic && at < last && closes(at));
|
|
232
256
|
return end === -1 ? undefined : end;
|
|
233
257
|
};
|