chaffjs 0.38.0 → 0.39.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/README.ja.md +20 -4
- package/README.md +19 -2
- package/checks/ai-tells.yaml +153 -0
- package/dist/acronym-expansion.d.ts +4 -0
- package/dist/acronym-expansion.d.ts.map +1 -0
- package/dist/acronym-expansion.js +46 -0
- package/dist/acronym-expansion.js.map +1 -0
- package/dist/ai-score/human-shares.d.ts.map +1 -1
- package/dist/ai-score/human-shares.js +53 -12
- package/dist/ai-score/human-shares.js.map +1 -1
- package/dist/ai-score/of-document.d.ts.map +1 -1
- package/dist/ai-score/of-document.js +4 -2
- package/dist/ai-score/of-document.js.map +1 -1
- package/dist/body-section.d.ts +3 -1
- package/dist/body-section.d.ts.map +1 -1
- package/dist/body-section.js +9 -2
- package/dist/body-section.js.map +1 -1
- package/dist/capitals-with-small.d.ts +5 -0
- package/dist/capitals-with-small.d.ts.map +1 -1
- package/dist/capitals-with-small.js +15 -0
- package/dist/capitals-with-small.js.map +1 -1
- package/dist/checks.d.ts +11 -0
- package/dist/checks.d.ts.map +1 -1
- package/dist/checks.js +27 -1
- package/dist/checks.js.map +1 -1
- package/dist/cli-args.js +1 -1
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-text.d.ts.map +1 -1
- package/dist/cli-text.js +4 -0
- package/dist/cli-text.js.map +1 -1
- package/dist/commands/fix-plan.d.ts.map +1 -1
- package/dist/commands/fix-plan.js +64 -4
- package/dist/commands/fix-plan.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +16 -2
- package/dist/commands/test.js.map +1 -1
- package/dist/detectors/acronym-context.d.ts +4 -1
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +16 -2
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/acronym-expansion.d.ts.map +1 -1
- package/dist/detectors/acronym-expansion.js +25 -0
- package/dist/detectors/acronym-expansion.js.map +1 -1
- package/dist/detectors/acronym-gloss.d.ts +19 -0
- package/dist/detectors/acronym-gloss.d.ts.map +1 -1
- package/dist/detectors/acronym-gloss.js +115 -0
- package/dist/detectors/acronym-gloss.js.map +1 -1
- package/dist/detectors/acronym-name.d.ts +9 -2
- package/dist/detectors/acronym-name.d.ts.map +1 -1
- package/dist/detectors/acronym-name.js +13 -3
- package/dist/detectors/acronym-name.js.map +1 -1
- package/dist/detectors/acronym-series.d.ts +7 -0
- package/dist/detectors/acronym-series.d.ts.map +1 -0
- package/dist/detectors/acronym-series.js +25 -0
- package/dist/detectors/acronym-series.js.map +1 -0
- package/dist/detectors/ai-phrasing.d.ts +3 -6
- package/dist/detectors/ai-phrasing.d.ts.map +1 -1
- package/dist/detectors/ai-phrasing.js +17 -16
- package/dist/detectors/ai-phrasing.js.map +1 -1
- package/dist/detectors/ai-structure.d.ts +1 -0
- package/dist/detectors/ai-structure.d.ts.map +1 -1
- package/dist/detectors/ai-structure.js +15 -4
- package/dist/detectors/ai-structure.js.map +1 -1
- package/dist/detectors/alnum-number.d.ts +1 -0
- package/dist/detectors/alnum-number.d.ts.map +1 -1
- package/dist/detectors/alnum-number.js +7 -3
- package/dist/detectors/alnum-number.js.map +1 -1
- package/dist/detectors/bare-comparative.d.ts +6 -0
- package/dist/detectors/bare-comparative.d.ts.map +1 -1
- package/dist/detectors/bare-comparative.js +31 -12
- package/dist/detectors/bare-comparative.js.map +1 -1
- package/dist/detectors/bold-emphasis-form.d.ts +8 -0
- package/dist/detectors/bold-emphasis-form.d.ts.map +1 -0
- package/dist/detectors/bold-emphasis-form.js +40 -0
- package/dist/detectors/bold-emphasis-form.js.map +1 -0
- package/dist/detectors/bold-emphasis.d.ts +0 -1
- package/dist/detectors/bold-emphasis.d.ts.map +1 -1
- package/dist/detectors/bold-emphasis.js +14 -12
- package/dist/detectors/bold-emphasis.js.map +1 -1
- package/dist/detectors/caps-caption.d.ts +5 -0
- package/dist/detectors/caps-caption.d.ts.map +1 -1
- package/dist/detectors/caps-caption.js +20 -2
- package/dist/detectors/caps-caption.js.map +1 -1
- package/dist/detectors/char-shape.d.ts.map +1 -1
- package/dist/detectors/char-shape.js +86 -27
- package/dist/detectors/char-shape.js.map +1 -1
- package/dist/detectors/chat-log-line.d.ts +8 -0
- package/dist/detectors/chat-log-line.d.ts.map +1 -0
- package/dist/detectors/chat-log-line.js +13 -0
- package/dist/detectors/chat-log-line.js.map +1 -0
- package/dist/detectors/citation-string.d.ts +3 -0
- package/dist/detectors/citation-string.d.ts.map +1 -0
- package/dist/detectors/citation-string.js +34 -0
- package/dist/detectors/citation-string.js.map +1 -0
- package/dist/detectors/closing-cliche.d.ts +18 -0
- package/dist/detectors/closing-cliche.d.ts.map +1 -0
- package/dist/detectors/closing-cliche.js +58 -0
- package/dist/detectors/closing-cliche.js.map +1 -0
- package/dist/detectors/closing-exhortation.d.ts +18 -0
- package/dist/detectors/closing-exhortation.d.ts.map +1 -0
- package/dist/detectors/closing-exhortation.js +55 -0
- package/dist/detectors/closing-exhortation.js.map +1 -0
- package/dist/detectors/cold-open.d.ts +25 -0
- package/dist/detectors/cold-open.d.ts.map +1 -0
- package/dist/detectors/cold-open.js +121 -0
- package/dist/detectors/cold-open.js.map +1 -0
- package/dist/detectors/comparative-context.d.ts +21 -0
- package/dist/detectors/comparative-context.d.ts.map +1 -0
- package/dist/detectors/comparative-context.js +57 -0
- package/dist/detectors/comparative-context.js.map +1 -0
- package/dist/detectors/concrete-evidence-density.d.ts +3 -0
- package/dist/detectors/concrete-evidence-density.d.ts.map +1 -0
- package/dist/detectors/concrete-evidence-density.js +75 -0
- package/dist/detectors/concrete-evidence-density.js.map +1 -0
- package/dist/detectors/concrete-evidence.d.ts +14 -0
- package/dist/detectors/concrete-evidence.d.ts.map +1 -1
- package/dist/detectors/concrete-evidence.js +24 -0
- package/dist/detectors/concrete-evidence.js.map +1 -1
- package/dist/detectors/contrast-frame.d.ts +5 -0
- package/dist/detectors/contrast-frame.d.ts.map +1 -1
- package/dist/detectors/contrast-frame.js +53 -6
- package/dist/detectors/contrast-frame.js.map +1 -1
- package/dist/detectors/coordinate-adjective.d.ts +2 -1
- package/dist/detectors/coordinate-adjective.d.ts.map +1 -1
- package/dist/detectors/coordinate-adjective.js +4 -2
- package/dist/detectors/coordinate-adjective.js.map +1 -1
- package/dist/detectors/duplicate-heading.d.ts +4 -2
- package/dist/detectors/duplicate-heading.d.ts.map +1 -1
- package/dist/detectors/duplicate-heading.js +35 -11
- package/dist/detectors/duplicate-heading.js.map +1 -1
- package/dist/detectors/email-frame-words.d.ts +10 -0
- package/dist/detectors/email-frame-words.d.ts.map +1 -0
- package/dist/detectors/email-frame-words.js +34 -0
- package/dist/detectors/email-frame-words.js.map +1 -0
- package/dist/detectors/email-letter.d.ts +3 -7
- package/dist/detectors/email-letter.d.ts.map +1 -1
- package/dist/detectors/email-letter.js +13 -21
- package/dist/detectors/email-letter.js.map +1 -1
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
- package/dist/detectors/fullwidth-alnum.js +20 -4
- package/dist/detectors/fullwidth-alnum.js.map +1 -1
- package/dist/detectors/gram-furniture.d.ts +18 -1
- package/dist/detectors/gram-furniture.d.ts.map +1 -1
- package/dist/detectors/gram-furniture.js +71 -0
- package/dist/detectors/gram-furniture.js.map +1 -1
- package/dist/detectors/gram-openers.d.ts +16 -0
- package/dist/detectors/gram-openers.d.ts.map +1 -1
- package/dist/detectors/gram-openers.js +52 -0
- 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 +40 -7
- package/dist/detectors/gram-predicate.js.map +1 -1
- package/dist/detectors/gram-repetition.d.ts +3 -0
- package/dist/detectors/gram-repetition.d.ts.map +1 -0
- package/dist/detectors/gram-repetition.js +158 -0
- package/dist/detectors/gram-repetition.js.map +1 -0
- package/dist/detectors/heading-level-skip.d.ts +6 -0
- package/dist/detectors/heading-level-skip.d.ts.map +1 -1
- package/dist/detectors/heading-level-skip.js +24 -1
- package/dist/detectors/heading-level-skip.js.map +1 -1
- package/dist/detectors/heading-numbering.js +2 -2
- package/dist/detectors/heading-numbering.js.map +1 -1
- package/dist/detectors/hyphen-copied-text.d.ts +3 -0
- package/dist/detectors/hyphen-copied-text.d.ts.map +1 -0
- package/dist/detectors/hyphen-copied-text.js +49 -0
- package/dist/detectors/hyphen-copied-text.js.map +1 -0
- package/dist/detectors/kanji-name-edge.d.ts +15 -0
- package/dist/detectors/kanji-name-edge.d.ts.map +1 -1
- package/dist/detectors/kanji-name-edge.js +30 -0
- package/dist/detectors/kanji-name-edge.js.map +1 -1
- package/dist/detectors/kanji-run-pieces.d.ts +7 -0
- package/dist/detectors/kanji-run-pieces.d.ts.map +1 -1
- package/dist/detectors/kanji-run-pieces.js +14 -4
- package/dist/detectors/kanji-run-pieces.js.map +1 -1
- package/dist/detectors/kutoten-consistency.d.ts.map +1 -1
- package/dist/detectors/kutoten-consistency.js +22 -4
- package/dist/detectors/kutoten-consistency.js.map +1 -1
- package/dist/detectors/lead-in-dash.d.ts +5 -0
- package/dist/detectors/lead-in-dash.d.ts.map +1 -1
- package/dist/detectors/lead-in-dash.js +9 -0
- package/dist/detectors/lead-in-dash.js.map +1 -1
- package/dist/detectors/letter-joined-name.d.ts +2 -0
- package/dist/detectors/letter-joined-name.d.ts.map +1 -1
- package/dist/detectors/letter-joined-name.js +8 -0
- package/dist/detectors/letter-joined-name.js.map +1 -1
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +11 -2
- package/dist/detectors/lexicon.js.map +1 -1
- package/dist/detectors/list-item.d.ts +14 -0
- package/dist/detectors/list-item.d.ts.map +1 -1
- package/dist/detectors/list-item.js +30 -1
- package/dist/detectors/list-item.js.map +1 -1
- package/dist/detectors/list-items.d.ts +1 -1
- package/dist/detectors/list-items.d.ts.map +1 -1
- package/dist/detectors/list-items.js +2 -0
- package/dist/detectors/list-items.js.map +1 -1
- package/dist/detectors/list-joint.d.ts +18 -0
- package/dist/detectors/list-joint.d.ts.map +1 -0
- package/dist/detectors/list-joint.js +42 -0
- package/dist/detectors/list-joint.js.map +1 -0
- package/dist/detectors/list-layout.d.ts +14 -0
- package/dist/detectors/list-layout.d.ts.map +1 -0
- package/dist/detectors/list-layout.js +29 -0
- package/dist/detectors/list-layout.js.map +1 -0
- package/dist/detectors/list-lead-in.d.ts +6 -1
- package/dist/detectors/list-lead-in.d.ts.map +1 -1
- package/dist/detectors/list-lead-in.js +42 -2
- package/dist/detectors/list-lead-in.js.map +1 -1
- package/dist/detectors/list-parallel.d.ts +6 -0
- package/dist/detectors/list-parallel.d.ts.map +1 -1
- package/dist/detectors/list-parallel.js +106 -13
- package/dist/detectors/list-parallel.js.map +1 -1
- package/dist/detectors/list-run.d.ts +13 -0
- package/dist/detectors/list-run.d.ts.map +1 -0
- package/dist/detectors/list-run.js +80 -0
- package/dist/detectors/list-run.js.map +1 -0
- package/dist/detectors/list-sentence.d.ts +11 -0
- package/dist/detectors/list-sentence.d.ts.map +1 -1
- package/dist/detectors/list-sentence.js +1 -0
- package/dist/detectors/list-sentence.js.map +1 -1
- package/dist/detectors/mark-shape.d.ts +2 -1
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +10 -6
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/name-run.d.ts +2 -0
- package/dist/detectors/name-run.d.ts.map +1 -1
- package/dist/detectors/name-run.js +1 -1
- package/dist/detectors/name-run.js.map +1 -1
- package/dist/detectors/name-variant-two-things.d.ts +18 -0
- package/dist/detectors/name-variant-two-things.d.ts.map +1 -0
- package/dist/detectors/name-variant-two-things.js +84 -0
- package/dist/detectors/name-variant-two-things.js.map +1 -0
- package/dist/detectors/name-variant.d.ts.map +1 -1
- package/dist/detectors/name-variant.js +14 -15
- package/dist/detectors/name-variant.js.map +1 -1
- package/dist/detectors/organisation-run.d.ts +6 -0
- package/dist/detectors/organisation-run.d.ts.map +1 -1
- package/dist/detectors/organisation-run.js +26 -2
- package/dist/detectors/organisation-run.js.map +1 -1
- package/dist/detectors/orthographic-variant-open.d.ts +35 -0
- package/dist/detectors/orthographic-variant-open.d.ts.map +1 -0
- package/dist/detectors/orthographic-variant-open.js +79 -0
- package/dist/detectors/orthographic-variant-open.js.map +1 -0
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +55 -59
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/over-general-claim.d.ts.map +1 -1
- package/dist/detectors/over-general-claim.js +82 -4
- package/dist/detectors/over-general-claim.js.map +1 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +61 -27
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/particle-run-names.d.ts +8 -0
- package/dist/detectors/particle-run-names.d.ts.map +1 -0
- package/dist/detectors/particle-run-names.js +17 -0
- package/dist/detectors/particle-run-names.js.map +1 -0
- package/dist/detectors/proper-noun-density.d.ts +13 -0
- package/dist/detectors/proper-noun-density.d.ts.map +1 -0
- package/dist/detectors/proper-noun-density.js +97 -0
- package/dist/detectors/proper-noun-density.js.map +1 -0
- package/dist/detectors/quoted-excerpt.d.ts +13 -0
- package/dist/detectors/quoted-excerpt.d.ts.map +1 -0
- package/dist/detectors/quoted-excerpt.js +53 -0
- package/dist/detectors/quoted-excerpt.js.map +1 -0
- package/dist/detectors/reference-entry.d.ts +7 -0
- package/dist/detectors/reference-entry.d.ts.map +1 -0
- package/dist/detectors/reference-entry.js +35 -0
- package/dist/detectors/reference-entry.js.map +1 -0
- package/dist/detectors/register-neutral-shape.d.ts +5 -2
- package/dist/detectors/register-neutral-shape.d.ts.map +1 -1
- package/dist/detectors/register-neutral-shape.js +21 -4
- package/dist/detectors/register-neutral-shape.js.map +1 -1
- package/dist/detectors/register-set-apart.d.ts +24 -0
- package/dist/detectors/register-set-apart.d.ts.map +1 -0
- package/dist/detectors/register-set-apart.js +102 -0
- package/dist/detectors/register-set-apart.js.map +1 -0
- package/dist/detectors/register-voice.d.ts +14 -0
- package/dist/detectors/register-voice.d.ts.map +1 -0
- package/dist/detectors/register-voice.js +47 -0
- package/dist/detectors/register-voice.js.map +1 -0
- package/dist/detectors/register.d.ts +5 -0
- package/dist/detectors/register.d.ts.map +1 -1
- package/dist/detectors/register.js +13 -0
- package/dist/detectors/register.js.map +1 -1
- package/dist/detectors/registry/closing-cliche.d.ts +3 -0
- package/dist/detectors/registry/closing-cliche.d.ts.map +1 -0
- package/dist/detectors/registry/closing-cliche.js +3 -0
- package/dist/detectors/registry/closing-cliche.js.map +1 -0
- package/dist/detectors/registry/closing-exhortation.d.ts +3 -0
- package/dist/detectors/registry/closing-exhortation.d.ts.map +1 -0
- package/dist/detectors/registry/closing-exhortation.js +3 -0
- package/dist/detectors/registry/closing-exhortation.js.map +1 -0
- package/dist/detectors/registry/cold-open.d.ts +3 -0
- package/dist/detectors/registry/cold-open.d.ts.map +1 -0
- package/dist/detectors/registry/cold-open.js +3 -0
- package/dist/detectors/registry/cold-open.js.map +1 -0
- package/dist/detectors/registry/colon-lead-in.js +1 -1
- package/dist/detectors/registry/colon-lead-in.js.map +1 -1
- package/dist/detectors/registry/concrete-evidence.js +1 -1
- package/dist/detectors/registry/concrete-evidence.js.map +1 -1
- package/dist/detectors/registry/ngram-repetition.js +1 -1
- package/dist/detectors/registry/ngram-repetition.js.map +1 -1
- package/dist/detectors/registry/proper-noun-density.js +1 -1
- package/dist/detectors/registry/proper-noun-density.js.map +1 -1
- package/dist/detectors/registry/topic-predicate-distance.js +1 -1
- package/dist/detectors/registry/topic-predicate-distance.js.map +1 -1
- package/dist/detectors/registry/unprompted-denial.d.ts +3 -0
- package/dist/detectors/registry/unprompted-denial.d.ts.map +1 -0
- package/dist/detectors/registry/unprompted-denial.js +3 -0
- package/dist/detectors/registry/unprompted-denial.js.map +1 -0
- package/dist/detectors/sentence-ending.d.ts +6 -1
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +42 -9
- package/dist/detectors/sentence-ending.js.map +1 -1
- package/dist/detectors/sentence-length.d.ts.map +1 -1
- package/dist/detectors/sentence-length.js +25 -10
- package/dist/detectors/sentence-length.js.map +1 -1
- package/dist/detectors/sentence-load.d.ts +5 -3
- package/dist/detectors/sentence-load.d.ts.map +1 -1
- package/dist/detectors/sentence-load.js +3 -5
- package/dist/detectors/sentence-load.js.map +1 -1
- package/dist/detectors/sentence-parts.d.ts +9 -0
- package/dist/detectors/sentence-parts.d.ts.map +1 -0
- package/dist/detectors/sentence-parts.js +62 -0
- package/dist/detectors/sentence-parts.js.map +1 -0
- package/dist/detectors/sentence-title.d.ts +3 -0
- package/dist/detectors/sentence-title.d.ts.map +1 -1
- package/dist/detectors/sentence-title.js +10 -0
- package/dist/detectors/sentence-title.js.map +1 -1
- package/dist/detectors/signals.d.ts +0 -2
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +12 -163
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +1 -1
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/structure.d.ts +9 -1
- package/dist/detectors/structure.d.ts.map +1 -1
- package/dist/detectors/structure.js +24 -11
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/superlative-clause.d.ts.map +1 -1
- package/dist/detectors/superlative-clause.js +19 -2
- package/dist/detectors/superlative-clause.js.map +1 -1
- package/dist/detectors/superlative-context.d.ts +35 -0
- package/dist/detectors/superlative-context.d.ts.map +1 -0
- package/dist/detectors/superlative-context.js +71 -0
- package/dist/detectors/superlative-context.js.map +1 -0
- package/dist/detectors/superlative-scope.d.ts +6 -2
- package/dist/detectors/superlative-scope.d.ts.map +1 -1
- package/dist/detectors/superlative-scope.js +20 -6
- package/dist/detectors/superlative-scope.js.map +1 -1
- package/dist/detectors/team.d.ts +0 -1
- package/dist/detectors/team.d.ts.map +1 -1
- package/dist/detectors/team.js +0 -46
- package/dist/detectors/team.js.map +1 -1
- package/dist/detectors/titled-code-citation.d.ts +12 -0
- package/dist/detectors/titled-code-citation.d.ts.map +1 -0
- package/dist/detectors/titled-code-citation.js +11 -0
- package/dist/detectors/titled-code-citation.js.map +1 -0
- package/dist/detectors/titled-run.d.ts +8 -1
- package/dist/detectors/titled-run.d.ts.map +1 -1
- package/dist/detectors/titled-run.js +14 -4
- package/dist/detectors/titled-run.js.map +1 -1
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +22 -11
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/topic-predicate-distance.d.ts +4 -0
- package/dist/detectors/topic-predicate-distance.d.ts.map +1 -0
- package/dist/detectors/topic-predicate-distance.js +22 -0
- package/dist/detectors/topic-predicate-distance.js.map +1 -0
- package/dist/detectors/unknown-word-context.d.ts +28 -0
- package/dist/detectors/unknown-word-context.d.ts.map +1 -0
- package/dist/detectors/unknown-word-context.js +89 -0
- package/dist/detectors/unknown-word-context.js.map +1 -0
- package/dist/detectors/unknown-word.d.ts +0 -5
- package/dist/detectors/unknown-word.d.ts.map +1 -1
- package/dist/detectors/unknown-word.js +16 -19
- package/dist/detectors/unknown-word.js.map +1 -1
- package/dist/detectors/unprompted-denial.d.ts +25 -0
- package/dist/detectors/unprompted-denial.d.ts.map +1 -0
- package/dist/detectors/unprompted-denial.js +100 -0
- package/dist/detectors/unprompted-denial.js.map +1 -0
- package/dist/document-sections.d.ts.map +1 -1
- package/dist/document-sections.js +3 -1
- package/dist/document-sections.js.map +1 -1
- package/dist/fix-plan/all-signs.d.ts +17 -0
- package/dist/fix-plan/all-signs.d.ts.map +1 -0
- package/dist/fix-plan/all-signs.js +26 -0
- package/dist/fix-plan/all-signs.js.map +1 -0
- package/dist/fix-plan/plan.d.ts +31 -0
- package/dist/fix-plan/plan.d.ts.map +1 -1
- package/dist/fix-plan/plan.js +23 -3
- package/dist/fix-plan/plan.js.map +1 -1
- package/dist/fix-plan/render.d.ts.map +1 -1
- package/dist/fix-plan/render.js +31 -2
- package/dist/fix-plan/render.js.map +1 -1
- package/dist/fix-plan/risen.d.ts +10 -0
- package/dist/fix-plan/risen.d.ts.map +1 -0
- package/dist/fix-plan/risen.js +7 -0
- package/dist/fix-plan/risen.js.map +1 -0
- package/dist/fix-plan/text.d.ts +15 -0
- package/dist/fix-plan/text.d.ts.map +1 -1
- package/dist/fix-plan/text.js +38 -2
- package/dist/fix-plan/text.js.map +1 -1
- package/dist/heading-numbering.d.ts +2 -1
- package/dist/heading-numbering.d.ts.map +1 -1
- package/dist/heading-numbering.js +40 -10
- package/dist/heading-numbering.js.map +1 -1
- package/dist/html/html-site-chrome.d.ts.map +1 -1
- package/dist/html/html-site-chrome.js +7 -2
- package/dist/html/html-site-chrome.js.map +1 -1
- package/dist/law-title.d.ts +7 -0
- package/dist/law-title.d.ts.map +1 -0
- package/dist/law-title.js +29 -0
- package/dist/law-title.js.map +1 -0
- package/dist/name-ending-run.d.ts +11 -0
- package/dist/name-ending-run.d.ts.map +1 -0
- package/dist/name-ending-run.js +37 -0
- package/dist/name-ending-run.js.map +1 -0
- package/dist/name-title-slip.d.ts +11 -0
- package/dist/name-title-slip.d.ts.map +1 -0
- package/dist/name-title-slip.js +51 -0
- package/dist/name-title-slip.js.map +1 -0
- package/dist/name-variant-shapes.d.ts +14 -0
- package/dist/name-variant-shapes.d.ts.map +1 -0
- package/dist/name-variant-shapes.js +43 -0
- package/dist/name-variant-shapes.js.map +1 -0
- package/dist/name-word-use.d.ts +5 -0
- package/dist/name-word-use.d.ts.map +1 -0
- package/dist/name-word-use.js +12 -0
- package/dist/name-word-use.js.map +1 -0
- package/dist/opening-passage.d.ts +8 -0
- package/dist/opening-passage.d.ts.map +1 -0
- package/dist/opening-passage.js +24 -0
- package/dist/opening-passage.js.map +1 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/quote-gloss.d.ts +4 -0
- package/dist/quote-gloss.d.ts.map +1 -0
- package/dist/quote-gloss.js +7 -0
- package/dist/quote-gloss.js.map +1 -0
- package/dist/quoted-spelling.d.ts +17 -0
- package/dist/quoted-spelling.d.ts.map +1 -0
- package/dist/quoted-spelling.js +27 -0
- package/dist/quoted-spelling.js.map +1 -0
- package/dist/render/semantic.d.ts +1 -1
- package/dist/render/semantic.d.ts.map +1 -1
- package/dist/render/semantic.js +2 -1
- package/dist/render/semantic.js.map +1 -1
- package/dist/rule-of-three.d.ts +19 -0
- package/dist/rule-of-three.d.ts.map +1 -0
- package/dist/rule-of-three.js +33 -0
- package/dist/rule-of-three.js.map +1 -0
- package/dist/run-semantic.d.ts.map +1 -1
- package/dist/run-semantic.js +2 -2
- package/dist/run-semantic.js.map +1 -1
- package/dist/section-levels.d.ts +18 -0
- package/dist/section-levels.d.ts.map +1 -0
- package/dist/section-levels.js +80 -0
- package/dist/section-levels.js.map +1 -0
- package/dist/semantic.d.ts +2 -0
- package/dist/semantic.d.ts.map +1 -1
- package/dist/semantic.js +13 -0
- package/dist/semantic.js.map +1 -1
- package/dist/sentence-load.d.ts +2 -1
- package/dist/sentence-load.d.ts.map +1 -1
- package/dist/sentence-load.js +4 -2
- package/dist/sentence-load.js.map +1 -1
- package/dist/spelling.d.ts +11 -0
- package/dist/spelling.d.ts.map +1 -1
- package/dist/spelling.js +19 -5
- package/dist/spelling.js.map +1 -1
- package/dist/structure/cited-document-section.d.ts.map +1 -1
- package/dist/structure/cited-document-section.js +15 -1
- package/dist/structure/cited-document-section.js.map +1 -1
- package/dist/structure/issues.d.ts +1 -1
- package/dist/structure/issues.d.ts.map +1 -1
- package/dist/structure/issues.js +5 -1
- package/dist/structure/issues.js.map +1 -1
- package/dist/structure-shape/template-outline.d.ts +11 -0
- package/dist/structure-shape/template-outline.d.ts.map +1 -0
- package/dist/structure-shape/template-outline.js +25 -0
- package/dist/structure-shape/template-outline.js.map +1 -0
- package/dist/title-case-name.d.ts +12 -0
- package/dist/title-case-name.d.ts.map +1 -0
- package/dist/title-case-name.js +37 -0
- package/dist/title-case-name.js.map +1 -0
- package/dist/topic-clause.d.ts +6 -1
- package/dist/topic-clause.d.ts.map +1 -1
- package/dist/topic-clause.js +77 -3
- package/dist/topic-clause.js.map +1 -1
- package/dist/word-use.d.ts +12 -4
- package/dist/word-use.d.ts.map +1 -1
- package/dist/word-use.js +47 -5
- package/dist/word-use.js.map +1 -1
- package/package.json +4 -3
- package/rules/ai-generated-composite.yaml +11 -3
- package/rules/ai-structure.yaml +7 -6
- package/rules/ai-tell.yaml +4 -4
- package/rules/all-caps-shouting.yaml +2 -2
- package/rules/bold-emphasis.yaml +5 -4
- package/rules/closing-cliche.yaml +4 -5
- package/rules/closing-exhortation.yaml +74 -0
- package/rules/cold-open.yaml +95 -0
- package/rules/colon-lead-in.yaml +68 -10
- package/rules/comparative-without-baseline.yaml +2 -2
- package/rules/concrete-evidence-density.yaml +2 -2
- package/rules/contrast-framing.yaml +16 -13
- package/rules/dangling-reference.yaml +2 -2
- package/rules/duplicate-heading.yaml +5 -2
- package/rules/email-greeting-closing.yaml +2 -2
- package/rules/email-stock-courtesy.yaml +62 -0
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/generic-opening.yaml +63 -0
- package/rules/heading-level-skip.yaml +2 -2
- package/rules/heading-numbering-mix.yaml +20 -20
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/kutoten-consistency.yaml +4 -4
- package/rules/list-item-form-mix.yaml +2 -2
- package/rules/max-kanji-continuous.yaml +7 -3
- package/rules/max-sentence-length.yaml +4 -2
- package/rules/name-variant.yaml +5 -2
- package/rules/ngram-repetition.yaml +2 -2
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/no-em-dash.yaml +2 -2
- package/rules/no-mixed-desumasu.yaml +16 -3
- package/rules/orthographic-variant.yaml +2 -2
- package/rules/over-general-claim.yaml +2 -2
- package/rules/oxford-comma-consistency.yaml +15 -3
- package/rules/proper-noun-density.yaml +14 -7
- package/rules/rule-of-three.yaml +3 -3
- package/rules/section-length-uniformity.yaml +2 -2
- package/rules/topic-predicate-distance.yaml +3 -2
- package/rules/undefined-acronym.yaml +8 -2
- package/rules/unknown-word.yaml +2 -2
- package/rules/unprompted-denial.yaml +88 -0
- package/rules/unqualified-superlative.yaml +8 -2
- package/skills/chaff/SKILL.md +38 -6
- package/src/acronym-expansion.ts +57 -0
- package/src/ai-score/human-shares.ts +53 -12
- package/src/ai-score/of-document.ts +5 -2
- package/src/body-section.ts +11 -2
- package/src/capitals-with-small.ts +16 -0
- package/src/checks.ts +32 -1
- package/src/cli-args.ts +1 -1
- package/src/cli-text.ts +4 -0
- package/src/commands/fix-plan.ts +72 -5
- package/src/commands/test.ts +18 -2
- package/src/detectors/acronym-context.ts +20 -2
- package/src/detectors/acronym-expansion.ts +26 -0
- package/src/detectors/acronym-gloss.ts +123 -0
- package/src/detectors/acronym-name.ts +22 -3
- package/src/detectors/acronym-series.ts +27 -0
- package/src/detectors/ai-phrasing.ts +18 -17
- package/src/detectors/ai-structure.ts +23 -6
- package/src/detectors/alnum-number.ts +8 -3
- package/src/detectors/bare-comparative.ts +41 -13
- package/src/detectors/bold-emphasis-form.ts +58 -0
- package/src/detectors/bold-emphasis.ts +16 -17
- package/src/detectors/caps-caption.ts +24 -2
- package/src/detectors/char-shape.ts +118 -29
- package/src/detectors/chat-log-line.ts +17 -0
- package/src/detectors/citation-string.ts +36 -0
- package/src/detectors/closing-cliche.ts +74 -0
- package/src/detectors/closing-exhortation.ts +74 -0
- package/src/detectors/cold-open.ts +145 -0
- package/src/detectors/comparative-context.ts +74 -0
- package/src/detectors/concrete-evidence-density.ts +99 -0
- package/src/detectors/concrete-evidence.ts +40 -0
- package/src/detectors/contrast-frame.ts +65 -7
- package/src/detectors/coordinate-adjective.ts +4 -2
- package/src/detectors/duplicate-heading.ts +44 -15
- package/src/detectors/email-frame-words.ts +39 -0
- package/src/detectors/email-letter.ts +15 -20
- package/src/detectors/fullwidth-alnum.ts +24 -4
- package/src/detectors/gram-furniture.ts +87 -1
- package/src/detectors/gram-openers.ts +71 -0
- package/src/detectors/gram-predicate.ts +49 -6
- package/src/detectors/gram-repetition.ts +199 -0
- package/src/detectors/heading-level-skip.ts +31 -1
- package/src/detectors/heading-numbering.ts +2 -2
- package/src/detectors/hyphen-copied-text.ts +65 -0
- package/src/detectors/kanji-name-edge.ts +31 -0
- package/src/detectors/kanji-run-pieces.ts +26 -0
- package/src/detectors/kutoten-consistency.ts +24 -4
- package/src/detectors/lead-in-dash.ts +11 -0
- package/src/detectors/letter-joined-name.ts +14 -0
- package/src/detectors/lexicon.ts +15 -2
- package/src/detectors/list-item.ts +37 -1
- package/src/detectors/list-items.ts +4 -1
- package/src/detectors/list-joint.ts +44 -0
- package/src/detectors/list-layout.ts +39 -0
- package/src/detectors/list-lead-in.ts +50 -3
- package/src/detectors/list-parallel.ts +119 -13
- package/src/detectors/list-run.ts +86 -0
- package/src/detectors/list-sentence.ts +11 -0
- package/src/detectors/mark-shape.ts +12 -7
- package/src/detectors/name-run.ts +2 -1
- package/src/detectors/name-variant-two-things.ts +136 -0
- package/src/detectors/name-variant.ts +14 -19
- package/src/detectors/organisation-run.ts +26 -2
- package/src/detectors/orthographic-variant-open.ts +119 -0
- package/src/detectors/orthographic-variant.ts +82 -82
- package/src/detectors/over-general-claim.ts +106 -5
- package/src/detectors/oxford-comma.ts +68 -28
- package/src/detectors/particle-run-names.ts +17 -0
- package/src/detectors/proper-noun-density.ts +109 -0
- package/src/detectors/quoted-excerpt.ts +68 -0
- package/src/detectors/reference-entry.ts +42 -0
- package/src/detectors/register-neutral-shape.ts +26 -6
- package/src/detectors/register-set-apart.ts +124 -0
- package/src/detectors/register-voice.ts +63 -0
- package/src/detectors/register.ts +15 -0
- package/src/detectors/registry/closing-cliche.ts +4 -0
- package/src/detectors/registry/closing-exhortation.ts +4 -0
- package/src/detectors/registry/cold-open.ts +4 -0
- package/src/detectors/registry/colon-lead-in.ts +1 -1
- package/src/detectors/registry/concrete-evidence.ts +1 -1
- package/src/detectors/registry/ngram-repetition.ts +1 -1
- package/src/detectors/registry/proper-noun-density.ts +1 -1
- package/src/detectors/registry/topic-predicate-distance.ts +1 -1
- package/src/detectors/registry/unprompted-denial.ts +4 -0
- package/src/detectors/sentence-ending.ts +60 -12
- package/src/detectors/sentence-length.ts +26 -9
- package/src/detectors/sentence-load.ts +3 -6
- package/src/detectors/sentence-parts.ts +70 -0
- package/src/detectors/sentence-title.ts +14 -0
- package/src/detectors/signals.ts +13 -198
- package/src/detectors/structure-tree.ts +3 -1
- package/src/detectors/structure.ts +25 -13
- package/src/detectors/superlative-clause.ts +21 -2
- package/src/detectors/superlative-context.ts +99 -0
- package/src/detectors/superlative-scope.ts +27 -9
- package/src/detectors/team.ts +1 -50
- package/src/detectors/titled-code-citation.ts +19 -0
- package/src/detectors/titled-run.ts +22 -5
- package/src/detectors/token-shape.ts +25 -13
- package/src/detectors/topic-predicate-distance.ts +25 -0
- package/src/detectors/unknown-word-context.ts +112 -0
- package/src/detectors/unknown-word.ts +18 -20
- package/src/detectors/unprompted-denial.ts +133 -0
- package/src/document-sections.ts +3 -1
- package/src/fix-plan/all-signs.ts +35 -0
- package/src/fix-plan/plan.ts +50 -3
- package/src/fix-plan/render.ts +41 -3
- package/src/fix-plan/risen.ts +13 -0
- package/src/fix-plan/text.ts +56 -2
- package/src/heading-numbering.ts +44 -10
- package/src/html/html-site-chrome.ts +9 -2
- package/src/law-title.ts +38 -0
- package/src/name-ending-run.ts +49 -0
- package/src/name-title-slip.ts +59 -0
- package/src/name-variant-shapes.ts +58 -0
- package/src/name-word-use.ts +17 -0
- package/src/opening-passage.ts +31 -0
- package/src/plugin.ts +2 -0
- package/src/quote-gloss.ts +11 -0
- package/src/quoted-spelling.ts +48 -0
- package/src/render/semantic.ts +2 -2
- package/src/rule-of-three.ts +50 -0
- package/src/run-semantic.ts +2 -2
- package/src/section-levels.ts +98 -0
- package/src/semantic.ts +14 -0
- package/src/sentence-load.ts +5 -3
- package/src/spelling.ts +37 -7
- package/src/structure/cited-document-section.ts +16 -1
- package/src/structure/issues.ts +10 -1
- package/src/structure-shape/template-outline.ts +34 -0
- package/src/title-case-name.ts +55 -0
- package/src/topic-clause.ts +96 -5
- package/src/word-use.ts +57 -6
- package/dist/legal-address.d.ts +0 -2
- package/dist/legal-address.d.ts.map +0 -1
- package/dist/legal-address.js +0 -16
- package/dist/legal-address.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-of-three.d.ts","sourceRoot":"","sources":["../src/rule-of-three.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AAMhI,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAkBrC,4CAA4C;AAC5C,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,MAAM,UAAU,EAAE,WAAW,SAAS,MAAM,EAAE,KAAG,OAGhG,CAAC;AAKF,mCAAmC;AACnC,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,OAAO,SAAS,UAAU,EAAE,EAAE,WAAW,SAAS,MAAM,EAAE,EAAE,OAAO,MAAM,KAAG,UAAU,GAAG,SAOnI,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const PERCENT = 100;
|
|
2
|
+
const THREE = 3;
|
|
3
|
+
/** これより少ない箇条書きは測らない。 */
|
|
4
|
+
const MIN_LISTS = 3;
|
|
5
|
+
/** これより少ない箇条書きでは、割合では判断せず、全部が 3 項目のときだけ報告する。 */
|
|
6
|
+
export const MIN_LISTS_FOR_SHARE = 5;
|
|
7
|
+
const LINE_BREAK = /\r?\n/u;
|
|
8
|
+
/** `from` より後ろで、最初の空でない行。 */
|
|
9
|
+
const nextWrittenLine = (source, from) => source
|
|
10
|
+
.slice(from)
|
|
11
|
+
.split(LINE_BREAK)
|
|
12
|
+
.find((line) => line.trim() !== "")
|
|
13
|
+
?.trim() ?? "";
|
|
14
|
+
const LATIN_LETTER = /[A-Za-z]/u;
|
|
15
|
+
/** 英語の語は語の切れ目まで照らす(etc が etcetera の頭に当たらない)。日本語の語は字面どおり。 */
|
|
16
|
+
const startsWithWord = (line, word) => line.toLowerCase().startsWith(word.toLowerCase()) && !(LATIN_LETTER.test(word.at(-1) ?? "") && LATIN_LETTER.test(line[word.length] ?? ""));
|
|
17
|
+
/** 箇条書きのすぐ下の行が、並びが続くことを言う語(など、etc.)で始まる。 */
|
|
18
|
+
export const continuesBeyond = (source, list, openWords) => {
|
|
19
|
+
const next = nextWrittenLine(source, list.span.end);
|
|
20
|
+
return openWords.some((word) => startsWithWord(next, word));
|
|
21
|
+
};
|
|
22
|
+
const isExactlyThree = (source, list, openWords) => list.items.length === THREE && !continuesBeyond(source, list, openWords);
|
|
23
|
+
/** 報告するときの数。報告しないときは undefined。 */
|
|
24
|
+
export const threeShare = (source, lists, openWords, limit) => {
|
|
25
|
+
const threes = lists.filter((list) => isExactlyThree(source, list, openWords));
|
|
26
|
+
const first = threes[0];
|
|
27
|
+
if (lists.length < MIN_LISTS || first === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
const share = Math.round((threes.length / lists.length) * PERCENT);
|
|
30
|
+
const reported = lists.length < MIN_LISTS_FOR_SHARE ? threes.length === lists.length : share > limit;
|
|
31
|
+
return reported ? { count: threes.length, total: lists.length, share, first } : undefined;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=rule-of-three.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AC,EAAE,SAAS,CAAC;CAChC,CAAC;AAoBF,4EAA4E;AAC5E,eAAO,MAAM,aAAa,GAAI,OAAO,SAAS,cAAc,EAAE,EAAE,UAAU,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,MAAM,KAAG,YAEzH,CAAC;AAoDH,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG;IAAE,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,aAAa,EAClB,OAAO,SAAS,cAAc,EAAE,EAChC,QAAQ,SAAS,SAAS,EAAE,EAC5B,UAAU,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EACzC,OAAO,MAAM,KACZ,GAAG,EAAoF,CAAC;AAE3F,eAAO,MAAM,WAAW,GACtB,KAAK,aAAa,EAClB,OAAO,SAAS,cAAc,EAAE,EAChC,QAAQ,SAAS,SAAS,EAAE,EAC5B,UAAU,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EACzC,OAAO,MAAM,EACb,SAAS,eAAe,KACvB,OAAO,CAAC,cAAc,CAuBxB,CAAC"}
|
package/dist/run-semantic.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { severityOf } from "./checks.js";
|
|
1
|
+
import { checkAppliesTo, severityOf } from "./checks.js";
|
|
2
2
|
import { ask } from "./judge.js";
|
|
3
3
|
import { FILTERS } from "./semantic.js";
|
|
4
4
|
import { narrow } from "./look-at.js";
|
|
@@ -44,7 +44,7 @@ const builtInJobs = (doc, rules, settings, genre) => semanticRules(rules, settin
|
|
|
44
44
|
];
|
|
45
45
|
});
|
|
46
46
|
const userJobs = (doc, checks, genre) => checks
|
|
47
|
-
.filter((check) => check.level !== "off" && check.use_for.some((target) => genre.startsWith(target)))
|
|
47
|
+
.filter((check) => check.level !== "off" && check.use_for.some((target) => genre.startsWith(target)) && checkAppliesTo(check, doc.language))
|
|
48
48
|
.map((check) => {
|
|
49
49
|
// look_at の括弧の中を取り出して絞り込む。取り出せなければ文書全体。spec §14。
|
|
50
50
|
const { candidates, narrowing } = narrow(doc, check.look_at, FILTERS["whole-document"] ?? (() => []));
|
package/dist/run-semantic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-semantic.js","sourceRoot":"","sources":["../src/run-semantic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAkB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"run-semantic.js","sourceRoot":"","sources":["../src/run-semantic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAkB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,GAAG,EAAqB,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,EAAkB,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,MAAM,EAAkB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAqBhD;;;GAGG;AACH,MAAM,SAAS,GAAG,CAAC,IAAwB,EAAwC,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,gBAAgB,CAAC,CAAC;AAExH,MAAM,iBAAiB,GAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAEpF,MAAM,iBAAiB,GAAG,CAAC,IAAoB,EAAE,KAAY,EAAY,EAAE;IACzE,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,MAAM,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,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AAC,SAAS,EAAE,CAAC,CAAC,CAAC;KACrH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Section } from "./plugin.ts";
|
|
2
|
+
/** One heading level's section lengths, compared with each other. */
|
|
3
|
+
export type LevelLengths = {
|
|
4
|
+
readonly lengths: readonly number[];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Section lengths compared with each other. A subsection is part of its section's length, and the title's introduction
|
|
8
|
+
* is compared with the top level. A run of subsections under headings that only group them is also compared on its own:
|
|
9
|
+
* three pros and three cons are six of one size. Under a heading with text of its own, subsections are parts of that
|
|
10
|
+
* section (seven principles of one guideline), and a section with text between two groups ends the run.
|
|
11
|
+
*/
|
|
12
|
+
export declare const sectionLevels: (sections: readonly Section[], size: (section: Section) => number) => LevelLengths[];
|
|
13
|
+
/**
|
|
14
|
+
* An interview: at least half of the headed sections open with the interviewer's question. Each section is one answer,
|
|
15
|
+
* so even lengths are the form, not a template.
|
|
16
|
+
*/
|
|
17
|
+
export declare const isInterview: (source: string, sections: readonly Section[], paragraphStarts: readonly number[], marks: readonly string[]) => boolean;
|
|
18
|
+
//# sourceMappingURL=section-levels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-levels.d.ts","sourceRoot":"","sources":["../src/section-levels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,qEAAqE;AACrE,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AA8DnE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,SAAS,OAAO,EAAE,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,KAAG,YAAY,EAK5G,CAAC;AAWF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,UAAU,SAAS,OAAO,EAAE,EAAE,iBAAiB,SAAS,MAAM,EAAE,EAAE,OAAO,SAAS,MAAM,EAAE,KAAG,OAMxI,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** A section's own text and every subsection under it, up to the next heading at its depth or shallower. */
|
|
2
|
+
const withSubsections = (sections, index, size) => {
|
|
3
|
+
const depth = sections[index]?.depth ?? 0;
|
|
4
|
+
const after = sections.slice(index + 1);
|
|
5
|
+
const end = after.findIndex((section) => section.depth <= depth);
|
|
6
|
+
const subsections = end === -1 ? after : after.slice(0, end);
|
|
7
|
+
return [sections[index], ...subsections].reduce((sum, section) => sum + (section === undefined ? 0 : size(section)), 0);
|
|
8
|
+
};
|
|
9
|
+
const depthCounts = (sections) => sections.reduce((counts, section) => counts.set(section.depth, (counts.get(section.depth) ?? 0) + 1), new Map());
|
|
10
|
+
/** The shallowest depth that more than one heading shares: the document's top level of sections, below its title. */
|
|
11
|
+
const topDepth = (sections) => [...depthCounts(sections).entries()]
|
|
12
|
+
.filter(([, count]) => count > 1)
|
|
13
|
+
.map(([depth]) => depth)
|
|
14
|
+
.sort((a, b) => a - b)[0];
|
|
15
|
+
/** The nearest heading above the section that is shallower than it. */
|
|
16
|
+
const parentOf = (sections, index) => {
|
|
17
|
+
const depth = sections[index]?.depth ?? 0;
|
|
18
|
+
return sections
|
|
19
|
+
.slice(0, index)
|
|
20
|
+
.reverse()
|
|
21
|
+
.find((section) => section.depth < depth);
|
|
22
|
+
};
|
|
23
|
+
/** A heading that only groups the subsections under it (Pros, Cons): no text of its own. */
|
|
24
|
+
const isGroupHeading = (section, top, size) => section !== undefined && section.depth >= top && size(section) === 0;
|
|
25
|
+
const topLevel = (sections, top, size) => ({
|
|
26
|
+
lengths: sections
|
|
27
|
+
.flatMap((section, index) => {
|
|
28
|
+
if (section.depth === top)
|
|
29
|
+
return [withSubsections(sections, index, size)];
|
|
30
|
+
return section.depth < top ? [size(section)] : [];
|
|
31
|
+
})
|
|
32
|
+
.filter((length) => length > 0),
|
|
33
|
+
});
|
|
34
|
+
/** Subsections at one depth, read in order; a run goes on across group headings and ends at any heading with text. */
|
|
35
|
+
const subsectionRuns = (sections, depth, top, size) => sections
|
|
36
|
+
.reduce((state, section, index) => {
|
|
37
|
+
if (section.depth === depth && isGroupHeading(parentOf(sections, index), top, size)) {
|
|
38
|
+
const length = withSubsections(sections, index, size);
|
|
39
|
+
const runs = state.open ? [...state.runs.slice(0, -1), [...(state.runs.at(-1) ?? []), length]] : [...state.runs, [length]];
|
|
40
|
+
return { runs, open: true };
|
|
41
|
+
}
|
|
42
|
+
if (section.depth > depth || (section.depth < depth && size(section) === 0))
|
|
43
|
+
return state;
|
|
44
|
+
return { runs: state.runs, open: false };
|
|
45
|
+
}, { runs: [], open: false })
|
|
46
|
+
.runs.map((run) => ({ lengths: run.filter((length) => length > 0) }));
|
|
47
|
+
/**
|
|
48
|
+
* Section lengths compared with each other. A subsection is part of its section's length, and the title's introduction
|
|
49
|
+
* is compared with the top level. A run of subsections under headings that only group them is also compared on its own:
|
|
50
|
+
* three pros and three cons are six of one size. Under a heading with text of its own, subsections are parts of that
|
|
51
|
+
* section (seven principles of one guideline), and a section with text between two groups ends the run.
|
|
52
|
+
*/
|
|
53
|
+
export const sectionLevels = (sections, size) => {
|
|
54
|
+
const top = topDepth(sections);
|
|
55
|
+
if (top === undefined)
|
|
56
|
+
return [];
|
|
57
|
+
const deeper = [...depthCounts(sections).keys()].filter((depth) => depth > top).sort((a, b) => a - b);
|
|
58
|
+
return [topLevel(sections, top, size), ...deeper.flatMap((depth) => subsectionRuns(sections, depth, top, size))].filter((level) => level.lengths.length > 0);
|
|
59
|
+
};
|
|
60
|
+
const leadingEmphasis = /^[\s*_]+/u;
|
|
61
|
+
/** The section's first paragraph opens with an interviewer's mark (―― in Japanese, Q: in English): a question turn. */
|
|
62
|
+
const opensWithPrompt = (source, section, firstParagraphStart, marks) => {
|
|
63
|
+
if (firstParagraphStart === undefined || firstParagraphStart >= section.span.end)
|
|
64
|
+
return false;
|
|
65
|
+
const text = source.slice(firstParagraphStart, section.span.end).replace(leadingEmphasis, "");
|
|
66
|
+
return marks.some((mark) => text.startsWith(mark));
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* An interview: at least half of the headed sections open with the interviewer's question. Each section is one answer,
|
|
70
|
+
* so even lengths are the form, not a template.
|
|
71
|
+
*/
|
|
72
|
+
export const isInterview = (source, sections, paragraphStarts, marks) => {
|
|
73
|
+
if (marks.length === 0)
|
|
74
|
+
return false;
|
|
75
|
+
const headed = sections.filter((section) => section.depth > 0 && section.sentences.length > 0);
|
|
76
|
+
const firstStart = (section) => paragraphStarts.find((start) => start >= section.span.start && start < section.span.end);
|
|
77
|
+
const turns = headed.filter((section) => opensWithPrompt(source, section, firstStart(section), marks)).length;
|
|
78
|
+
return turns > 0 && turns * 2 >= headed.length;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=section-levels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-levels.js","sourceRoot":"","sources":["../src/section-levels.ts"],"names":[],"mappings":"AAKA,4GAA4G;AAC5G,MAAM,eAAe,GAAG,CAAC,QAA4B,EAAE,KAAa,EAAE,IAAkC,EAAU,EAAE;IAClH,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7D,OAAO,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E,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/F,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAsB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtJ,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9G,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC;AACjD,CAAC,CAAC"}
|
package/dist/semantic.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export declare const riskDisclosure: Filter;
|
|
|
19
19
|
export declare const emptyConclusion: Filter;
|
|
20
20
|
/** 効果を主張する数値に根拠が無い文だけを渡す。 */
|
|
21
21
|
export declare const unsourcedNumber: Filter;
|
|
22
|
+
/** 書き出しの数文だけを渡す。最初の文が数を言うなら、具体から始まっているので問い合わせない。 */
|
|
23
|
+
export declare const genericOpening: Filter;
|
|
22
24
|
/** 利用者が checks.yaml に書いた検査の既定。絞り込みを書かなければ文書全体。 */
|
|
23
25
|
export declare const wholeDocument: Filter;
|
|
24
26
|
export declare const FILTERS: Readonly<Record<string, Filter>>;
|
package/dist/semantic.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../src/semantic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../src/semantic.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAW,MAAM,aAAa,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,SAAS,EAAE,CAAC;AAWzD,mCAAmC;AACnC,eAAO,MAAM,cAAc,EAAE,MAK5B,CAAC;AAUF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAM7B,CAAC;AAeF,6BAA6B;AAC7B,eAAO,MAAM,eAAe,EAAE,MAGuD,CAAC;AAItF,oDAAoD;AACpD,eAAO,MAAM,cAAc,EAAE,MAM5B,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,aAAa,EAAE,MAG3B,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMpD,CAAC"}
|
package/dist/semantic.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { calendarUnitsOf } from "./calendar-number.js";
|
|
2
2
|
import { closingAndEarlier, newNumbers } from "./closing-numbers.js";
|
|
3
|
+
import { openingProse, opensWithNumber } from "./opening-passage.js";
|
|
4
|
+
import { proseText } from "./measure.js";
|
|
3
5
|
const heads = (doc) => doc.sections.map((section) => section.heading).join(" ");
|
|
4
6
|
const sectionText = (doc, section) => doc.source.slice(section.span.start, section.span.end).trim();
|
|
5
7
|
/** 見出しに答えが書いてあるなら、本文を読ませる必要はない。 */
|
|
@@ -48,6 +50,16 @@ const hasEvidence = (text) => EVIDENCE_WORDS.some((word) => text.includes(word))
|
|
|
48
50
|
export const unsourcedNumber = (doc) => doc.sentences
|
|
49
51
|
.filter((sentence) => NUMBER.test(sentence.text) && EFFECT.test(sentence.text) && !hasEvidence(sentence.text))
|
|
50
52
|
.map((sentence) => ({ text: sentence.text.trim(), offset: sentence.span.start }));
|
|
53
|
+
const OPENING_MAX_CHARS = 1000;
|
|
54
|
+
/** 書き出しの数文だけを渡す。最初の文が数を言うなら、具体から始まっているので問い合わせない。 */
|
|
55
|
+
export const genericOpening = (doc) => {
|
|
56
|
+
const opening = openingProse(doc);
|
|
57
|
+
const first = opening[0];
|
|
58
|
+
if (first === undefined || opensWithNumber(opening))
|
|
59
|
+
return [];
|
|
60
|
+
const text = opening.map(proseText).join(doc.lengthUnit === "char" ? "" : " ");
|
|
61
|
+
return [{ text: text.slice(0, OPENING_MAX_CHARS), offset: first.span.start }];
|
|
62
|
+
};
|
|
51
63
|
/** 利用者が checks.yaml に書いた検査の既定。絞り込みを書かなければ文書全体。 */
|
|
52
64
|
export const wholeDocument = (doc) => {
|
|
53
65
|
const body = doc.sentences.map((sentence) => sentence.text.trim()).join("");
|
|
@@ -57,6 +69,7 @@ export const FILTERS = {
|
|
|
57
69
|
"risk-disclosure": riskDisclosure,
|
|
58
70
|
"empty-conclusion": emptyConclusion,
|
|
59
71
|
"unsourced-number": unsourcedNumber,
|
|
72
|
+
"generic-opening": genericOpening,
|
|
60
73
|
"whole-document": wholeDocument,
|
|
61
74
|
};
|
|
62
75
|
//# sourceMappingURL=semantic.js.map
|
package/dist/semantic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic.js","sourceRoot":"","sources":["../src/semantic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"semantic.js","sourceRoot":"","sources":["../src/semantic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAA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AAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/E,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,kDAAkD;AAClD,MAAM,CAAC,MAAM,aAAa,GAAW,CAAC,GAAG,EAAE,EAAE;IAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7G,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAqC;IACvD,iBAAiB,EAAE,cAAc;IACjC,kBAAkB,EAAE,eAAe;IACnC,kBAAkB,EAAE,eAAe;IACnC,iBAAiB,EAAE,cAAc;IACjC,gBAAgB,EAAE,aAAa;CAChC,CAAC"}
|
package/dist/sentence-load.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Token } from "./plugin.ts";
|
|
2
|
+
import { type TopicClauseWords } from "./topic-clause.ts";
|
|
2
3
|
/**
|
|
3
4
|
* The deepest the brackets of a text nest: 「計画(案)」 is one, 「(注(a)を参照)」 two, plain text none. A closer with no
|
|
4
5
|
* opener (the 1) of a list) is ignored, an opener never closed counts as open until the end, a closer of the other width closes
|
|
@@ -17,5 +18,5 @@ export declare const clauseCount: (tokens: readonly Token[]) => number;
|
|
|
17
18
|
* undefined when the sentence has no topic. The distance is the reader's wait: everything between has to be held before the
|
|
18
19
|
* topic is said to do anything.
|
|
19
20
|
*/
|
|
20
|
-
export declare const topicDistance: (tokens: readonly Token[]) => number | undefined;
|
|
21
|
+
export declare const topicDistance: (tokens: readonly Token[], words?: TopicClauseWords) => number | undefined;
|
|
21
22
|
//# sourceMappingURL=sentence-load.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentence-load.d.ts","sourceRoot":"","sources":["../src/sentence-load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"sentence-load.d.ts","sourceRoot":"","sources":["../src/sentence-load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAmC1E;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,MAS3C,CAAC;AAiBF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,SAAS,KAAK,EAAE,KAAG,MAGtD,CAAC;AAoCF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,SAAS,KAAK,EAAE,EAAE,QAAQ,gBAAgB,KAAG,MAAM,GAAG,SAO3F,CAAC"}
|
package/dist/sentence-load.js
CHANGED
|
@@ -98,11 +98,13 @@ const firstTopic = (tokens) => {
|
|
|
98
98
|
* undefined when the sentence has no topic. The distance is the reader's wait: everything between has to be held before the
|
|
99
99
|
* topic is said to do anything.
|
|
100
100
|
*/
|
|
101
|
-
export const topicDistance = (tokens) => {
|
|
101
|
+
export const topicDistance = (tokens, words) => {
|
|
102
102
|
const topic = firstTopic(tokens);
|
|
103
103
|
const last = tokens.findLastIndex((token) => !TRAILING.has(token.pos));
|
|
104
104
|
if (topic === -1 || last <= topic)
|
|
105
105
|
return undefined;
|
|
106
|
-
return tokens
|
|
106
|
+
return tokens
|
|
107
|
+
.slice(topic + 1, topicClauseEnd(tokens, topic, last, words) ?? last)
|
|
108
|
+
.reduce((sum, token) => sum + [...token.surface.replace(/\s/gu, "")].length, 0);
|
|
107
109
|
};
|
|
108
110
|
//# sourceMappingURL=sentence-load.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentence-load.js","sourceRoot":"","sources":["../src/sentence-load.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"sentence-load.js","sourceRoot":"","sources":["../src/sentence-load.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAyB,MAAM,mBAAmB,CAAC;AAE1E;;;GAGG;AACH,MAAM,QAAQ,GAAqC;IACjD,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;CACT,CAAC;AAEF,oHAAoH;AACpH,MAAM,WAAW,GAAqC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEjG,6GAA6G;AAC7G,MAAM,OAAO,GAAG,6BAA6B,CAAC;AAE9C;;;GAGG;AACH,MAAM,aAAa,GAAG,qCAAqC,CAAC;AAE5D,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,CACvC,IAAI,CAAC,OAAO,CAAC,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AAE,GAAG,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3G,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAwB,EAAE,KAAwB,EAAsB,EAAE;IACtG,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACvE,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,IAAI,IAAI,KAAK;QAAE,OAAO,SAAS,CAAC;IACpD,OAAO,MAAM;SACV,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC;SACpE,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACpF,CAAC,CAAC"}
|
package/dist/spelling.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export type Suffix = {
|
|
3
3
|
readonly suffix: string;
|
|
4
4
|
readonly replacement: string;
|
|
5
|
+
readonly inflection?: boolean;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* 語を辞書で引くのに要るもの。words は語の集まりの並び(辞書と、語彙表やチームの足した語)で、どれかにあれば載っている語。
|
|
@@ -11,9 +12,18 @@ export type Speller = {
|
|
|
11
12
|
readonly words: ReadonlyArray<ReadonlySet<string>>;
|
|
12
13
|
readonly suffixes: readonly Suffix[];
|
|
13
14
|
readonly prefixes: readonly string[];
|
|
15
|
+
/** 語尾を取らない語(those、which)。thoses を those + s と読まない。 */
|
|
16
|
+
readonly uninflected?: ReadonlySet<string>;
|
|
14
17
|
};
|
|
18
|
+
/** 語尾を外した語幹のうち、語尾を取らない語(those)でないもの。 */
|
|
19
|
+
export declare const stemsOf: (word: string, speller: Speller) => string[];
|
|
15
20
|
/** 辞書の語か。そのままか、語尾を外すか、接頭辞を一つ外して(語尾も外して)辞書にあれば知っている語。 */
|
|
16
21
|
export declare const isKnownWord: (word: string, speller: Speller) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 派生した語に活用の語尾を付けた語(operationalises は operationalise + s、その operationalise は operational + ise)。
|
|
24
|
+
* 外側は活用の語尾(-s、-ed)、内側は派生の語尾だけで、活用の語尾の上に語尾は重ならない(oversers は overs + ers でない)。
|
|
25
|
+
*/
|
|
26
|
+
export declare const hasTwoEndings: (word: string, speller: Speller) => boolean;
|
|
17
27
|
/** 一字違いの形。入れ替え(recieve → receive)、置き換え、抜け、余分の順。同じ形は一度だけ。 */
|
|
18
28
|
export declare const editsOf: (word: string) => string[];
|
|
19
29
|
/**
|
|
@@ -28,6 +38,7 @@ export type CheckedWord = {
|
|
|
28
38
|
readonly offset: number;
|
|
29
39
|
readonly word: string;
|
|
30
40
|
};
|
|
41
|
+
export declare const isAddress: (chunk: string) => boolean;
|
|
31
42
|
export declare const wordsToCheck: (text: string, minLength: number, maxLength: number) => CheckedWord[];
|
|
32
43
|
/** source(Markdown のままの文書)の offset から始まる語が、頭の字を分けた語の残りか。 */
|
|
33
44
|
export declare const isSplitWord: (source: string, offset: number) => boolean;
|
package/dist/spelling.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spelling.d.ts","sourceRoot":"","sources":["../src/spelling.ts"],"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AAM,CAAC,KAAG,MAAM,GAAG,SAIlG,CAAC;AAEF,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAW7E,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,OAAmF,CAAC;AAK9H,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,EAAE,WAAW,MAAM,KAAG,WAAW,EAO5F,CAAC;AAOF,4DAA4D;AAC5D,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAsF,CAAC"}
|
package/dist/spelling.js
CHANGED
|
@@ -3,17 +3,30 @@ const inLists = (word, speller) => speller.words.some((list) => list.has(word));
|
|
|
3
3
|
/** 語幹がこれより短くなる外し方はしない。"bed" を "b" + "ed" と読まない。 */
|
|
4
4
|
const MIN_STEM = 2;
|
|
5
5
|
/** 語尾を外した語幹。外した後ろに同じ子音が二つ並べば一つ減らした形も(stopped → stopp → stop)。 */
|
|
6
|
-
const
|
|
6
|
+
const endingStemsOf = (word, suffixes) => suffixes.flatMap(({ suffix, replacement }) => {
|
|
7
7
|
if (!word.endsWith(suffix) || word.length - suffix.length < MIN_STEM)
|
|
8
8
|
return [];
|
|
9
9
|
const stem = word.slice(0, word.length - suffix.length);
|
|
10
10
|
const doubled = stem.length > MIN_STEM && stem.at(-1) === stem.at(-2) ? [stem.slice(0, -1)] : [];
|
|
11
11
|
return [`${stem}${replacement}`, ...doubled];
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
/** 語尾を外した語幹のうち、語尾を取らない語(those)でないもの。 */
|
|
14
|
+
export const stemsOf = (word, speller) => endingStemsOf(word, speller.suffixes).filter((stem) => speller.uninflected?.has(stem) !== true);
|
|
15
|
+
const isListed = (word, speller) => inLists(word, speller) || stemsOf(word, speller).some((stem) => inLists(stem, speller));
|
|
14
16
|
const isPrefixed = (word, speller) => speller.prefixes.some((prefix) => word.startsWith(prefix) && word.length - prefix.length >= MIN_STEM && isListed(word.slice(prefix.length), speller));
|
|
15
17
|
/** 辞書の語か。そのままか、語尾を外すか、接頭辞を一つ外して(語尾も外して)辞書にあれば知っている語。 */
|
|
16
18
|
export const isKnownWord = (word, speller) => isListed(word, speller) || isPrefixed(word, speller);
|
|
19
|
+
/** 内側の語尾を外した後に残す字の数。短い語幹は辞書の略語に当たりやすい(thier を thy + er、その thy を th + y と読まない)。 */
|
|
20
|
+
const MIN_INNER_STEM = 4;
|
|
21
|
+
/** 派生の語尾(-ise、-ness)を外した語幹。重ねた子音は戻さない(visuallize を visual + ize と読まない)。 */
|
|
22
|
+
const derivedStemsOf = (word, speller) => speller.suffixes
|
|
23
|
+
.filter(({ suffix, inflection }) => inflection !== true && word.endsWith(suffix) && word.length - suffix.length >= MIN_INNER_STEM)
|
|
24
|
+
.map(({ suffix, replacement }) => `${word.slice(0, word.length - suffix.length)}${replacement}`);
|
|
25
|
+
/**
|
|
26
|
+
* 派生した語に活用の語尾を付けた語(operationalises は operationalise + s、その operationalise は operational + ise)。
|
|
27
|
+
* 外側は活用の語尾(-s、-ed)、内側は派生の語尾だけで、活用の語尾の上に語尾は重ならない(oversers は overs + ers でない)。
|
|
28
|
+
*/
|
|
29
|
+
export const hasTwoEndings = (word, speller) => endingStemsOf(word, speller.suffixes.filter(({ inflection }) => inflection === true)).some((stem) => derivedStemsOf(stem, speller).some((inner) => inLists(inner, speller)));
|
|
17
30
|
const LETTERS = [..."abcdefghijklmnopqrstuvwxyz"];
|
|
18
31
|
/** 一字違いの形。入れ替え(recieve → receive)、置き換え、抜け、余分の順。同じ形は一度だけ。 */
|
|
19
32
|
export const editsOf = (word) => {
|
|
@@ -38,12 +51,13 @@ export const suggestionFor = (word, speller, used) => {
|
|
|
38
51
|
/**
|
|
39
52
|
* 確かめる語。小文字だけで書いた英字の語で、ほかの語・番号・記号に続かないもの。大文字を含む語(固有名詞、略語、文頭の語)、
|
|
40
53
|
* 数字や下線を含む語、アポストロフィとハイフンの前後(don't、co-operate)、文字参照(—)、ファイル名やドメインの一部(index.html の index)、
|
|
41
|
-
* URL とメールの中、maxLength
|
|
54
|
+
* URL とメールの中、maxLength より長い字の並び(符号化したデータ)は見ない。角括弧の字を続けた語(引用を変えた handl[e])、
|
|
55
|
+
* 括弧の字を挟んで続く語(neuro(a)typicality)、= が続く語(式を地の文に書いた nboot=2,000 の変数の名)も語の一部なので見ない。
|
|
42
56
|
*/
|
|
43
|
-
const WORD = /(?<![\p{L}\p{N}_./@#&'’\\-])[a-z]+(?![\p{L}\p{N}_/@'
|
|
57
|
+
const WORD = /(?<![\p{L}\p{N}_./@#&'’\\-])[a-z]+(?![\p{L}\p{N}_/@'’=-]|\.[\p{L}\p{N}]|\[\p{L}|\(\p{L}+\)\p{L})/gu;
|
|
44
58
|
/** 空白で区切った一続きの字。URL(://)、www. で始まるもの、メール(@)は丸ごと語として読まない。 */
|
|
45
59
|
const CHUNK = /\S+/gu;
|
|
46
|
-
const isAddress = (chunk) => chunk.includes("://") || chunk.includes("@") || chunk.startsWith("www.");
|
|
60
|
+
export const isAddress = (chunk) => chunk.includes("://") || chunk.includes("@") || chunk.startsWith("www.");
|
|
47
61
|
const addressSpans = (text) => [...text.matchAll(CHUNK)].filter((match) => isAddress(match[0])).map((match) => [match.index, match.index + match[0].length]);
|
|
48
62
|
export const wordsToCheck = (text, minLength, maxLength) => {
|
|
49
63
|
const addresses = addressSpans(text);
|
package/dist/spelling.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spelling.js","sourceRoot":"","sources":["../src/spelling.ts"],"names":[],"mappings":"AAAA,yDAAyD;
|
|
1
|
+
{"version":3,"file":"spelling.js","sourceRoot":"","sources":["../src/spelling.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAiBzD,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,OAAgB,E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AAE,SAAiB,EAAiB,EAAE;IAChG,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SAC5B,MAAM,CACL,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,SAAS,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CACxJ;SACA,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,oEAAoE;AACpE,MAAM,UAAU,GAAG,6BAA6B,CAAC;AACjD,gCAAgC;AAChC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,4DAA4D;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,MAAc,EAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cited-document-section.d.ts","sourceRoot":"","sources":["../../src/structure/cited-document-section.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"cited-document-section.d.ts","sourceRoot":"","sources":["../../src/structure/cited-document-section.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA8ClD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM,aAAa,KAAG,WAAW,CAAC,aAAa,CAMzF,CAAC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
/** 見出しが名前の後ろに添えた略称や注記(「…特例に関する法律(特例法)」「…手数料令(手数料令)<抜粋>」)の括弧。名前ではない。 */
|
|
2
|
+
const GLOSS_OPENERS = { ")": "(", ")": "(", ">": "<", ">": "<" };
|
|
3
|
+
const MAX_GLOSS_LENGTH = 30;
|
|
4
|
+
/** 末尾の括弧書きを外から一つずつ外す。中に同じ括弧を含むものは外さない。 */
|
|
5
|
+
const withoutGlosses = (heading) => {
|
|
6
|
+
let name = heading.trim();
|
|
7
|
+
for (;;) {
|
|
8
|
+
const opener = GLOSS_OPENERS[name.at(-1) ?? ""];
|
|
9
|
+
const at = opener === undefined ? -1 : name.lastIndexOf(opener);
|
|
10
|
+
if (at <= 0 || name.length - at > MAX_GLOSS_LENGTH)
|
|
11
|
+
return name;
|
|
12
|
+
name = name.slice(0, at).trimEnd();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
1
15
|
/** 見出しの言葉。文書の最初の見出しは文書自身の題(「# 就業規則」)なので、他の文書の名前として読まない。 */
|
|
2
|
-
const headingOf = (node, title) => node === title ? undefined : String(node.attrs["heading"] ?? "")
|
|
16
|
+
const headingOf = (node, title) => node === title ? undefined : withoutGlosses(String(node.attrs["heading"] ?? ""));
|
|
3
17
|
const documentsCited = (nodes) => new Set(nodes.flatMap((node) => (node.kind === "reference" && typeof node.attrs["document"] === "string" ? [node.attrs["document"]] : [])));
|
|
4
18
|
/** 木を上から順に、見出しの言葉と条の中かと一緒に並べる。再帰にしないのは、深い木でスタックを使い切らないため。 */
|
|
5
19
|
const visitsOf = (tree) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cited-document-section.js","sourceRoot":"","sources":["../../src/structure/cited-document-section.ts"],"names":[],"mappings":"AAOA,2DAA2D;AAC3D,MAAM,SAAS,GAAG,CAAC,IAAmB,EAAE,KAAgC,EAAsB,EAAE,CAC9F,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"cited-document-section.js","sourceRoot":"","sources":["../../src/structure/cited-document-section.ts"],"names":[],"mappings":"AAOA,uEAAuE;AACvE,MAAM,aAAa,GAAqC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACnG,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,0CAA0C;AAC1C,MAAM,cAAc,GAAG,CAAC,OAAe,EAAU,EAAE;IACjD,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC1B,SAAS,CAAC;QACR,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAChD,MAAM,EAAE,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAChE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,gBAAgB;YAAE,OAAO,IAAI,CAAC;QAChE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;AACH,CAAC,CAAC;AAEF,2DAA2D;AAC3D,MAAM,SAAS,GAAG,CAAC,IAAmB,EAAE,KAAgC,EAAsB,EAAE,CAC9F,IAAI,KAAK,KAAK,C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;QACjF,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;QAC/F,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACnG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,IAAmB,EAA8B,EAAE;IAC5F,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,IAAI,GAAG,EAAE,CAAC;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACvJ,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
|
@@ -27,7 +27,7 @@ export declare const chapterReading: (target: string, chapters: Chapters) => {
|
|
|
27
27
|
* 参照の番地が木に無い。他の文書の名前が付いた参照(民法第709条、Section 9 of the Master Agreement)は引かない。
|
|
28
28
|
* 条を 1 つも持たない文書も見ない。他の文書を指しているだけかもしれない。
|
|
29
29
|
*/
|
|
30
|
-
export declare const danglingReferences: (tree: StructureNode, source: string, nameNouns?: readonly string[]) => StructureIssue[];
|
|
30
|
+
export declare const danglingReferences: (tree: StructureNode, source: string, nameNouns?: readonly string[], referenceListHeadings?: readonly string[]) => StructureIssue[];
|
|
31
31
|
/**
|
|
32
32
|
* 参照が指す節点。danglingReferences と同じ引き方(番地、章の短い番地、fallback)で、番号の付いたまとまりを引く。
|
|
33
33
|
* 同じ鍵の節点が二つ以上ある(番号の振り直しや別表の条)ときは、どれを指すのか決まらないので undefined。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../src/structure/issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../src/structure/issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAelD,sDAAsD;AACtD,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIhJ,8DAA8D;AAC9D,eAAO,MAAM,eAAe,GAAI,MAAM,aAAa,KAAG,aAAa,EAUlE,CAAC;AAgCF,8HAA8H;AAC9H,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3F;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,UAAU,QAAQ,KAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAK5H,CAAC;AA0DF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,aAAa,EACnB,QAAQ,MAAM,EACd,YAAW,SAAS,MAAM,EAAO,EACjC,wBAAuB,SAAS,MAAM,EAAO,KAC5C,cAAc,EAqChB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,aAAa,EAAE,QAAQ,MAAM,KAAG,CAAC,CAAC,SAAS,EAAE,aAAa,KAAK,aAAa,GAAG,SAAS,CAqB/H,CAAC;AAkBF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,aAAa,EAAE,aAAY,SAAS,MAAM,EAAO,EAAE,eAAW,KAAG,cAAc,EAgBzH,CAAC"}
|
package/dist/structure/issues.js
CHANGED
|
@@ -7,6 +7,7 @@ import { namesAbsentUnit, withinAbsentUnit } from "./unit-word.js";
|
|
|
7
7
|
import { isListedParagraph, listedParagraphsByArticle } from "./listed-paragraph.js";
|
|
8
8
|
import { referencesInCitedDocuments } from "./cited-document-section.js";
|
|
9
9
|
import { citedElsewhereReader } from "./cited-elsewhere.js";
|
|
10
|
+
import { referenceListSpans } from "../reference-lists.js";
|
|
10
11
|
const NUMBERED = new Set(["chapter", "article", "item"]);
|
|
11
12
|
/** 木を上から順に平らにする。文書の中での順番と同じになる。再帰にしないのは、深い木でスタックを使い切らないため。 */
|
|
12
13
|
export const inDocumentOrder = (tree) => {
|
|
@@ -106,7 +107,7 @@ const ownNumberings = (nodes, resolvesHere) => {
|
|
|
106
107
|
* 参照の番地が木に無い。他の文書の名前が付いた参照(民法第709条、Section 9 of the Master Agreement)は引かない。
|
|
107
108
|
* 条を 1 つも持たない文書も見ない。他の文書を指しているだけかもしれない。
|
|
108
109
|
*/
|
|
109
|
-
export const danglingReferences = (tree, source, nameNouns = []) => {
|
|
110
|
+
export const danglingReferences = (tree, source, nameNouns = [], referenceListHeadings = []) => {
|
|
110
111
|
const nodes = inDocumentOrder(tree);
|
|
111
112
|
// 参照は条を指す。条を一つも持たない文書(契約書に付ける承諾書のひな形など)の「契約書第6条」は、別の文書の条。
|
|
112
113
|
if (!nodes.some((node) => node.kind === "article"))
|
|
@@ -136,7 +137,10 @@ export const danglingReferences = (tree, source, nameNouns = []) => {
|
|
|
136
137
|
// 平文の契約は見出しを「9. Indemnification.」と本文の形で書き、木はそれを番地にしない。残った参照があるときだけ読む。
|
|
137
138
|
const written = unresolved.length === 0 ? undefined : writtenReading(nodes, source);
|
|
138
139
|
const writtenAddresses = new Set(written?.addresses);
|
|
140
|
+
// 文献一覧の項目は他の著作を引く。そこの "pp. Article 81" は雑誌の論文番号で、この文書の条ではない。
|
|
141
|
+
const lists = unresolved.length === 0 ? [] : referenceListSpans(source, referenceListHeadings);
|
|
139
142
|
return unresolved
|
|
143
|
+
.filter((node) => !lists.some((span) => span.start <= node.span.start && node.span.start < span.end))
|
|
140
144
|
.filter((node) => !isListedParagraph(textOf(node, "target"), listed))
|
|
141
145
|
.filter((node) => !writtenAddresses.has(textOf(node, "target")) && written?.subdivision(node) !== true)
|
|
142
146
|
.map((node) => ({ offset: node.span.start, values: { label: textOf(node, "label"), target: textOf(node, "target") } }));
|