chaffjs 0.38.0 → 0.40.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 +21 -4
- package/README.md +20 -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 +54 -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/alternative-words.d.ts +6 -0
- package/dist/alternative-words.d.ts.map +1 -1
- package/dist/alternative-words.js +10 -0
- package/dist/alternative-words.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/closing-code.d.ts +8 -0
- package/dist/closing-code.d.ts.map +1 -0
- package/dist/closing-code.js +18 -0
- package/dist/closing-code.js.map +1 -0
- 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/date-format.d.ts +19 -1
- package/dist/date-format.d.ts.map +1 -1
- package/dist/date-format.js +41 -5
- package/dist/date-format.js.map +1 -1
- package/dist/detectors/acronym-context.d.ts +5 -2
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +19 -4
- 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-mention.d.ts +5 -0
- package/dist/detectors/acronym-mention.d.ts.map +1 -1
- package/dist/detectors/acronym-mention.js +16 -0
- package/dist/detectors/acronym-mention.js.map +1 -1
- package/dist/detectors/acronym-name.d.ts +14 -2
- package/dist/detectors/acronym-name.d.ts.map +1 -1
- package/dist/detectors/acronym-name.js +28 -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/blank-runs.d.ts +12 -0
- package/dist/detectors/blank-runs.d.ts.map +1 -0
- package/dist/detectors/blank-runs.js +27 -0
- package/dist/detectors/blank-runs.js.map +1 -0
- 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/bold-label.d.ts +3 -1
- package/dist/detectors/bold-label.d.ts.map +1 -1
- package/dist/detectors/bold-label.js +16 -6
- package/dist/detectors/bold-label.js.map +1 -1
- package/dist/detectors/capitalised-term.d.ts.map +1 -1
- package/dist/detectors/capitalised-term.js +28 -9
- package/dist/detectors/capitalised-term.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 +9 -0
- package/dist/detectors/citation-string.d.ts.map +1 -0
- package/dist/detectors/citation-string.js +86 -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/contraction-emphasis.d.ts +3 -0
- package/dist/detectors/contraction-emphasis.d.ts.map +1 -0
- package/dist/detectors/contraction-emphasis.js +24 -0
- package/dist/detectors/contraction-emphasis.js.map +1 -0
- package/dist/detectors/contraction-mention.d.ts +12 -1
- package/dist/detectors/contraction-mention.d.ts.map +1 -1
- package/dist/detectors/contraction-mention.js +39 -6
- package/dist/detectors/contraction-mention.js.map +1 -1
- package/dist/detectors/contraction-mix.d.ts +3 -0
- package/dist/detectors/contraction-mix.d.ts.map +1 -0
- package/dist/detectors/contraction-mix.js +69 -0
- package/dist/detectors/contraction-mix.js.map +1 -0
- 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/date-format.d.ts.map +1 -1
- package/dist/detectors/date-format.js +13 -1
- package/dist/detectors/date-format.js.map +1 -1
- package/dist/detectors/duplicate-definition.d.ts +3 -0
- package/dist/detectors/duplicate-definition.d.ts.map +1 -0
- package/dist/detectors/duplicate-definition.js +16 -0
- package/dist/detectors/duplicate-definition.js.map +1 -0
- 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/final-period-captions.d.ts +15 -0
- package/dist/detectors/final-period-captions.d.ts.map +1 -0
- package/dist/detectors/final-period-captions.js +61 -0
- package/dist/detectors/final-period-captions.js.map +1 -0
- 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/heading-sentences.d.ts +10 -0
- package/dist/detectors/heading-sentences.d.ts.map +1 -0
- package/dist/detectors/heading-sentences.js +32 -0
- package/dist/detectors/heading-sentences.js.map +1 -0
- 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 +1 -2
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +16 -57
- 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 +7 -2
- package/dist/detectors/list-lead-in.d.ts.map +1 -1
- package/dist/detectors/list-lead-in.js +67 -6
- 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/missing-final-period.d.ts.map +1 -1
- package/dist/detectors/missing-final-period.js +3 -1
- package/dist/detectors/missing-final-period.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/numbering-readings.d.ts +2 -2
- package/dist/detectors/numbering-readings.d.ts.map +1 -1
- package/dist/detectors/numbering-readings.js +7 -0
- package/dist/detectors/numbering-readings.js.map +1 -1
- package/dist/detectors/open-end-anaphor.d.ts +8 -0
- package/dist/detectors/open-end-anaphor.d.ts.map +1 -0
- package/dist/detectors/open-end-anaphor.js +22 -0
- package/dist/detectors/open-end-anaphor.js.map +1 -0
- package/dist/detectors/open-end-lead.d.ts +4 -0
- package/dist/detectors/open-end-lead.d.ts.map +1 -0
- package/dist/detectors/open-end-lead.js +34 -0
- package/dist/detectors/open-end-lead.js.map +1 -0
- package/dist/detectors/open-end-scope.d.ts.map +1 -1
- package/dist/detectors/open-end-scope.js +7 -1
- package/dist/detectors/open-end-scope.js.map +1 -1
- package/dist/detectors/ordinal-run-gaps.d.ts +1 -0
- package/dist/detectors/ordinal-run-gaps.d.ts.map +1 -1
- package/dist/detectors/ordinal-run-gaps.js +1 -1
- package/dist/detectors/ordinal-run-gaps.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 +37 -0
- package/dist/detectors/orthographic-variant-open.d.ts.map +1 -0
- package/dist/detectors/orthographic-variant-open.js +81 -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/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +14 -5
- package/dist/detectors/orthography.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/placeholder-text.d.ts.map +1 -1
- package/dist/detectors/placeholder-text.js +14 -2
- package/dist/detectors/placeholder-text.js.map +1 -1
- 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/quote-without-source.d.ts +6 -2
- package/dist/detectors/quote-without-source.d.ts.map +1 -1
- package/dist/detectors/quote-without-source.js +33 -8
- package/dist/detectors/quote-without-source.js.map +1 -1
- 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-separate-part.d.ts +7 -0
- package/dist/detectors/register-separate-part.d.ts.map +1 -0
- package/dist/detectors/register-separate-part.js +32 -0
- package/dist/detectors/register-separate-part.js.map +1 -0
- 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/contraction-mix.js +1 -1
- package/dist/detectors/registry/contraction-mix.js.map +1 -1
- package/dist/detectors/registry/duplicate-definition.js +1 -1
- package/dist/detectors/registry/duplicate-definition.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/reproduced-text.d.ts +5 -0
- package/dist/detectors/reproduced-text.d.ts.map +1 -0
- package/dist/detectors/reproduced-text.js +19 -0
- package/dist/detectors/reproduced-text.js.map +1 -0
- package/dist/detectors/request-owner.d.ts +2 -1
- package/dist/detectors/request-owner.d.ts.map +1 -1
- package/dist/detectors/request-owner.js +31 -7
- package/dist/detectors/request-owner.js.map +1 -1
- package/dist/detectors/requirement-smell.d.ts.map +1 -1
- package/dist/detectors/requirement-smell.js +16 -5
- package/dist/detectors/requirement-smell.js.map +1 -1
- package/dist/detectors/sentence-counts.d.ts +2 -1
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +23 -7
- package/dist/detectors/sentence-counts.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts +7 -1
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +47 -11
- 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 +37 -12
- 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 +11 -0
- package/dist/detectors/sentence-parts.d.ts.map +1 -0
- package/dist/detectors/sentence-parts.js +64 -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 +18 -167
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/spelling-variety.d.ts.map +1 -1
- package/dist/detectors/spelling-variety.js +20 -2
- package/dist/detectors/spelling-variety.js.map +1 -1
- package/dist/detectors/structure-tree.d.ts +2 -1
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +3 -8
- 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 +43 -16
- 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 +33 -16
- 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/undefined-term.d.ts +5 -0
- package/dist/detectors/undefined-term.d.ts.map +1 -1
- package/dist/detectors/undefined-term.js +22 -1
- package/dist/detectors/undefined-term.js.map +1 -1
- package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
- package/dist/detectors/unfilled-placeholder.js +15 -1
- package/dist/detectors/unfilled-placeholder.js.map +1 -1
- package/dist/detectors/unknown-word-context.d.ts +35 -0
- package/dist/detectors/unknown-word-context.d.ts.map +1 -0
- package/dist/detectors/unknown-word-context.js +100 -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 +17 -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/latin-spacing-source.d.ts +12 -0
- package/dist/latin-spacing-source.d.ts.map +1 -0
- package/dist/latin-spacing-source.js +25 -0
- package/dist/latin-spacing-source.js.map +1 -0
- 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-separator.d.ts.map +1 -1
- package/dist/name-separator.js +4 -1
- package/dist/name-separator.js.map +1 -1
- 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/paragraph-length.d.ts +14 -0
- package/dist/paragraph-length.d.ts.map +1 -1
- package/dist/paragraph-length.js +25 -0
- package/dist/paragraph-length.js.map +1 -1
- package/dist/paragraph-runs.d.ts +2 -2
- package/dist/paragraph-runs.d.ts.map +1 -1
- package/dist/paragraph-runs.js +65 -14
- package/dist/paragraph-runs.js.map +1 -1
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/quote-echo.d.ts +6 -0
- package/dist/quote-echo.d.ts.map +1 -0
- package/dist/quote-echo.js +14 -0
- package/dist/quote-echo.js.map +1 -0
- 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 +15 -2
- 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/set-phrase-particles.d.ts +4 -0
- package/dist/set-phrase-particles.d.ts.map +1 -0
- package/dist/set-phrase-particles.js +26 -0
- package/dist/set-phrase-particles.js.map +1 -0
- 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/alternative-clause.d.ts +7 -0
- package/dist/structure/alternative-clause.d.ts.map +1 -1
- package/dist/structure/alternative-clause.js +23 -8
- package/dist/structure/alternative-clause.js.map +1 -1
- package/dist/structure/cited-document-section.d.ts +2 -0
- package/dist/structure/cited-document-section.d.ts.map +1 -1
- package/dist/structure/cited-document-section.js +23 -1
- package/dist/structure/cited-document-section.js.map +1 -1
- package/dist/structure/issues.d.ts +4 -2
- package/dist/structure/issues.d.ts.map +1 -1
- package/dist/structure/issues.js +17 -9
- package/dist/structure/issues.js.map +1 -1
- package/dist/structure/numbering.d.ts +10 -1
- package/dist/structure/numbering.d.ts.map +1 -1
- package/dist/structure/numbering.js +41 -4
- package/dist/structure/numbering.js.map +1 -1
- package/dist/structure/unread-label.d.ts +13 -0
- package/dist/structure/unread-label.d.ts.map +1 -0
- package/dist/structure/unread-label.js +70 -0
- package/dist/structure/unread-label.js.map +1 -0
- 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 +90 -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 +12 -3
- package/rules/ai-structure.yaml +7 -6
- package/rules/ai-tell.yaml +10 -6
- package/rules/all-caps-shouting.yaml +2 -2
- package/rules/bold-emphasis.yaml +5 -4
- package/rules/bold-label-list.yaml +6 -6
- 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/contraction-consistency.yaml +2 -2
- package/rules/contrast-framing.yaml +16 -13
- package/rules/dangling-reference.yaml +2 -2
- package/rules/date-format-consistency.yaml +2 -2
- package/rules/duplicate-definition.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/honesty-marker.yaml +84 -0
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/kutoten-consistency.yaml +4 -4
- package/rules/latin-spacing.yaml +6 -4
- package/rules/list-item-form-mix.yaml +2 -2
- package/rules/max-kanji-continuous.yaml +7 -3
- package/rules/max-paragraph-length.yaml +2 -2
- package/rules/max-sentence-length.yaml +6 -2
- package/rules/missing-final-period.yaml +2 -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/nominalization.yaml +1 -1
- package/rules/numbering-gap.yaml +2 -2
- package/rules/one-sentence-paragraph-run.yaml +2 -2
- 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/quote-without-source.yaml +2 -2
- package/rules/request-without-deadline.yaml +2 -2
- package/rules/requirement-smell.yaml +2 -2
- package/rules/rule-of-three.yaml +3 -3
- package/rules/section-length-uniformity.yaml +2 -2
- package/rules/spelling-consistency.yaml +4 -4
- package/rules/teki-overuse.yaml +2 -2
- package/rules/topic-predicate-distance.yaml +3 -2
- package/rules/undefined-acronym.yaml +9 -2
- package/rules/undefined-term.yaml +2 -2
- package/rules/unfilled-placeholder.yaml +2 -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 +39 -6
- package/src/acronym-expansion.ts +57 -0
- package/src/ai-score/human-shares.ts +54 -12
- package/src/ai-score/of-document.ts +5 -2
- package/src/alternative-words.ts +15 -0
- 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/closing-code.ts +21 -0
- package/src/commands/fix-plan.ts +72 -5
- package/src/commands/test.ts +18 -2
- package/src/date-format.ts +54 -7
- package/src/detectors/acronym-context.ts +23 -4
- package/src/detectors/acronym-expansion.ts +26 -0
- package/src/detectors/acronym-gloss.ts +123 -0
- package/src/detectors/acronym-mention.ts +17 -0
- package/src/detectors/acronym-name.ts +40 -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/blank-runs.ts +30 -0
- package/src/detectors/bold-emphasis-form.ts +58 -0
- package/src/detectors/bold-emphasis.ts +16 -17
- package/src/detectors/bold-label.ts +22 -6
- package/src/detectors/capitalised-term.ts +36 -9
- 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 +93 -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/contraction-emphasis.ts +46 -0
- package/src/detectors/contraction-mention.ts +52 -6
- package/src/detectors/contraction-mix.ts +94 -0
- package/src/detectors/contrast-frame.ts +65 -7
- package/src/detectors/coordinate-adjective.ts +4 -2
- package/src/detectors/date-format.ts +18 -2
- package/src/detectors/duplicate-definition.ts +21 -0
- 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/final-period-captions.ts +78 -0
- 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/heading-sentences.ts +36 -0
- 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 +20 -63
- 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 +88 -7
- 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/missing-final-period.ts +9 -1
- 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/numbering-readings.ts +10 -2
- package/src/detectors/open-end-anaphor.ts +31 -0
- package/src/detectors/open-end-lead.ts +46 -0
- package/src/detectors/open-end-scope.ts +8 -1
- package/src/detectors/ordinal-run-gaps.ts +1 -1
- package/src/detectors/organisation-run.ts +26 -2
- package/src/detectors/orthographic-variant-open.ts +124 -0
- package/src/detectors/orthographic-variant.ts +82 -82
- package/src/detectors/orthography.ts +20 -7
- 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/placeholder-text.ts +21 -4
- package/src/detectors/proper-noun-density.ts +109 -0
- package/src/detectors/quote-without-source.ts +52 -10
- 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-separate-part.ts +42 -0
- 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/contraction-mix.ts +1 -1
- package/src/detectors/registry/duplicate-definition.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/reproduced-text.ts +33 -0
- package/src/detectors/request-owner.ts +31 -8
- package/src/detectors/requirement-smell.ts +21 -5
- package/src/detectors/sentence-counts.ts +27 -7
- package/src/detectors/sentence-ending.ts +66 -14
- package/src/detectors/sentence-length.ts +43 -11
- package/src/detectors/sentence-load.ts +3 -6
- package/src/detectors/sentence-parts.ts +73 -0
- package/src/detectors/sentence-title.ts +14 -0
- package/src/detectors/signals.ts +20 -202
- package/src/detectors/spelling-variety.ts +26 -2
- package/src/detectors/structure-tree.ts +5 -9
- package/src/detectors/structure.ts +47 -19
- 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 +40 -18
- package/src/detectors/topic-predicate-distance.ts +25 -0
- package/src/detectors/undefined-term.ts +26 -1
- package/src/detectors/unfilled-placeholder.ts +20 -2
- package/src/detectors/unknown-word-context.ts +129 -0
- package/src/detectors/unknown-word.ts +29 -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/latin-spacing-source.ts +33 -0
- package/src/law-title.ts +38 -0
- package/src/name-ending-run.ts +49 -0
- package/src/name-separator.ts +4 -1
- 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/paragraph-length.ts +31 -0
- package/src/paragraph-runs.ts +71 -13
- package/src/plugin.ts +2 -0
- package/src/quote-echo.ts +18 -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 +16 -3
- package/src/sentence-load.ts +5 -3
- package/src/set-phrase-particles.ts +32 -0
- package/src/spelling.ts +37 -7
- package/src/structure/alternative-clause.ts +32 -7
- package/src/structure/cited-document-section.ts +24 -1
- package/src/structure/issues.ts +29 -10
- package/src/structure/numbering.ts +50 -3
- package/src/structure/unread-label.ts +74 -0
- package/src/structure-shape/template-outline.ts +34 -0
- package/src/title-case-name.ts +55 -0
- package/src/topic-clause.ts +110 -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,48 @@
|
|
|
1
|
+
// Words a document takes from elsewhere: a capitalised name (the Interagency Group) and a cited work (a reference list's entry,
|
|
2
|
+
// a citation written as a sentence). They keep the hyphens their owner gave them, unless the document writes the same name two
|
|
3
|
+
// ways (Co-working Space and Coworking Space), and a cited title keeps its ordinary words
|
|
4
|
+
// (factors beside the dataset FACTors). A capital the citing lost (arxiv for arXiv, ai-generated for AI-generated) is still
|
|
5
|
+
// the document's slip and is still compared. Pure.
|
|
6
|
+
|
|
7
|
+
/** Where a word was taken from: a capitalised name, or a cited work. */
|
|
8
|
+
export type Quoted = "name" | "cited";
|
|
9
|
+
|
|
10
|
+
/** A word, and for a word in a capitalised run, the run as written (Twenty-Nine Palms Band of Mission Indians), quoted or not. */
|
|
11
|
+
type QuotedWord = { readonly key: string; readonly spelling: string; readonly quoted?: Quoted | undefined; readonly name?: string | undefined };
|
|
12
|
+
|
|
13
|
+
/** The spelling without its hyphens: two spellings equal this way differ only in hyphenation (Interagency, inter-agency). */
|
|
14
|
+
const closedUp = (spelling: string): string => spelling.replaceAll("-", "");
|
|
15
|
+
|
|
16
|
+
/** A name without its case and hyphens: two names equal this way are one name (Co-working Space, Coworking Space). */
|
|
17
|
+
const nameKeyOf = (name: string): string => closedUp(name.toLowerCase());
|
|
18
|
+
|
|
19
|
+
/** The ways each group of words is written, grouped by keyOf and written as spellingOf gives. */
|
|
20
|
+
const spellingsBy = <Word>(words: readonly Word[], keyOf: (word: Word) => string, spellingOf: (word: Word) => string): Map<string, Set<string>> =>
|
|
21
|
+
words.reduce((groups, word) => groups.set(keyOf(word), (groups.get(keyOf(word)) ?? new Set<string>()).add(spellingOf(word))), new Map<string, Set<string>>());
|
|
22
|
+
|
|
23
|
+
const SMALL_LETTERS_ONLY = /^[\p{Ll}\d-]+$/u;
|
|
24
|
+
|
|
25
|
+
/** A cited word in small letters that the dictionary knows (factors): the title's own word, not a name written small. */
|
|
26
|
+
const isOrdinaryCitedWord = (word: QuotedWord, isWord: (word: string) => boolean): boolean =>
|
|
27
|
+
word.quoted === "cited" && SMALL_LETTERS_ONLY.test(word.spelling) && isWord(word.spelling);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The words without those taken from elsewhere where their way is their own: in a group of one key whose spellings differ only
|
|
31
|
+
* in hyphens, a cited word and a word of a name the document writes one way only; and a cited ordinary word in small letters. spelling is the word with the first letter of each part
|
|
32
|
+
* in small letters; isWord says whether the language's dictionary has a word.
|
|
33
|
+
*/
|
|
34
|
+
export const withoutQuotedSpellings = <Word extends QuotedWord>(words: readonly Word[], isWord: (word: string) => boolean): Word[] => {
|
|
35
|
+
const closed = spellingsBy(
|
|
36
|
+
words,
|
|
37
|
+
(word) => word.key,
|
|
38
|
+
(word) => closedUp(word.spelling),
|
|
39
|
+
);
|
|
40
|
+
const names = spellingsBy(
|
|
41
|
+
words.filter((word) => word.name !== undefined),
|
|
42
|
+
(word) => nameKeyOf(word.name ?? ""),
|
|
43
|
+
(word) => word.name ?? "",
|
|
44
|
+
);
|
|
45
|
+
const differsInHyphensOnly = (word: Word): boolean => closed.get(word.key)?.size === 1;
|
|
46
|
+
const isOwnWay = (word: Word): boolean => word.quoted === "cited" || names.get(nameKeyOf(word.name ?? ""))?.size === 1;
|
|
47
|
+
return words.filter((word) => word.quoted === undefined || !((differsInHyphensOnly(word) && isOwnWay(word)) || isOrdinaryCitedWord(word, isWord)));
|
|
48
|
+
};
|
package/src/render/semantic.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Finding, RuleDefinition } from "../plugin.ts";
|
|
2
|
-
import type
|
|
2
|
+
import { checkAppliesTo, type UserCheck } from "../checks.ts";
|
|
3
3
|
import type { Narrowing } from "../look-at.ts";
|
|
4
4
|
import type { Job as Plan, SemanticResult } from "../run-semantic.ts";
|
|
5
5
|
import { uiLanguageOf, type Texts, type UiLanguage } from "../ui.ts";
|
|
@@ -116,7 +116,7 @@ type Named = { readonly name: string; readonly howToFix: string };
|
|
|
116
116
|
const nameOf = (rule: string, rules: readonly RuleDefinition[], checks: readonly UserCheck[], language: string): Named => {
|
|
117
117
|
const built = rules.find((entry) => entry.id === rule);
|
|
118
118
|
if (built !== undefined) return { name: localized(built.name, language), howToFix: localized(built.how_to_fix, language) };
|
|
119
|
-
const user = checks.find((entry) => entry.id === rule);
|
|
119
|
+
const user = checks.find((entry) => entry.id === rule && checkAppliesTo(entry, language));
|
|
120
120
|
return { name: user?.name ?? rule, howToFix: user?.how_to_fix ?? "" };
|
|
121
121
|
};
|
|
122
122
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BulletList } from "./plugin.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* rule-of-three の数え方。箇条書きのうち、ちょうど 3 項目のものがどれだけあるか。
|
|
5
|
+
* すぐ下の行が「など」「etc.」で始まる箇条書きは、書いた 3 つより多くあると書き手が言っている。ちょうど 3 項目とは数えない。
|
|
6
|
+
* 箇条書きが少ないと、1 つで割合が大きく動く(4 つなら 25 ポイント)。そのときは全部が 3 項目のときだけ報告する。
|
|
7
|
+
*/
|
|
8
|
+
export type ThreeShare = { readonly count: number; readonly total: number; readonly share: number; readonly first: BulletList };
|
|
9
|
+
|
|
10
|
+
const PERCENT = 100;
|
|
11
|
+
const THREE = 3;
|
|
12
|
+
/** これより少ない箇条書きは測らない。 */
|
|
13
|
+
const MIN_LISTS = 3;
|
|
14
|
+
/** これより少ない箇条書きでは、割合では判断せず、全部が 3 項目のときだけ報告する。 */
|
|
15
|
+
export const MIN_LISTS_FOR_SHARE = 5;
|
|
16
|
+
|
|
17
|
+
const LINE_BREAK = /\r?\n/u;
|
|
18
|
+
|
|
19
|
+
/** `from` より後ろで、最初の空でない行。 */
|
|
20
|
+
const nextWrittenLine = (source: string, from: number): string =>
|
|
21
|
+
source
|
|
22
|
+
.slice(from)
|
|
23
|
+
.split(LINE_BREAK)
|
|
24
|
+
.find((line) => line.trim() !== "")
|
|
25
|
+
?.trim() ?? "";
|
|
26
|
+
|
|
27
|
+
const LATIN_LETTER = /[A-Za-z]/u;
|
|
28
|
+
|
|
29
|
+
/** 英語の語は語の切れ目まで照らす(etc が etcetera の頭に当たらない)。日本語の語は字面どおり。 */
|
|
30
|
+
const startsWithWord = (line: string, word: string): boolean =>
|
|
31
|
+
line.toLowerCase().startsWith(word.toLowerCase()) && !(LATIN_LETTER.test(word.at(-1) ?? "") && LATIN_LETTER.test(line[word.length] ?? ""));
|
|
32
|
+
|
|
33
|
+
/** 箇条書きのすぐ下の行が、並びが続くことを言う語(など、etc.)で始まる。 */
|
|
34
|
+
export const continuesBeyond = (source: string, list: BulletList, openWords: readonly string[]): boolean => {
|
|
35
|
+
const next = nextWrittenLine(source, list.span.end);
|
|
36
|
+
return openWords.some((word) => startsWithWord(next, word));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const isExactlyThree = (source: string, list: BulletList, openWords: readonly string[]): boolean =>
|
|
40
|
+
list.items.length === THREE && !continuesBeyond(source, list, openWords);
|
|
41
|
+
|
|
42
|
+
/** 報告するときの数。報告しないときは undefined。 */
|
|
43
|
+
export const threeShare = (source: string, lists: readonly BulletList[], openWords: readonly string[], limit: number): ThreeShare | undefined => {
|
|
44
|
+
const threes = lists.filter((list) => isExactlyThree(source, list, openWords));
|
|
45
|
+
const first = threes[0];
|
|
46
|
+
if (lists.length < MIN_LISTS || first === undefined) return undefined;
|
|
47
|
+
const share = Math.round((threes.length / lists.length) * PERCENT);
|
|
48
|
+
const reported = lists.length < MIN_LISTS_FOR_SHARE ? threes.length === lists.length : share > limit;
|
|
49
|
+
return reported ? { count: threes.length, total: lists.length, share, first } : undefined;
|
|
50
|
+
};
|
package/src/run-semantic.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { severityOf, type UserCheck } from "./checks.ts";
|
|
1
|
+
import { checkAppliesTo, severityOf, type UserCheck } from "./checks.ts";
|
|
2
2
|
import { ask, type JudgeOptions } from "./judge.ts";
|
|
3
3
|
import { FILTERS, type Candidate } from "./semantic.ts";
|
|
4
4
|
import { narrow, type Narrowing } from "./look-at.ts";
|
|
@@ -71,7 +71,7 @@ const builtInJobs = (doc: ProseDocument, rules: readonly RuleDefinition[], setti
|
|
|
71
71
|
|
|
72
72
|
const userJobs = (doc: ProseDocument, checks: readonly UserCheck[], genre: string): Job[] =>
|
|
73
73
|
checks
|
|
74
|
-
.filter((check) => check.level !== "off" && check.use_for.some((target) => genre.startsWith(target)))
|
|
74
|
+
.filter((check) => check.level !== "off" && check.use_for.some((target) => genre.startsWith(target)) && checkAppliesTo(check, doc.language))
|
|
75
75
|
.map((check) => {
|
|
76
76
|
// look_at の括弧の中を取り出して絞り込む。取り出せなければ文書全体。spec §14。
|
|
77
77
|
const { candidates, narrowing } = narrow(doc, check.look_at, FILTERS["whole-document"] ?? (() => []));
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Section } from "./plugin.ts";
|
|
2
|
+
|
|
3
|
+
/** One heading level's section lengths, compared with each other. */
|
|
4
|
+
export type LevelLengths = { readonly lengths: readonly number[] };
|
|
5
|
+
|
|
6
|
+
/** A section's own text and every subsection under it, up to the next heading at its depth or shallower. */
|
|
7
|
+
const withSubsections = (sections: readonly Section[], index: number, size: (section: Section) => number): number => {
|
|
8
|
+
const depth = sections[index]?.depth ?? 0;
|
|
9
|
+
const after = sections.slice(index + 1);
|
|
10
|
+
const end = after.findIndex((section) => section.depth <= depth);
|
|
11
|
+
const subsections = end === -1 ? after : after.slice(0, end);
|
|
12
|
+
return [sections[index], ...subsections].reduce((sum, section) => sum + (section === undefined ? 0 : size(section)), 0);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const depthCounts = (sections: readonly Section[]): Map<number, number> =>
|
|
16
|
+
sections.reduce((counts, section) => counts.set(section.depth, (counts.get(section.depth) ?? 0) + 1), new Map<number, number>());
|
|
17
|
+
|
|
18
|
+
/** The shallowest depth that more than one heading shares: the document's top level of sections, below its title. */
|
|
19
|
+
const topDepth = (sections: readonly Section[]): number | undefined =>
|
|
20
|
+
[...depthCounts(sections).entries()]
|
|
21
|
+
.filter(([, count]) => count > 1)
|
|
22
|
+
.map(([depth]) => depth)
|
|
23
|
+
.sort((a, b) => a - b)[0];
|
|
24
|
+
|
|
25
|
+
/** The nearest heading above the section that is shallower than it. */
|
|
26
|
+
const parentOf = (sections: readonly Section[], index: number): Section | undefined => {
|
|
27
|
+
const depth = sections[index]?.depth ?? 0;
|
|
28
|
+
return sections
|
|
29
|
+
.slice(0, index)
|
|
30
|
+
.reverse()
|
|
31
|
+
.find((section) => section.depth < depth);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** A heading that only groups the subsections under it (Pros, Cons): no text of its own. */
|
|
35
|
+
const isGroupHeading = (section: Section | undefined, top: number, size: (section: Section) => number): boolean =>
|
|
36
|
+
section !== undefined && section.depth >= top && size(section) === 0;
|
|
37
|
+
|
|
38
|
+
const topLevel = (sections: readonly Section[], top: number, size: (section: Section) => number): LevelLengths => ({
|
|
39
|
+
lengths: sections
|
|
40
|
+
.flatMap((section, index) => {
|
|
41
|
+
if (section.depth === top) return [withSubsections(sections, index, size)];
|
|
42
|
+
return section.depth < top ? [size(section)] : [];
|
|
43
|
+
})
|
|
44
|
+
.filter((length) => length > 0),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
type Runs = { readonly runs: readonly (readonly number[])[]; readonly open: boolean };
|
|
48
|
+
|
|
49
|
+
/** Subsections at one depth, read in order; a run goes on across group headings and ends at any heading with text. */
|
|
50
|
+
const subsectionRuns = (sections: readonly Section[], depth: number, top: number, size: (section: Section) => number): LevelLengths[] =>
|
|
51
|
+
sections
|
|
52
|
+
.reduce<Runs>(
|
|
53
|
+
(state, section, index) => {
|
|
54
|
+
if (section.depth === depth && isGroupHeading(parentOf(sections, index), top, size)) {
|
|
55
|
+
const length = withSubsections(sections, index, size);
|
|
56
|
+
const runs = state.open ? [...state.runs.slice(0, -1), [...(state.runs.at(-1) ?? []), length]] : [...state.runs, [length]];
|
|
57
|
+
return { runs, open: true };
|
|
58
|
+
}
|
|
59
|
+
if (section.depth > depth || (section.depth < depth && size(section) === 0)) return state;
|
|
60
|
+
return { runs: state.runs, open: false };
|
|
61
|
+
},
|
|
62
|
+
{ runs: [], open: false },
|
|
63
|
+
)
|
|
64
|
+
.runs.map((run) => ({ lengths: run.filter((length) => length > 0) }));
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Section lengths compared with each other. A subsection is part of its section's length, and the title's introduction
|
|
68
|
+
* is compared with the top level. A run of subsections under headings that only group them is also compared on its own:
|
|
69
|
+
* three pros and three cons are six of one size. Under a heading with text of its own, subsections are parts of that
|
|
70
|
+
* section (seven principles of one guideline), and a section with text between two groups ends the run.
|
|
71
|
+
*/
|
|
72
|
+
export const sectionLevels = (sections: readonly Section[], size: (section: Section) => number): LevelLengths[] => {
|
|
73
|
+
const top = topDepth(sections);
|
|
74
|
+
if (top === undefined) return [];
|
|
75
|
+
const deeper = [...depthCounts(sections).keys()].filter((depth) => depth > top).sort((a, b) => a - b);
|
|
76
|
+
return [topLevel(sections, top, size), ...deeper.flatMap((depth) => subsectionRuns(sections, depth, top, size))].filter((level) => level.lengths.length > 0);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const leadingEmphasis = /^[\s*_]+/u;
|
|
80
|
+
|
|
81
|
+
/** The section's first paragraph opens with an interviewer's mark (―― in Japanese, Q: in English): a question turn. */
|
|
82
|
+
const opensWithPrompt = (source: string, section: Section, firstParagraphStart: number | undefined, marks: readonly string[]): boolean => {
|
|
83
|
+
if (firstParagraphStart === undefined || firstParagraphStart >= section.span.end) return false;
|
|
84
|
+
const text = source.slice(firstParagraphStart, section.span.end).replace(leadingEmphasis, "");
|
|
85
|
+
return marks.some((mark) => text.startsWith(mark));
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* An interview: at least half of the headed sections open with the interviewer's question. Each section is one answer,
|
|
90
|
+
* so even lengths are the form, not a template.
|
|
91
|
+
*/
|
|
92
|
+
export const isInterview = (source: string, sections: readonly Section[], paragraphStarts: readonly number[], marks: readonly string[]): boolean => {
|
|
93
|
+
if (marks.length === 0) return false;
|
|
94
|
+
const headed = sections.filter((section) => section.depth > 0 && section.sentences.length > 0);
|
|
95
|
+
const firstStart = (section: Section): number | undefined => paragraphStarts.find((start) => start >= section.span.start && start < section.span.end);
|
|
96
|
+
const turns = headed.filter((section) => opensWithPrompt(source, section, firstStart(section), marks)).length;
|
|
97
|
+
return turns > 0 && turns * 2 >= headed.length;
|
|
98
|
+
};
|
package/src/semantic.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { calendarUnitsOf } from "./calendar-number.ts";
|
|
2
2
|
import { closingAndEarlier, newNumbers } from "./closing-numbers.ts";
|
|
3
|
+
import { hasNewCodeOrLink, isLinkList } from "./closing-code.ts";
|
|
4
|
+
import { openingProse, opensWithNumber } from "./opening-passage.ts";
|
|
5
|
+
import { proseText } from "./measure.ts";
|
|
3
6
|
import type { ProseDocument, Section } from "./plugin.ts";
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -29,8 +32,6 @@ export const riskDisclosure: Filter = (doc) => {
|
|
|
29
32
|
return [{ text: body.slice(0, 4000), offset: doc.sentences[0]?.span.start ?? 0 }];
|
|
30
33
|
};
|
|
31
34
|
|
|
32
|
-
const EVIDENCE = /`|https?:\/\//u;
|
|
33
|
-
|
|
34
35
|
/** 結びに、前に書いていない数があるか。本文の数を繰り返すだけ(「以上のように、9月は…」)なら具体物ではない。 */
|
|
35
36
|
const hasNewNumber = (doc: ProseDocument, last: Section): boolean => {
|
|
36
37
|
const { closing, earlier } = closingAndEarlier(doc, last);
|
|
@@ -45,7 +46,7 @@ export const emptyConclusion: Filter = (doc) => {
|
|
|
45
46
|
const last = doc.sections.at(-1);
|
|
46
47
|
if (last === undefined || last.sentences.length === 0) return [];
|
|
47
48
|
const text = sectionText(doc, last);
|
|
48
|
-
if (
|
|
49
|
+
if (isLinkList(text) || hasNewCodeOrLink(text, doc.source.slice(0, last.span.start)) || hasNewNumber(doc, last)) return [];
|
|
49
50
|
return [{ text: text.slice(0, 2000), offset: last.sentences[0]?.span.start ?? last.span.start }];
|
|
50
51
|
};
|
|
51
52
|
|
|
@@ -68,6 +69,17 @@ export const unsourcedNumber: Filter = (doc) =>
|
|
|
68
69
|
.filter((sentence) => NUMBER.test(sentence.text) && EFFECT.test(sentence.text) && !hasEvidence(sentence.text))
|
|
69
70
|
.map((sentence) => ({ text: sentence.text.trim(), offset: sentence.span.start }));
|
|
70
71
|
|
|
72
|
+
const OPENING_MAX_CHARS = 1000;
|
|
73
|
+
|
|
74
|
+
/** 書き出しの数文だけを渡す。最初の文が数を言うなら、具体から始まっているので問い合わせない。 */
|
|
75
|
+
export const genericOpening: Filter = (doc) => {
|
|
76
|
+
const opening = openingProse(doc);
|
|
77
|
+
const first = opening[0];
|
|
78
|
+
if (first === undefined || opensWithNumber(opening)) return [];
|
|
79
|
+
const text = opening.map(proseText).join(doc.lengthUnit === "char" ? "" : " ");
|
|
80
|
+
return [{ text: text.slice(0, OPENING_MAX_CHARS), offset: first.span.start }];
|
|
81
|
+
};
|
|
82
|
+
|
|
71
83
|
/** 利用者が checks.yaml に書いた検査の既定。絞り込みを書かなければ文書全体。 */
|
|
72
84
|
export const wholeDocument: Filter = (doc) => {
|
|
73
85
|
const body = doc.sentences.map((sentence) => sentence.text.trim()).join("");
|
|
@@ -78,5 +90,6 @@ export const FILTERS: Readonly<Record<string, Filter>> = {
|
|
|
78
90
|
"risk-disclosure": riskDisclosure,
|
|
79
91
|
"empty-conclusion": emptyConclusion,
|
|
80
92
|
"unsourced-number": unsourcedNumber,
|
|
93
|
+
"generic-opening": genericOpening,
|
|
81
94
|
"whole-document": wholeDocument,
|
|
82
95
|
};
|
package/src/sentence-load.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// How much one sentence asks the reader to hold at once: brackets inside brackets, clauses chained one after another, and how
|
|
2
2
|
// far the topic stands from the end where its predicate is. Pure: a sentence's text and tokens come in, numbers go out.
|
|
3
3
|
import type { Token } from "./plugin.ts";
|
|
4
|
-
import { topicClauseEnd } from "./topic-clause.ts";
|
|
4
|
+
import { topicClauseEnd, type TopicClauseWords } from "./topic-clause.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Opening brackets and the mark that closes each. Quotation marks that open and close with the same character are left out, and
|
|
@@ -117,9 +117,11 @@ const firstTopic = (tokens: readonly Token[]): number => {
|
|
|
117
117
|
* undefined when the sentence has no topic. The distance is the reader's wait: everything between has to be held before the
|
|
118
118
|
* topic is said to do anything.
|
|
119
119
|
*/
|
|
120
|
-
export const topicDistance = (tokens: readonly Token[]): number | undefined => {
|
|
120
|
+
export const topicDistance = (tokens: readonly Token[], words?: TopicClauseWords): number | undefined => {
|
|
121
121
|
const topic = firstTopic(tokens);
|
|
122
122
|
const last = tokens.findLastIndex((token) => !TRAILING.has(token.pos));
|
|
123
123
|
if (topic === -1 || last <= topic) return undefined;
|
|
124
|
-
return tokens
|
|
124
|
+
return tokens
|
|
125
|
+
.slice(topic + 1, topicClauseEnd(tokens, topic, last, words) ?? last)
|
|
126
|
+
.reduce((sum, token) => sum + [...token.surface.replace(/\s/gu, "")].length, 0);
|
|
125
127
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Token } from "./plugin.ts";
|
|
2
|
+
|
|
3
|
+
// A particle inside a set phrase (絶滅のおそれのある種: おそれのある, "at risk of"): the phrase is read as one word, so its particle
|
|
4
|
+
// is not a link of a nesting chain. Pure.
|
|
5
|
+
|
|
6
|
+
const touches = (left: Token | undefined, right: Token | undefined): boolean => left !== undefined && right !== undefined && left.span.end === right.span.start;
|
|
7
|
+
|
|
8
|
+
/** How many words before a particle are read for a phrase's head: the tokenizer may cut it (おそれ as お and それ). */
|
|
9
|
+
const MAX_HEAD_WORDS = 3;
|
|
10
|
+
|
|
11
|
+
/** The words written straight before tokens[at], joined (おそれ from お and それ). */
|
|
12
|
+
const headBefore = (tokens: readonly Token[], at: number): string => {
|
|
13
|
+
const window = tokens.slice(Math.max(0, at - MAX_HEAD_WORDS), at + 1);
|
|
14
|
+
const gap = window.findLastIndex((token, index) => index < window.length - 1 && !touches(token, window[index + 1]));
|
|
15
|
+
return window
|
|
16
|
+
.slice(gap + 1, -1)
|
|
17
|
+
.map((token) => token.surface)
|
|
18
|
+
.join("");
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Whether the particle at `at`, the words before it and the dictionary form of the word after it spell one of phrases (おそれのある). */
|
|
22
|
+
const isInPhrase = (tokens: readonly Token[], at: number, phrases: readonly string[]): boolean => {
|
|
23
|
+
const [particle, after] = [tokens[at], tokens[at + 1]];
|
|
24
|
+
if (particle === undefined || after === undefined || !touches(particle, after)) return false;
|
|
25
|
+
const tail = `${particle.surface}${after.lemma ?? after.surface}`;
|
|
26
|
+
const head = headBefore(tokens, at);
|
|
27
|
+
return phrases.some((phrase) => phrase.endsWith(tail) && phrase.length > tail.length && head.endsWith(phrase.slice(0, -tail.length)));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** The counted particles (particles) of a sentence that stand inside one of phrases, each written whole (おそれのある). */
|
|
31
|
+
export const setPhraseParticles = (tokens: readonly Token[], particles: readonly string[], phrases: readonly string[]): ReadonlySet<Token> =>
|
|
32
|
+
new Set(tokens.filter((token, at) => particles.includes(token.surface) && isInPhrase(tokens, at, phrases)));
|
package/src/spelling.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// 辞書に無い語と、一字違いの言い直し。純粋な関数だけを置く。辞書と、語尾・接頭辞の知識は言語パッケージが渡す。
|
|
2
2
|
|
|
3
3
|
/** 語尾の置き換え 1 つ。suffix を外して replacement を足すと辞書の語(carried → carry)。 */
|
|
4
|
-
export type Suffix = { readonly suffix: string; readonly replacement: string };
|
|
4
|
+
export type Suffix = { readonly suffix: string; readonly replacement: string; readonly inflection?: boolean };
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 語を辞書で引くのに要るもの。words は語の集まりの並び(辞書と、語彙表やチームの足した語)で、どれかにあれば載っている語。
|
|
8
8
|
* 大きい辞書を文書ごとに写さないよう、集まりは足し合わせずに並べる。suffixes は語尾、prefixes は接頭辞。
|
|
9
9
|
*/
|
|
10
|
-
export type Speller = {
|
|
10
|
+
export type Speller = {
|
|
11
|
+
readonly words: ReadonlyArray<ReadonlySet<string>>;
|
|
12
|
+
readonly suffixes: readonly Suffix[];
|
|
13
|
+
readonly prefixes: readonly string[];
|
|
14
|
+
/** 語尾を取らない語(those、which)。thoses を those + s と読まない。 */
|
|
15
|
+
readonly uninflected?: ReadonlySet<string>;
|
|
16
|
+
};
|
|
11
17
|
|
|
12
18
|
const inLists = (word: string, speller: Speller): boolean => speller.words.some((list) => list.has(word));
|
|
13
19
|
|
|
@@ -15,7 +21,7 @@ const inLists = (word: string, speller: Speller): boolean => speller.words.some(
|
|
|
15
21
|
const MIN_STEM = 2;
|
|
16
22
|
|
|
17
23
|
/** 語尾を外した語幹。外した後ろに同じ子音が二つ並べば一つ減らした形も(stopped → stopp → stop)。 */
|
|
18
|
-
const
|
|
24
|
+
const endingStemsOf = (word: string, suffixes: readonly Suffix[]): string[] =>
|
|
19
25
|
suffixes.flatMap(({ suffix, replacement }) => {
|
|
20
26
|
if (!word.endsWith(suffix) || word.length - suffix.length < MIN_STEM) return [];
|
|
21
27
|
const stem = word.slice(0, word.length - suffix.length);
|
|
@@ -23,7 +29,11 @@ const stemsOf = (word: string, suffixes: readonly Suffix[]): string[] =>
|
|
|
23
29
|
return [`${stem}${replacement}`, ...doubled];
|
|
24
30
|
});
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
/** 語尾を外した語幹のうち、語尾を取らない語(those)でないもの。 */
|
|
33
|
+
export const stemsOf = (word: string, speller: Speller): string[] =>
|
|
34
|
+
endingStemsOf(word, speller.suffixes).filter((stem) => speller.uninflected?.has(stem) !== true);
|
|
35
|
+
|
|
36
|
+
const isListed = (word: string, speller: Speller): boolean => inLists(word, speller) || stemsOf(word, speller).some((stem) => inLists(stem, speller));
|
|
27
37
|
|
|
28
38
|
const isPrefixed = (word: string, speller: Speller): boolean =>
|
|
29
39
|
speller.prefixes.some((prefix) => word.startsWith(prefix) && word.length - prefix.length >= MIN_STEM && isListed(word.slice(prefix.length), speller));
|
|
@@ -31,6 +41,25 @@ const isPrefixed = (word: string, speller: Speller): boolean =>
|
|
|
31
41
|
/** 辞書の語か。そのままか、語尾を外すか、接頭辞を一つ外して(語尾も外して)辞書にあれば知っている語。 */
|
|
32
42
|
export const isKnownWord = (word: string, speller: Speller): boolean => isListed(word, speller) || isPrefixed(word, speller);
|
|
33
43
|
|
|
44
|
+
/** 内側の語尾を外した後に残す字の数。短い語幹は辞書の略語に当たりやすい(thier を thy + er、その thy を th + y と読まない)。 */
|
|
45
|
+
const MIN_INNER_STEM = 4;
|
|
46
|
+
|
|
47
|
+
/** 派生の語尾(-ise、-ness)を外した語幹。重ねた子音は戻さない(visuallize を visual + ize と読まない)。 */
|
|
48
|
+
const derivedStemsOf = (word: string, speller: Speller): string[] =>
|
|
49
|
+
speller.suffixes
|
|
50
|
+
.filter(({ suffix, inflection }) => inflection !== true && word.endsWith(suffix) && word.length - suffix.length >= MIN_INNER_STEM)
|
|
51
|
+
.map(({ suffix, replacement }) => `${word.slice(0, word.length - suffix.length)}${replacement}`);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 派生した語に活用の語尾を付けた語(operationalises は operationalise + s、その operationalise は operational + ise)。
|
|
55
|
+
* 外側は活用の語尾(-s、-ed)、内側は派生の語尾だけで、活用の語尾の上に語尾は重ならない(oversers は overs + ers でない)。
|
|
56
|
+
*/
|
|
57
|
+
export const hasTwoEndings = (word: string, speller: Speller): boolean =>
|
|
58
|
+
endingStemsOf(
|
|
59
|
+
word,
|
|
60
|
+
speller.suffixes.filter(({ inflection }) => inflection === true),
|
|
61
|
+
).some((stem) => derivedStemsOf(stem, speller).some((inner) => inLists(inner, speller)));
|
|
62
|
+
|
|
34
63
|
const LETTERS = [..."abcdefghijklmnopqrstuvwxyz"];
|
|
35
64
|
|
|
36
65
|
/** 一字違いの形。入れ替え(recieve → receive)、置き換え、抜け、余分の順。同じ形は一度だけ。 */
|
|
@@ -61,12 +90,13 @@ export type CheckedWord = { readonly offset: number; readonly word: string };
|
|
|
61
90
|
/**
|
|
62
91
|
* 確かめる語。小文字だけで書いた英字の語で、ほかの語・番号・記号に続かないもの。大文字を含む語(固有名詞、略語、文頭の語)、
|
|
63
92
|
* 数字や下線を含む語、アポストロフィとハイフンの前後(don't、co-operate)、文字参照(—)、ファイル名やドメインの一部(index.html の index)、
|
|
64
|
-
* URL とメールの中、maxLength
|
|
93
|
+
* URL とメールの中、maxLength より長い字の並び(符号化したデータ)は見ない。角括弧の字を続けた語(引用を変えた handl[e])、
|
|
94
|
+
* 括弧の字を挟んで続く語(neuro(a)typicality)、= が続く語(式を地の文に書いた nboot=2,000 の変数の名)も語の一部なので見ない。
|
|
65
95
|
*/
|
|
66
|
-
const WORD = /(?<![\p{L}\p{N}_./@#&'’\\-])[a-z]+(?![\p{L}\p{N}_/@'
|
|
96
|
+
const WORD = /(?<![\p{L}\p{N}_./@#&'’\\-])[a-z]+(?![\p{L}\p{N}_/@'’=-]|\.[\p{L}\p{N}]|\[\p{L}|\(\p{L}+\)\p{L})/gu;
|
|
67
97
|
/** 空白で区切った一続きの字。URL(://)、www. で始まるもの、メール(@)は丸ごと語として読まない。 */
|
|
68
98
|
const CHUNK = /\S+/gu;
|
|
69
|
-
const isAddress = (chunk: string): boolean => chunk.includes("://") || chunk.includes("@") || chunk.startsWith("www.");
|
|
99
|
+
export const isAddress = (chunk: string): boolean => chunk.includes("://") || chunk.includes("@") || chunk.startsWith("www.");
|
|
70
100
|
|
|
71
101
|
const addressSpans = (text: string): Array<readonly [number, number]> =>
|
|
72
102
|
[...text.matchAll(CHUNK)].filter((match) => isAddress(match[0])).map((match) => [match.index, match.index + match[0].length]);
|
|
@@ -23,21 +23,46 @@ const isLabelLine = (line: string): boolean => {
|
|
|
23
23
|
return text.startsWith("#") || ("【〔[[((".includes(text.charAt(0)) && "】〕]]))".includes(text.charAt(text.length - 1)));
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
/** A division whose heading, or the label line just before it, the test names. */
|
|
27
|
+
const divisionNamedBy =
|
|
28
|
+
(source: string, names: (text: string) => boolean): ((node: StructureNode) => boolean) =>
|
|
29
|
+
(node) => {
|
|
30
|
+
const heading = node.attrs["heading"];
|
|
31
|
+
if (typeof heading === "string" && names(heading)) return true;
|
|
32
|
+
const label = previousLineOf(source, node.span.start);
|
|
33
|
+
return isLabelLine(label) && names(label);
|
|
34
|
+
};
|
|
35
|
+
|
|
26
36
|
/**
|
|
27
37
|
* A division its heading, or the label line just before it (【18条変更オプション条項:知財調停】), names as an alternative
|
|
28
38
|
* (alternative-clause-label).
|
|
29
39
|
*/
|
|
30
40
|
export const alternativeReader = (source: string, labels: readonly string[]): ((node: StructureNode) => boolean) => {
|
|
31
41
|
const words = labels.filter((label) => label !== "");
|
|
32
|
-
|
|
33
|
-
return (node) => {
|
|
34
|
-
const heading = node.attrs["heading"];
|
|
35
|
-
if (typeof heading === "string" && names(heading)) return true;
|
|
36
|
-
const label = previousLineOf(source, node.span.start);
|
|
37
|
-
return isLabelLine(label) && names(label);
|
|
38
|
-
};
|
|
42
|
+
return divisionNamedBy(source, (text) => words.some((word) => text.includes(word)));
|
|
39
43
|
};
|
|
40
44
|
|
|
45
|
+
/** One number or letter after the word (オプション2, Option B), not the first of a range or a list (オプション1~3, Options 1 and 2). */
|
|
46
|
+
const ONE_CHOICE = /^\s?(?:[0-90-9]+|[A-ZA-Z])(?![0-90-9A-Za-zA-Z])(?!\s*(?:[~〜~\-–—‐・、,,&&]|to\b|and\b|or\b))/u;
|
|
47
|
+
|
|
48
|
+
/** The text names one choice among numbered ones: an option word (option-choice-label) followed by its number or letter. */
|
|
49
|
+
export const namesOneChoice = (text: string, words: readonly string[]): boolean =>
|
|
50
|
+
words
|
|
51
|
+
.filter((word) => word !== "")
|
|
52
|
+
.some((word) =>
|
|
53
|
+
text
|
|
54
|
+
.split(word)
|
|
55
|
+
.slice(1)
|
|
56
|
+
.some((after) => ONE_CHOICE.test(after)),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A division its heading or label line names as one of numbered choices (第1条(オプション2:…), "Option B"): only one of
|
|
61
|
+
* them stays in the signed text (option-choice-label).
|
|
62
|
+
*/
|
|
63
|
+
export const choiceReader = (source: string, words: readonly string[]): ((node: StructureNode) => boolean) =>
|
|
64
|
+
divisionNamedBy(source, (text) => namesOneChoice(text, words));
|
|
65
|
+
|
|
41
66
|
/** Where a line starts with a division whose number is left blank (placeholder-division: 第●条): a new run of numbers. */
|
|
42
67
|
export const placeholderStarts = (source: string, patterns: readonly string[]): number[] => {
|
|
43
68
|
const heads = patterns.filter((pattern) => pattern !== "");
|
|
@@ -5,9 +5,24 @@ import type { StructureNode } from "../plugin.ts";
|
|
|
5
5
|
/** heading: いちばん近い見出しの節の言葉。inArticle: 条の中か。 */
|
|
6
6
|
type Visit = { readonly node: StructureNode; readonly heading: string | undefined; readonly inArticle: boolean };
|
|
7
7
|
|
|
8
|
+
/** 見出しが名前の後ろに添えた略称や注記(「…特例に関する法律(特例法)」「…手数料令(手数料令)<抜粋>」)の括弧。名前ではない。 */
|
|
9
|
+
const GLOSS_OPENERS: Readonly<Record<string, string>> = { ")": "(", ")": "(", ">": "<", ">": "<" };
|
|
10
|
+
const MAX_GLOSS_LENGTH = 30;
|
|
11
|
+
|
|
12
|
+
/** 末尾の括弧書きを外から一つずつ外す。中に同じ括弧を含むものは外さない。 */
|
|
13
|
+
const withoutGlosses = (heading: string): string => {
|
|
14
|
+
let name = heading.trim();
|
|
15
|
+
for (;;) {
|
|
16
|
+
const opener = GLOSS_OPENERS[name.at(-1) ?? ""];
|
|
17
|
+
const at = opener === undefined ? -1 : name.lastIndexOf(opener);
|
|
18
|
+
if (at <= 0 || name.length - at > MAX_GLOSS_LENGTH) return name;
|
|
19
|
+
name = name.slice(0, at).trimEnd();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
/** 見出しの言葉。文書の最初の見出しは文書自身の題(「# 就業規則」)なので、他の文書の名前として読まない。 */
|
|
9
24
|
const headingOf = (node: StructureNode, title: StructureNode | undefined): string | undefined =>
|
|
10
|
-
node === title ? undefined : String(node.attrs["heading"] ?? "")
|
|
25
|
+
node === title ? undefined : withoutGlosses(String(node.attrs["heading"] ?? ""));
|
|
11
26
|
|
|
12
27
|
const documentsCited = (nodes: readonly StructureNode[]): ReadonlySet<string> =>
|
|
13
28
|
new Set(nodes.flatMap((node) => (node.kind === "reference" && typeof node.attrs["document"] === "string" ? [node.attrs["document"]] : [])));
|
|
@@ -40,3 +55,11 @@ export const referencesInCitedDocuments = (tree: StructureNode): ReadonlySet<Str
|
|
|
40
55
|
const quoted = visits.filter((visit) => visit.node.kind === "reference" && visit.inArticle && visit.heading !== undefined && cited.has(visit.heading));
|
|
41
56
|
return new Set(quoted.map((visit) => visit.node));
|
|
42
57
|
};
|
|
58
|
+
|
|
59
|
+
/** 見出しが他の文書の名前そのもので、その名前を文書がほかで他の文書として引いている節に引き写した条。Pure. */
|
|
60
|
+
export const articlesInCitedDocuments = (tree: StructureNode): readonly StructureNode[] => {
|
|
61
|
+
const visits = visitsOf(tree);
|
|
62
|
+
const cited = documentsCited(visits.map((visit) => visit.node));
|
|
63
|
+
if (cited.size === 0) return [];
|
|
64
|
+
return visits.filter((visit) => visit.node.kind === "article" && visit.heading !== undefined && cited.has(visit.heading)).map((visit) => visit.node);
|
|
65
|
+
};
|
package/src/structure/issues.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { namesAbsentUnit, withinAbsentUnit } from "./unit-word.ts";
|
|
|
8
8
|
import { isListedParagraph, listedParagraphsByArticle } from "./listed-paragraph.ts";
|
|
9
9
|
import { referencesInCitedDocuments } from "./cited-document-section.ts";
|
|
10
10
|
import { citedElsewhereReader } from "./cited-elsewhere.ts";
|
|
11
|
+
import { referenceListSpans } from "../reference-lists.ts";
|
|
11
12
|
|
|
12
13
|
// 木だけで決まる誤り。参照先が無い、番号が飛ぶ・重なる、同じ語を二度定義する。
|
|
13
14
|
// 意味の食い違いは判定しない。書いてあることから機械で決まるものだけを出す。
|
|
@@ -137,7 +138,12 @@ const ownNumberings = (nodes: readonly StructureNode[], resolvesHere: (node: Str
|
|
|
137
138
|
* 参照の番地が木に無い。他の文書の名前が付いた参照(民法第709条、Section 9 of the Master Agreement)は引かない。
|
|
138
139
|
* 条を 1 つも持たない文書も見ない。他の文書を指しているだけかもしれない。
|
|
139
140
|
*/
|
|
140
|
-
export const danglingReferences = (
|
|
141
|
+
export const danglingReferences = (
|
|
142
|
+
tree: StructureNode,
|
|
143
|
+
source: string,
|
|
144
|
+
nameNouns: readonly string[] = [],
|
|
145
|
+
referenceListHeadings: readonly string[] = [],
|
|
146
|
+
): StructureIssue[] => {
|
|
141
147
|
const nodes = inDocumentOrder(tree);
|
|
142
148
|
// 参照は条を指す。条を一つも持たない文書(契約書に付ける承諾書のひな形など)の「契約書第6条」は、別の文書の条。
|
|
143
149
|
if (!nodes.some((node) => node.kind === "article")) return [];
|
|
@@ -167,7 +173,10 @@ export const danglingReferences = (tree: StructureNode, source: string, nameNoun
|
|
|
167
173
|
// 平文の契約は見出しを「9. Indemnification.」と本文の形で書き、木はそれを番地にしない。残った参照があるときだけ読む。
|
|
168
174
|
const written = unresolved.length === 0 ? undefined : writtenReading(nodes, source);
|
|
169
175
|
const writtenAddresses = new Set(written?.addresses);
|
|
176
|
+
// 文献一覧の項目は他の著作を引く。そこの "pp. Article 81" は雑誌の論文番号で、この文書の条ではない。
|
|
177
|
+
const lists = unresolved.length === 0 ? [] : referenceListSpans(source, referenceListHeadings);
|
|
170
178
|
return unresolved
|
|
179
|
+
.filter((node) => !lists.some((span) => span.start <= node.span.start && node.span.start < span.end))
|
|
171
180
|
.filter((node) => !isListedParagraph(textOf(node, "target"), listed))
|
|
172
181
|
.filter((node) => !writtenAddresses.has(textOf(node, "target")) && written?.subdivision(node) !== true)
|
|
173
182
|
.map((node) => ({ offset: node.span.start, values: { label: textOf(node, "label"), target: textOf(node, "target") } }));
|
|
@@ -200,18 +209,20 @@ export const referenceResolver = (tree: StructureNode, source: string): ((refere
|
|
|
200
209
|
};
|
|
201
210
|
};
|
|
202
211
|
|
|
203
|
-
|
|
212
|
+
/** choice: the division, one of several to choose from, that holds the definition (undefined when the text keeps it whatever is chosen). */
|
|
213
|
+
type Definition = { readonly node: StructureNode; readonly article: string; readonly choice: StructureNode | undefined };
|
|
204
214
|
|
|
205
|
-
/**
|
|
206
|
-
const definitionsInOrder = (tree: StructureNode): Definition[] => {
|
|
215
|
+
/** 定義を文書の順に、それが置かれた条の番地と、選ぶ条項の中ならその条項と一緒に並べる。範囲を限った定義は、その条の中でだけ比べるため。 */
|
|
216
|
+
const definitionsInOrder = (tree: StructureNode, isChoice: (node: StructureNode) => boolean): Definition[] => {
|
|
207
217
|
const found: Definition[] = [];
|
|
208
|
-
const pending: Definition[] = [{ node: tree, article: "" }];
|
|
218
|
+
const pending: Definition[] = [{ node: tree, article: "", choice: undefined }];
|
|
209
219
|
while (pending.length > 0) {
|
|
210
220
|
const current = pending.pop();
|
|
211
221
|
if (current === undefined) break;
|
|
212
222
|
if (current.node.kind === "definition") found.push(current);
|
|
213
223
|
const article = current.node.kind === "article" ? current.node.address : current.article;
|
|
214
|
-
current.node.
|
|
224
|
+
const choice = current.choice ?? (current.node.kind !== "definition" && isChoice(current.node) ? current.node : undefined);
|
|
225
|
+
current.node.children.toReversed().forEach((child) => pending.push({ node: child, article, choice }));
|
|
215
226
|
}
|
|
216
227
|
return found;
|
|
217
228
|
};
|
|
@@ -222,17 +233,25 @@ const definitionsInOrder = (tree: StructureNode): Definition[] => {
|
|
|
222
233
|
* 添付した文書(partStarts から始まる Exhibit A など)は別の文書なので、その中の定義はその中でだけ比べる。
|
|
223
234
|
* 同じ名前の後ろの括弧で同じ語を定義し直したもの(件名と本文の Financial Crimes Enforcement Network ("FinCEN"))は、
|
|
224
235
|
* 一つの定義を書き直しただけで食い違えないので言わない。名前は source から読む。
|
|
236
|
+
* ひな形の選ぶ条項(オプション1、オプション2)の中の定義は、選ばなければ消える。先の定義が消えうるなら、後の定義は二度目と決まらない。
|
|
237
|
+
* そこで選ぶ条項の中の定義は、どれを選んでも残る定義と、同じ条項の中の定義とだけ比べる。
|
|
225
238
|
*/
|
|
226
|
-
export const duplicateDefinitions = (
|
|
239
|
+
export const duplicateDefinitions = (
|
|
240
|
+
tree: StructureNode,
|
|
241
|
+
partStarts: readonly number[] = [],
|
|
242
|
+
source = "",
|
|
243
|
+
isChoice: (node: StructureNode) => boolean = () => false,
|
|
244
|
+
): StructureIssue[] => {
|
|
227
245
|
const first = new Map<string, StructureNode>();
|
|
228
|
-
return definitionsInOrder(tree).flatMap(({ node, article }) => {
|
|
246
|
+
return definitionsInOrder(tree, isChoice).flatMap(({ node, article, choice }) => {
|
|
229
247
|
const term = textOf(node, "term");
|
|
230
248
|
const within = node.attrs["within"] === undefined ? article : textOf(node, "within");
|
|
231
249
|
const scoped = node.attrs["scope"] === "local" ? `${within}\u0000${term}` : term;
|
|
232
250
|
const key = `${partAt(partStarts, node.span.start)}\u0000${scoped}`;
|
|
233
|
-
const
|
|
251
|
+
const choiceKey = choice === undefined ? undefined : `${choice.span.start}\u0000${key}`;
|
|
252
|
+
const earlier = first.get(key) ?? (choiceKey === undefined ? undefined : first.get(choiceKey));
|
|
234
253
|
if (earlier === undefined) {
|
|
235
|
-
first.set(key, node);
|
|
254
|
+
first.set(choiceKey ?? key, node);
|
|
236
255
|
return [];
|
|
237
256
|
}
|
|
238
257
|
const name = nameBeforeDefinition(source, node);
|