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,74 @@
|
|
|
1
|
+
import type { Token } from "../plugin.ts";
|
|
2
|
+
|
|
3
|
+
// Sentences around a comparative that already say what it is compared with, though no baseline word names it. Pure.
|
|
4
|
+
|
|
5
|
+
const lower = (token: Token | undefined): string => token?.surface.toLowerCase() ?? "";
|
|
6
|
+
|
|
7
|
+
const isSpace = (token: Token): boolean => token.surface.trim() === "";
|
|
8
|
+
|
|
9
|
+
/** The index of the sentence's first word, past leading spaces. */
|
|
10
|
+
const firstWordAt = (tokens: readonly Token[]): number => tokens.findIndex((token) => !isSpace(token));
|
|
11
|
+
|
|
12
|
+
const wordOf = (token: Token): readonly string[] => [lower(token), token.lemma?.toLowerCase() ?? ""];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A word inside the sentence, before the comparative, that names the change or the alternative it follows from: a cause
|
|
16
|
+
* (これにより、…ことにより、…できるため、) or a contrast (Print statements work, but a debugger is better). The word must
|
|
17
|
+
* follow another word: the clause before it is what the comparison sets itself against.
|
|
18
|
+
*/
|
|
19
|
+
export const followsCause = (tokens: readonly Token[], first: Token, causes: ReadonlySet<string>): boolean => {
|
|
20
|
+
const opening = firstWordAt(tokens);
|
|
21
|
+
return tokens.some((token, at) => at > opening && token.span.end <= first.span.start && wordOf(token).some((word) => causes.has(word)));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** The sentence opens with a word that puts it after a change or a topic it names (As the application grows, …; By pairing …, …). */
|
|
25
|
+
export const opensWithCause = (tokens: readonly Token[], openers: ReadonlySet<string>): boolean => openers.has(lower(tokens[firstWordAt(tokens)]));
|
|
26
|
+
|
|
27
|
+
/** How far before the comparative a verb that makes it a change from now may stand (make the system meet their needs better). */
|
|
28
|
+
const MAKER_REACH = 6;
|
|
29
|
+
|
|
30
|
+
const CLAUSE_BREAK = new Set([",", ";", ":"]);
|
|
31
|
+
|
|
32
|
+
/** A verb shortly before the comparative, in its clause, makes it a change from the present state (to make results more predictable, we can do better). */
|
|
33
|
+
export const madeComparative = (tokens: readonly Token[], first: Token, makers: ReadonlySet<string>): boolean => {
|
|
34
|
+
const at = tokens.indexOf(first);
|
|
35
|
+
const reach = tokens.slice(Math.max(0, at - MAKER_REACH), at);
|
|
36
|
+
const clause = reach.slice(reach.findLastIndex((token) => CLAUSE_BREAK.has(token.surface)) + 1);
|
|
37
|
+
return clause.some((token) => (token.pos === "VERB" || token.pos === "AUX") && makers.has(lower(token)));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** A condition word with its negation attached (couldn't, wouldn’t) is the condition word. */
|
|
41
|
+
export const withoutNegation = (word: string): string => word.replace(/n['’]t$/u, "");
|
|
42
|
+
|
|
43
|
+
/** A comparative is the subject of the predicate, opening its clause: a maxim weighing two comparatives (simpler is better). */
|
|
44
|
+
export const comparesComparatives = (tokens: readonly Token[], headAt: number, comparatives: ReadonlySet<string>): boolean => {
|
|
45
|
+
const subject = tokens[headAt - 1];
|
|
46
|
+
const before = tokens[headAt - 2];
|
|
47
|
+
return comparatives.has(lower(subject)) && (before === undefined || isSpace(before) || CLAUSE_BREAK.has(before.surface));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const MODIFIER = new Set(["ADJ", "VERB"]);
|
|
51
|
+
|
|
52
|
+
const nounWord = (token: Token): string => token.lemma?.toLowerCase() ?? lower(token);
|
|
53
|
+
|
|
54
|
+
/** The subject noun before the predicate head, past adverbs (A blurred background usually looks better → background). */
|
|
55
|
+
const subjectAt = (tokens: readonly Token[], headAt: number): number => {
|
|
56
|
+
const at = tokens.slice(0, headAt).findLastIndex((token) => token.pos !== "ADV" && !isSpace(token));
|
|
57
|
+
return tokens[at]?.pos === "NOUN" ? at : -1;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The subject is one kind of a thing the sentence before names as another kind (Virtual backgrounds are fine, … A blurred
|
|
62
|
+
* background looks better): the same noun under a different modifier, so the comparison is between the two kinds.
|
|
63
|
+
*/
|
|
64
|
+
export const comparesKinds = (previous: readonly Token[], tokens: readonly Token[], head: Token | undefined): boolean => {
|
|
65
|
+
if (head === undefined) return false;
|
|
66
|
+
const at = subjectAt(tokens, tokens.indexOf(head));
|
|
67
|
+
const [modifier, subject] = [tokens[at - 1], tokens[at]];
|
|
68
|
+
if (at === -1 || subject === undefined || modifier === undefined || !MODIFIER.has(modifier.pos)) return false;
|
|
69
|
+
const noun = nounWord(subject);
|
|
70
|
+
return previous.some(
|
|
71
|
+
(token, index) =>
|
|
72
|
+
token.pos === "NOUN" && nounWord(token) === noun && MODIFIER.has(previous[index - 1]?.pos ?? "") && lower(previous[index - 1]) !== lower(modifier),
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { proseText } from "../measure.ts";
|
|
2
|
+
import type { Detector, Finding, ProseDocument, Section, Sentence } from "../plugin.ts";
|
|
3
|
+
import {
|
|
4
|
+
evidenceSpans,
|
|
5
|
+
hasNumeral,
|
|
6
|
+
isClaim,
|
|
7
|
+
isConditionHeading,
|
|
8
|
+
isLabelOnly,
|
|
9
|
+
isNavigationLine,
|
|
10
|
+
startsWithin,
|
|
11
|
+
statesIntent,
|
|
12
|
+
type AdviceWords,
|
|
13
|
+
type IntentWords,
|
|
14
|
+
} from "./concrete-evidence.ts";
|
|
15
|
+
import { letteredIndexEntries } from "./lettered-index.ts";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 具体物の密度。数値・コード・リンク・引用が 1 つも無い節は、
|
|
19
|
+
* 読み終えても何も持ち帰れない。**少ないほうを指摘する**ので、他の密度 rule と向きが逆。
|
|
20
|
+
*/
|
|
21
|
+
const CONCRETE = /\d|`|https?:\/\//u;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 見出しのない導入部は、書き出しで呼ぶ。文書の言葉なので、message がどの言語でも混ざらない。
|
|
25
|
+
* 決まった呼び名(「この節」)を置くと、英語の文書の message に日本語が入る。
|
|
26
|
+
*/
|
|
27
|
+
const OPENING = { word: 4, char: 12 };
|
|
28
|
+
|
|
29
|
+
const openingOf = (sentence: Sentence | undefined, unit: ProseDocument["lengthUnit"]): string => {
|
|
30
|
+
const text = sentence === undefined ? "" : proseText(sentence);
|
|
31
|
+
const pieces = unit === "word" ? text.split(" ") : Array.from(text);
|
|
32
|
+
const joiner = unit === "word" ? " " : "";
|
|
33
|
+
return pieces.length <= OPENING[unit] ? pieces.join(joiner) : `${pieces.slice(0, OPENING[unit]).join(joiner)}…`;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const hasNumeralIn = (section: Section): boolean => section.sentences.some((sentence) => hasNumeral(sentence.tokens ?? []));
|
|
37
|
+
|
|
38
|
+
/** これより短い節は、具体物があるべきか判断できない。 */
|
|
39
|
+
const MIN_SENTENCES = 3;
|
|
40
|
+
|
|
41
|
+
const adviceWordsOf = (doc: ProseDocument): AdviceWords => ({
|
|
42
|
+
openers: (doc.lexicons["advice-opener"] ?? []).map((entry) => entry.pattern),
|
|
43
|
+
endings: (doc.lexicons["advice-ending"] ?? []).map((entry) => entry.pattern),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const intentWordsOf = (doc: ProseDocument): IntentWords => ({
|
|
47
|
+
phrases: (doc.lexicons["intent-phrase"] ?? []).map((entry) => entry.pattern),
|
|
48
|
+
endings: (doc.lexicons["intent-ending"] ?? []).map((entry) => entry.pattern),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const lowerPatternsOf = (doc: ProseDocument, id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern.toLowerCase());
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 文の半分以上が問い・指示・見込みや方針の節(質問の一覧、手引き、リスクと対策、答申の提言)は、数字で裏づける主張をしていない。
|
|
55
|
+
* 番号だけの文(a.)は数えない。
|
|
56
|
+
*/
|
|
57
|
+
const mostlyClaims = (sentences: readonly Sentence[], language: string, advice: AdviceWords, intent: IntentWords): boolean => {
|
|
58
|
+
const said = sentences.filter((sentence) => !isLabelOnly(sentence));
|
|
59
|
+
return said.filter((sentence) => isClaim(sentence, language, advice) && !statesIntent(sentence, intent)).length * 2 > said.length;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const concreteEvidence: Detector = (doc, options): Finding[] => {
|
|
63
|
+
const entries = letteredIndexEntries(doc.sections);
|
|
64
|
+
const advice = adviceWordsOf(doc);
|
|
65
|
+
const intent = intentWordsOf(doc);
|
|
66
|
+
const navigation = lowerPatternsOf(doc, "navigation-line");
|
|
67
|
+
const conditionHeadings = lowerPatternsOf(doc, "condition-heading");
|
|
68
|
+
const proseOf = (section: Section): Sentence[] => section.sentences.filter((sentence) => !isNavigationLine(sentence, navigation));
|
|
69
|
+
const sections = doc.sections.filter((section) => {
|
|
70
|
+
const sentences = proseOf(section);
|
|
71
|
+
return (
|
|
72
|
+
sentences.length >= MIN_SENTENCES &&
|
|
73
|
+
!entries.has(section) &&
|
|
74
|
+
!isConditionHeading(section.unlabeledHeading ?? section.heading, conditionHeadings) &&
|
|
75
|
+
mostlyClaims(sentences, doc.language, advice, intent)
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
const bare = sections.filter(
|
|
79
|
+
(section) => !CONCRETE.test(doc.source.slice(section.span.start, section.span.end)) && !hasNumeralIn(section) && !startsWithin(section.span, doc.links),
|
|
80
|
+
);
|
|
81
|
+
// 構造の木は作るのに手間がかかる。指摘に届かない文書では作らない。
|
|
82
|
+
const nodes = bare.length < options.limit ? [] : evidenceSpans(doc.structure);
|
|
83
|
+
const empty = bare.filter((section) => !startsWithin(section.span, nodes));
|
|
84
|
+
if (empty.length < options.limit) return [];
|
|
85
|
+
return empty.map((section) => ({
|
|
86
|
+
rule: "concrete-evidence-density",
|
|
87
|
+
severity: "info",
|
|
88
|
+
line: 0,
|
|
89
|
+
column: 0,
|
|
90
|
+
quote: section.heading.length > 0 ? section.heading : (section.sentences[0]?.text.trim() ?? ""),
|
|
91
|
+
values: {
|
|
92
|
+
word: section.heading.length > 0 ? section.heading : openingOf(section.sentences[0], doc.lengthUnit),
|
|
93
|
+
count: empty.length,
|
|
94
|
+
total: sections.length,
|
|
95
|
+
limit: options.limit,
|
|
96
|
+
offset: section.span.start,
|
|
97
|
+
},
|
|
98
|
+
}));
|
|
99
|
+
};
|
|
@@ -106,3 +106,43 @@ export const isClaim = (sentence: Pick<Sentence, "text" | "tokens">, language: s
|
|
|
106
106
|
!opensWith(sentence.text, words.openers) &&
|
|
107
107
|
!endsWith(sentence.text, words.endings) &&
|
|
108
108
|
!opensWithVerb(sentence.tokens ?? [], language);
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 見込み・あるべき姿・書き手の予定を述べる言い方。英語は文のどこかの語(may, should, we will)、日本語は文末(〜が期待される、〜すべきである)。
|
|
112
|
+
* どちらの言語の語彙表も、その言語の文書にしか無い。
|
|
113
|
+
*/
|
|
114
|
+
export type IntentWords = { readonly phrases: readonly string[]; readonly endings: readonly string[] };
|
|
115
|
+
|
|
116
|
+
/** 語の並びとして比べる形。字とアポストロフィ以外を空白に畳んで、両端に空白を置く。 */
|
|
117
|
+
const wordRun = (text: string): string =>
|
|
118
|
+
` ${text
|
|
119
|
+
.replace(/’/gu, "'")
|
|
120
|
+
.replace(/[^\p{L}']+/gu, " ")
|
|
121
|
+
.trim()} `;
|
|
122
|
+
|
|
123
|
+
/** 文頭の大文字だけを小文字に戻す。文の途中の大文字の語(in May)は、助動詞と別の語。 */
|
|
124
|
+
const withLowerHead = (text: string): string => {
|
|
125
|
+
const trimmed = text.trimStart();
|
|
126
|
+
return `${trimmed.charAt(0).toLowerCase()}${trimmed.slice(1)}`;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const containsPhrase = (text: string, phrases: readonly string[]): boolean => {
|
|
130
|
+
const words = wordRun(withLowerHead(text));
|
|
131
|
+
return phrases.some((phrase) => words.includes(wordRun(phrase.toLowerCase())));
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/** 事実でなく、起こりうること・すべきこと・書き手のする予定を述べた文(リスクと対策、提言、答申の方針)。裏づけの数字を求める主張ではない。 */
|
|
135
|
+
export const statesIntent = (sentence: Pick<Sentence, "text">, words: IntentWords): boolean =>
|
|
136
|
+
containsPhrase(sentence.text, words.phrases) || endsWith(sentence.text, words.endings);
|
|
137
|
+
|
|
138
|
+
/** 比べる形。前後の空白と、文末の句点・コロンを除き、小文字にする。 */
|
|
139
|
+
const bareLine = (text: string): string =>
|
|
140
|
+
withoutTail(text, new Set([...TERMINALS, ":", ":"]))
|
|
141
|
+
.trim()
|
|
142
|
+
.toLowerCase();
|
|
143
|
+
|
|
144
|
+
/** 変換で残ったサイトの案内(ページの先頭です。本文)。文書の本文ではない。 */
|
|
145
|
+
export const isNavigationLine = (sentence: Pick<Sentence, "text">, lines: readonly string[]): boolean => lines.includes(bareLine(sentence.text));
|
|
146
|
+
|
|
147
|
+
/** 条件を並べる節の見出し(Requirements、応募資格)。並ぶのは条件で、裏づけを求める主張ではない。 */
|
|
148
|
+
export const isConditionHeading = (heading: string, headings: readonly string[]): boolean => headings.includes(bareLine(heading));
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { Lexicon, LexiconEntry, Sentence } from "../plugin.ts";
|
|
2
2
|
import { escapeRegExp } from "../orthography.ts";
|
|
3
|
-
import { comparableText, comparableWords, entryIn, entryOpens, entryRanges } from "./lexicon-match.ts";
|
|
3
|
+
import { comparableText, comparableWords, entryCloses, entryIn, entryOpens, entryRanges } from "./lexicon-match.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 対比の枠の語。frames は 1 つで枠になる語(not only、だけでなく)。
|
|
7
7
|
* leads は打ち消し(it's not、単なる)で、turns(it's、but、ではなく)が後ろに来たときだけ枠になる。同じ文の後ろか、次の文の頭。
|
|
8
8
|
* 打ち消しの頭に立つ返しの語(It's not ready. It's not tested. の 2 つ目の It's)は返しではなく、次の打ち消し。
|
|
9
|
+
* 語の組(group)で返し方を絞る。across の打ち消し(don't、wasn't)は次の文の頭でしか返らず、その文に打ち消しがあれば返っていない。
|
|
10
|
+
* across の打ち消しを返すのは、次の文の頭の across の主語(It、They)だけ。But(I don't always. But …)は譲歩、That's は前の文全体への言葉で、
|
|
11
|
+
* 打ち消した X の代わりを言っていない。closing の打ち消し(はなく、)は、同じ文が closing の返し(です、だ)で閉じたときだけ枠。
|
|
12
|
+
* amounts は、枠の語の隣(position の側)で量を言う語(not just one、一杯だけでなく)。「一つより多い」で、X を打ち消していない。
|
|
9
13
|
*/
|
|
10
|
-
export type ContrastWords = { readonly frames: Lexicon; readonly leads: Lexicon; readonly turns: Lexicon };
|
|
14
|
+
export type ContrastWords = { readonly frames: Lexicon; readonly leads: Lexicon; readonly turns: Lexicon; readonly amounts?: Lexicon };
|
|
15
|
+
|
|
16
|
+
const ACROSS = "across";
|
|
17
|
+
const CLOSING = "closing";
|
|
11
18
|
|
|
12
19
|
const lowered = (entry: LexiconEntry): string => comparableWords(entry.pattern);
|
|
13
20
|
|
|
@@ -23,11 +30,15 @@ const answersAfter = (leadRange: Range, turns: readonly Range[], leads: readonly
|
|
|
23
30
|
const rangesOf = (text: string, word: string): Range[] =>
|
|
24
31
|
[...text.matchAll(new RegExp(escapeRegExp(word), "gu"))].map((match) => ({ start: match.index, end: match.index + word.length }));
|
|
25
32
|
|
|
33
|
+
/** 組の無い語。同じ文の中でも、次の文の頭でも返す。 */
|
|
34
|
+
const plainOf = (lexicon: Lexicon): Lexicon => lexicon.filter((entry) => entry.group === undefined);
|
|
35
|
+
const groupOf = (lexicon: Lexicon, group: string): Lexicon => lexicon.filter((entry) => entry.group === group);
|
|
36
|
+
|
|
26
37
|
/** 品詞が無ければ位置を語で言えないので、空白をまとめた文字列の位置で比べる。 */
|
|
27
38
|
const textTurnAfter = (sentence: Sentence, lead: LexiconEntry, words: ContrastWords): boolean => {
|
|
28
39
|
const text = comparableText(sentence);
|
|
29
40
|
const leads = words.leads.flatMap((entry) => rangesOf(text, lowered(entry)));
|
|
30
|
-
const turns = words.turns.flatMap((entry) => rangesOf(text, lowered(entry)));
|
|
41
|
+
const turns = plainOf(words.turns).flatMap((entry) => rangesOf(text, lowered(entry)));
|
|
31
42
|
return rangesOf(text, lowered(lead)).some((range) => answersAfter(range, turns, leads));
|
|
32
43
|
};
|
|
33
44
|
|
|
@@ -35,20 +46,67 @@ const textTurnAfter = (sentence: Sentence, lead: LexiconEntry, words: ContrastWo
|
|
|
35
46
|
const turnAfter = (sentence: Sentence, lead: LexiconEntry, words: ContrastWords): boolean => {
|
|
36
47
|
if (sentence.tokens === undefined || lead.tokens === undefined) return textTurnAfter(sentence, lead, words);
|
|
37
48
|
const leads = words.leads.flatMap((entry) => entryRanges(sentence, entry));
|
|
38
|
-
const turns = words.turns.flatMap((entry) => entryRanges(sentence, entry));
|
|
49
|
+
const turns = plainOf(words.turns).flatMap((entry) => entryRanges(sentence, entry));
|
|
39
50
|
return entryRanges(sentence, lead).some((range) => answersAfter(range, turns, leads));
|
|
40
51
|
};
|
|
41
52
|
|
|
42
53
|
/** 次の文が返しの語で始まり、それ自体が打ち消しで始まっていないか。 */
|
|
43
54
|
const nextTurns = (next: Sentence | undefined, words: ContrastWords): boolean =>
|
|
44
|
-
next !== undefined && words.turns.some((turn) => entryOpens(next, turn)) && !words.leads.some((lead) => entryOpens(next, lead));
|
|
55
|
+
next !== undefined && plainOf(words.turns).some((turn) => entryOpens(next, turn)) && !words.leads.some((lead) => entryOpens(next, lead));
|
|
56
|
+
|
|
57
|
+
const LETTER = /\p{L}/u;
|
|
58
|
+
|
|
59
|
+
/** 品詞が無いと前方一致になるので、語の途中(It と Items)では文の頭の語と見ない。 */
|
|
60
|
+
const opensWithWord = (sentence: Sentence, entry: LexiconEntry): boolean => {
|
|
61
|
+
if (!entryOpens(sentence, entry)) return false;
|
|
62
|
+
if (sentence.tokens !== undefined && entry.tokens !== undefined) return true;
|
|
63
|
+
return !LETTER.test(comparableText(sentence).charAt(comparableWords(entry.pattern).length));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** 次の文が across の主語(It、They)で始まり、どこにも打ち消しが無いか(It wasn't the plan. It was luck.)。 */
|
|
67
|
+
const nextAffirms = (next: Sentence | undefined, words: ContrastWords): boolean =>
|
|
68
|
+
next !== undefined && groupOf(words.turns, ACROSS).some((turn) => opensWithWord(next, turn)) && !words.leads.some((lead) => entryIn(next, lead));
|
|
69
|
+
|
|
70
|
+
const AFTER = "after";
|
|
71
|
+
const DIGIT_AFTER = /^\p{Nd}/u;
|
|
72
|
+
/** 数字と、続く助数詞一字(1回、2つ)。 */
|
|
73
|
+
const DIGIT_BEFORE = /\p{Nd}\p{L}?$/u;
|
|
74
|
+
|
|
75
|
+
/** 枠の語(range)の隣で量を言っているか。position が after なら後ろ(not just one)、ほかは前(一杯だけでなく)。数字も量。 */
|
|
76
|
+
const measuresAmount = (text: string, range: Range, amounts: Lexicon): boolean => {
|
|
77
|
+
const after = text.slice(range.end).trimStart();
|
|
78
|
+
const before = text.slice(0, range.start).trimEnd();
|
|
79
|
+
return amounts.some((amount) => {
|
|
80
|
+
const word = lowered(amount);
|
|
81
|
+
if (amount.position !== AFTER) return before.endsWith(word) || DIGIT_BEFORE.test(before);
|
|
82
|
+
return (after.startsWith(word) && !LETTER.test(after.charAt(word.length))) || DIGIT_AFTER.test(after);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** 枠の語が、量を言っていない所に一度でもあるか。文字列の上で位置を言えないときは枠のまま。 */
|
|
87
|
+
const framesIn = (sentence: Sentence, frame: LexiconEntry, amounts: Lexicon): boolean => {
|
|
88
|
+
if (!entryIn(sentence, frame)) return false;
|
|
89
|
+
const text = comparableText(sentence);
|
|
90
|
+
const ranges = rangesOf(text, lowered(frame));
|
|
91
|
+
return ranges.length === 0 || ranges.some((range) => !measuresAmount(text, range, amounts));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const closesWithTurn = (sentence: Sentence, words: ContrastWords): boolean => groupOf(words.turns, CLOSING).some((turn) => entryCloses(sentence, turn));
|
|
95
|
+
|
|
96
|
+
const answeredBy = (lead: LexiconEntry, sentence: Sentence, next: Sentence | undefined, words: ContrastWords): boolean => {
|
|
97
|
+
if (lead.group === ACROSS) return nextAffirms(next, words);
|
|
98
|
+
if (lead.group === CLOSING) return closesWithTurn(sentence, words);
|
|
99
|
+
return turnAfter(sentence, lead, words) || nextTurns(next, words);
|
|
100
|
+
};
|
|
45
101
|
|
|
46
102
|
const answered = (sentence: Sentence, next: Sentence | undefined, words: ContrastWords): boolean =>
|
|
47
|
-
words.leads.some((lead) => entryIn(sentence, lead) && (
|
|
103
|
+
words.leads.some((lead) => entryIn(sentence, lead) && answeredBy(lead, sentence, next, words));
|
|
48
104
|
|
|
49
105
|
/**
|
|
50
106
|
* 対比の枠で書いた文。「X ではなく Y」「It's not X. It's Y.」の形で、打ち消した側の文を返す。
|
|
51
107
|
* 2 文にまたがる枠も 1 つと数える。返しの文は数えない。
|
|
52
108
|
*/
|
|
53
109
|
export const contrastSentences = (sentences: readonly Sentence[], words: ContrastWords): Sentence[] =>
|
|
54
|
-
sentences.filter(
|
|
110
|
+
sentences.filter(
|
|
111
|
+
(sentence, index) => words.frames.some((frame) => framesIn(sentence, frame, words.amounts ?? [])) || answered(sentence, sentences[index + 1], words),
|
|
112
|
+
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Token } from "../plugin.ts";
|
|
2
2
|
import type { TokenRange } from "./token-column.ts";
|
|
3
3
|
import { firstOf, secondOf, withoutFirst, type View } from "./list-view.ts";
|
|
4
|
+
import { isBareIndefiniteModifier } from "./list-item.ts";
|
|
4
5
|
|
|
5
6
|
// Coordinate adjectives before one noun (long-term, strategic collaboration): the comma between them is not a list comma,
|
|
6
7
|
// and the first adjective is not an item. Pure.
|
|
@@ -30,12 +31,13 @@ export const opensWithModifiedNoun = (words: readonly Token[]): boolean => MODIF
|
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* The list without its first item when that item is the first of two coordinate adjectives on the second item's noun
|
|
33
|
-
* (… from CISA's long-term, strategic collaboration with A and B: the and joins two items, not three)
|
|
34
|
+
* (… from CISA's long-term, strategic collaboration with A and B: the and joins two items, not three), or an indefinite
|
|
35
|
+
* article with adjectives only (A simple, minimalist palette of cool blue and gray), which no noun has closed yet.
|
|
34
36
|
*/
|
|
35
37
|
export const withoutCoordinateAdjective = (view: View): View => {
|
|
36
38
|
const [first, second] = [firstOf(view), secondOf(view)];
|
|
37
39
|
if (first === undefined || second === undefined) return view;
|
|
38
40
|
const { tokens } = view.list.scope.sentence;
|
|
39
41
|
const coordinate = endsWithModifier(wordsOf(tokens, first.item)) && opensWithModifiedNoun(wordsOf(tokens, second.item));
|
|
40
|
-
return coordinate ? withoutFirst(view) : view;
|
|
42
|
+
return coordinate || isBareIndefiniteModifier(view.list.scope, first.item) ? withoutFirst(view) : view;
|
|
41
43
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Detector, Finding, MarkupHeading } from "../plugin.ts";
|
|
1
|
+
import type { Detector, Finding, MarkupHeading, ProseDocument } from "../plugin.ts";
|
|
2
|
+
import { numberingStyleOf, UNNUMBERED, type NumberLabel } from "../heading-numbering.ts";
|
|
2
3
|
import { lineNumberAt, linesOf } from "../structure/lines.ts";
|
|
3
4
|
import { recordLabelOf, recordRhythmMask } from "./heading-record-rhythm.ts";
|
|
4
5
|
import { findingAt, writtenHeadings } from "./markup-finding.ts";
|
|
@@ -18,9 +19,28 @@ const parentIndexes = (headings: readonly MarkupHeading[]): number[] => {
|
|
|
18
19
|
});
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 見出しを比べる範囲。ふつうは親の見出し。番号の無い見出しは、同じ親の下の同じ深さで直前の番号付きの見出し(「7.3 …」)までを範囲にする。
|
|
24
|
+
* 番号付きの節とその中の「Example 1」を同じ深さに並べた文書では、番号付きの見出しが読み手にとっての親で、節ごとに数え直す例は重複でない。
|
|
25
|
+
*/
|
|
26
|
+
const scopesOf = (headings: readonly MarkupHeading[], parents: readonly number[], isNumbered: (text: string) => boolean): string[] => {
|
|
27
|
+
const lastNumbered = new Map<string, number>();
|
|
28
|
+
return headings.map((heading, index) => {
|
|
29
|
+
const parent = String(parents[index] ?? -1);
|
|
30
|
+
const row = `${parent}:${String(heading.depth)}`;
|
|
31
|
+
if (isNumbered(heading.text)) lastNumbered.set(row, index);
|
|
32
|
+
const section = lastNumbered.get(row);
|
|
33
|
+
return section === undefined || section === index ? parent : `${parent}/${String(section)}`;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
22
36
|
|
|
23
|
-
|
|
37
|
+
/** 文書の題(最初の見出しが # のとき、その言葉)。ページの題を本文の頭や目次の後でもう一度掲げるのは、節の重複ではない。 */
|
|
38
|
+
const titleKeyOf = (headings: readonly MarkupHeading[]): string | undefined => {
|
|
39
|
+
const first = headings[0];
|
|
40
|
+
return first?.depth === 1 ? headingKey(first.text) : undefined;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type RepeatedHeading = { readonly heading: MarkupHeading; readonly first: MarkupHeading };
|
|
24
44
|
|
|
25
45
|
/** 見出しごとに、同じ親の下の兄弟の型の並びで、決まった見出しの組をくり返す所にあるか(recordRhythmMask)。 */
|
|
26
46
|
const inRecordRhythm = (parents: readonly number[], keys: readonly string[]): boolean[] => {
|
|
@@ -40,31 +60,40 @@ const inRecordRhythm = (parents: readonly number[], keys: readonly string[]): bo
|
|
|
40
60
|
return inRhythm;
|
|
41
61
|
};
|
|
42
62
|
|
|
63
|
+
/** 番号の付いた見出しか。番号を持つ語(Chapter 2、第2章)は言語の語彙表 heading-number-label から。 */
|
|
64
|
+
const numberedBy =
|
|
65
|
+
(labels: readonly NumberLabel[]) =>
|
|
66
|
+
(text: string): boolean =>
|
|
67
|
+
numberingStyleOf(text, labels) !== UNNUMBERED;
|
|
68
|
+
|
|
43
69
|
/**
|
|
44
70
|
* 同じ親の下で、前の見出しと同じ言葉の見出し(markdownlint の MD024 siblings_only)。変更履歴の版ごとの「Added」「Fixed」のように、
|
|
45
71
|
* 親が違えば同じ言葉でもよい。深さが違っても親が同じなら兄弟として比べる(飛んだ深さの見出しも同じ親の下にある)。
|
|
46
|
-
*
|
|
72
|
+
* 番号付きの見出しが同じ深さで区切る範囲(scopesOf)も親として扱う。事例ごとに決まった見出しの組をくり返す所(recordRhythmMask)と、
|
|
73
|
+
* 文書の題をもう一度掲げた所は、文書の作りとしての重複なので言わない。
|
|
47
74
|
*/
|
|
48
|
-
export const repeatedSiblingHeadings = (headings: readonly MarkupHeading[]): RepeatedHeading[] => {
|
|
75
|
+
export const repeatedSiblingHeadings = (headings: readonly MarkupHeading[], labels: readonly NumberLabel[] = []): RepeatedHeading[] => {
|
|
49
76
|
const parents = parentIndexes(headings);
|
|
77
|
+
const scopes = scopesOf(headings, parents, numberedBy(labels));
|
|
50
78
|
const keys = headings.map((heading) => headingKey(heading.text));
|
|
51
79
|
const inRhythm = inRecordRhythm(parents, keys);
|
|
52
|
-
const
|
|
53
|
-
const
|
|
80
|
+
const title = titleKeyOf(headings);
|
|
81
|
+
const seen = new Map<string, MarkupHeading>();
|
|
82
|
+
return headings.flatMap((heading, index) => {
|
|
54
83
|
const key = keys[index] ?? "";
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
seen.set(
|
|
58
|
-
|
|
59
|
-
if (first === undefined) siblings.set(key, heading);
|
|
60
|
-
return first === undefined || key === "" || inRhythm[index] === true ? [] : [{ heading, first }];
|
|
84
|
+
const scoped = `${scopes[index] ?? ""}\n${key}`;
|
|
85
|
+
const first = seen.get(scoped);
|
|
86
|
+
if (first === undefined) seen.set(scoped, heading);
|
|
87
|
+
return first === undefined || key === "" || key === title || inRhythm[index] === true ? [] : [{ heading, first }];
|
|
61
88
|
});
|
|
62
|
-
return repeats;
|
|
63
89
|
};
|
|
64
90
|
|
|
91
|
+
const numberLabelsOf = (doc: ProseDocument): NumberLabel[] =>
|
|
92
|
+
(doc.lexicons["heading-number-label"] ?? []).map((entry) => ({ word: entry.pattern, position: entry.position === "after" ? "after" : "before" }));
|
|
93
|
+
|
|
65
94
|
export const duplicateHeading: Detector = (doc): Finding[] => {
|
|
66
95
|
const lines = linesOf(doc.source);
|
|
67
|
-
return repeatedSiblingHeadings(writtenHeadings(doc)).map(({ heading, first }) =>
|
|
96
|
+
return repeatedSiblingHeadings(writtenHeadings(doc), numberLabelsOf(doc)).map(({ heading, first }) =>
|
|
68
97
|
findingAt(doc, heading, { heading: heading.text, firstLine: lineNumberAt(lines, first.start) ?? 0 }),
|
|
69
98
|
);
|
|
70
99
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Where an email's greeting and closing words are found in a line: a Latin word at the head of the line or of one of its
|
|
2
|
+
// sentences, a Japanese word anywhere, and a name alone as the salutation (Priya,). Pure; the words come from the caller.
|
|
3
|
+
import { escapeRegExp } from "../orthography.ts";
|
|
4
|
+
|
|
5
|
+
const LATIN_START = /^[A-Za-z]/u;
|
|
6
|
+
const LETTER = /\p{L}/u;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Whether a line holds one of the words. A Latin word opens the line (Dear, Best regards) and is followed by no letter,
|
|
10
|
+
* so "Hi" does not match "History"; a Japanese word may stand anywhere in it (いつもお世話になっております).
|
|
11
|
+
*/
|
|
12
|
+
export const lineHas = (line: string, words: readonly string[]): boolean => {
|
|
13
|
+
const trimmed = line.trim();
|
|
14
|
+
const folded = trimmed.toLowerCase();
|
|
15
|
+
return words.some((word) => {
|
|
16
|
+
if (!LATIN_START.test(word)) return trimmed.includes(word);
|
|
17
|
+
return folded.startsWith(word.toLowerCase()) && !LETTER.test(trimmed.charAt(word.length));
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** A name alone as the salutation (Priya,) is a few words; a longer line ending in a comma is a sentence run on. */
|
|
22
|
+
const MAX_SALUTATION_WORDS = 3;
|
|
23
|
+
|
|
24
|
+
/** Whether a line is a name alone as the salutation: a few words holding a letter, ending with one of the marks, no sentence's end. */
|
|
25
|
+
export const isSalutation = (line: string, marks: readonly string[], sentenceEnds: readonly string[]): boolean => {
|
|
26
|
+
const trimmed = line.trim();
|
|
27
|
+
const mark = marks.find((candidate) => trimmed.endsWith(candidate));
|
|
28
|
+
if (mark === undefined || !LETTER.test(trimmed)) return false;
|
|
29
|
+
const name = trimmed.slice(0, trimmed.length - mark.length);
|
|
30
|
+
return name.split(/\s+/u).length <= MAX_SALUTATION_WORDS && !sentenceEnds.some((end) => name.includes(end));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** The line's sentences after the first: what follows a sentence's end mark and a blank (…on Monday. Thanks, and…). */
|
|
34
|
+
const laterSentences = (line: string, sentenceEnds: readonly string[]): string[] =>
|
|
35
|
+
sentenceEnds.length === 0 ? [] : line.split(new RegExp(`(?:${sentenceEnds.map(escapeRegExp).join("|")})\\s+`, "u")).slice(1);
|
|
36
|
+
|
|
37
|
+
/** Whether a closing opens the line or one of its later sentences (It reopens on Monday. Thanks, and enjoy the day!). */
|
|
38
|
+
export const closingIn = (line: string, closings: readonly string[], sentenceEnds: readonly string[]): boolean =>
|
|
39
|
+
[line, ...laterSentences(line, sentenceEnds)].some((sentence) => lineHas(sentence, closings));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// A work email or letter's own parts: a greeting and a closing, a subject line, and an attachment the text mentions.
|
|
2
2
|
// Pure. The words (お世話になっております, Dear, Best regards, 件名, attached) come from the language's email-greeting,
|
|
3
|
-
// email-closing, email-sentence-end, memo-header-label, notice-header, newsletter-issue, email-subject-field, attachment-mention, attachment-not-mention and attachment-line lexicons. The
|
|
3
|
+
// email-closing, email-salutation-end, email-sentence-end, memo-header-label, notice-header, newsletter-issue, email-subject-field, attachment-mention, attachment-not-mention and attachment-line lexicons. The
|
|
4
4
|
// header and the signature are masked in doc.prose; a quoted reply is someone else's words and is left out.
|
|
5
5
|
import { escapeRegExp } from "../orthography.ts";
|
|
6
6
|
import { quoteAt } from "./structure-tree.ts";
|
|
7
|
+
import { closingIn, isSalutation, lineHas } from "./email-frame-words.ts";
|
|
7
8
|
import { isNoticeHead, noticeWordsOf } from "../notice-header.ts";
|
|
8
9
|
import { isHeadingLine, isIssueHead, issueWordsOf } from "../newsletter-issue.ts";
|
|
9
10
|
import type { Detector, Finding, ProseDocument, Span } from "../plugin.ts";
|
|
@@ -20,22 +21,8 @@ export type BodyLine = { readonly start: number; readonly text: string; readonly
|
|
|
20
21
|
|
|
21
22
|
const patternsOf = (doc: ProseDocument, id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
22
23
|
|
|
23
|
-
const LATIN_START = /^[A-Za-z]/u;
|
|
24
24
|
const LETTER = /\p{L}/u;
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Whether a line holds one of the words. A Latin word opens the line (Dear, Best regards) and is followed by no letter,
|
|
28
|
-
* so "Hi" does not match "History"; a Japanese word may stand anywhere in it (いつもお世話になっております).
|
|
29
|
-
*/
|
|
30
|
-
export const lineHas = (line: string, words: readonly string[]): boolean => {
|
|
31
|
-
const trimmed = line.trim();
|
|
32
|
-
const folded = trimmed.toLowerCase();
|
|
33
|
-
return words.some((word) => {
|
|
34
|
-
if (!LATIN_START.test(word)) return trimmed.includes(word);
|
|
35
|
-
return folded.startsWith(word.toLowerCase()) && !LETTER.test(trimmed.charAt(word.length));
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
26
|
/**
|
|
40
27
|
* Whether each offset, asked in rising order, is inside one of the spans (sorted by start). One pass over the spans for
|
|
41
28
|
* the whole document: an archive with a quoted reply in every message stays linear.
|
|
@@ -161,14 +148,18 @@ export const frameSlips = (
|
|
|
161
148
|
closings: readonly string[],
|
|
162
149
|
sentenceEnds: readonly string[],
|
|
163
150
|
signings: readonly number[] = [],
|
|
151
|
+
salutationEnds: readonly string[] = [],
|
|
164
152
|
): FrameSlip[] => {
|
|
165
153
|
const first = lines[0];
|
|
166
154
|
const last = lines.at(-1);
|
|
167
155
|
if (first === undefined || last === undefined) return [];
|
|
168
|
-
const greeted =
|
|
156
|
+
const greeted =
|
|
157
|
+
isSalutation(first.text, salutationEnds, sentenceEnds) ||
|
|
158
|
+
lines.slice(0, greetingLineCount(lines, sentenceEnds)).some((line) => lineHas(line.text, greetings));
|
|
169
159
|
const parts = partsOf(lines);
|
|
170
160
|
const closed = parts.some(
|
|
171
|
-
(part, index) =>
|
|
161
|
+
(part, index) =>
|
|
162
|
+
part.slice(-CLOSING_LINES).some((line) => closingIn(line.text, closings, sentenceEnds)) || signedOff(part, parts[index + 1]?.[0], signings),
|
|
172
163
|
);
|
|
173
164
|
return [
|
|
174
165
|
...(greeted ? [] : [{ variant: "greeting" as const, offset: first.start }]),
|
|
@@ -209,11 +200,13 @@ export const isMemo = (source: string, labels: readonly string[], sentenceEnds:
|
|
|
209
200
|
|
|
210
201
|
/**
|
|
211
202
|
* The source's lines before the first sentence (the first lines, when no line ends one), past blank lines and a quoted reply.
|
|
212
|
-
* A heading is a title, not a sentence, even when it ends in an exclamation mark (# Vol.12 転落に注意!)
|
|
203
|
+
* A heading is a title, not a sentence, even when it ends in an exclamation mark (# Vol.12 転落に注意!); a header field is
|
|
204
|
+
* the header's, even when its value ends one (Withdrawn: On 21 August the letter was withdrawn.).
|
|
213
205
|
*/
|
|
214
206
|
export const headLines = (source: string, sentenceEnds: readonly string[]): string[] => {
|
|
215
207
|
const lines = source.split("\n").filter((line) => line.trim() !== "" && !line.trimStart().startsWith(">"));
|
|
216
|
-
const
|
|
208
|
+
const isSentence = (line: string): boolean => !isHeadingLine(line) && fieldOf(line.trim()) === undefined && endsSentence(line, sentenceEnds);
|
|
209
|
+
const firstSentence = lines.findIndex(isSentence);
|
|
217
210
|
return lines.slice(0, firstSentence === -1 ? HEADER_LINES : firstSentence);
|
|
218
211
|
};
|
|
219
212
|
|
|
@@ -230,7 +223,9 @@ const frameSlipsOf = (doc: ProseDocument): FrameSlip[] => {
|
|
|
230
223
|
const sentenceEnds = patternsOf(doc, "email-sentence-end");
|
|
231
224
|
if (takesNoFrame(doc, sentenceEnds)) return [];
|
|
232
225
|
const lines = bodyLines(doc.source, doc.prose ?? doc.source, doc.replyQuotes ?? []);
|
|
233
|
-
|
|
226
|
+
const signings = signingLines(doc.source, doc.replyQuotes ?? []);
|
|
227
|
+
const words = (id: string): string[] => patternsOf(doc, id);
|
|
228
|
+
return frameSlips(lines, words("email-greeting"), words("email-closing"), sentenceEnds, signings, words("email-salutation-end"));
|
|
234
229
|
};
|
|
235
230
|
|
|
236
231
|
export const emailFrame: Detector = (doc): Finding[] =>
|
|
@@ -18,9 +18,9 @@ const kindOf = (run: string): AlnumKind => {
|
|
|
18
18
|
return single ? "digit" : "digits";
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
/** 項目の番号の並び(行の頭や括弧の後ろの「1.」「(1)」「1)
|
|
21
|
+
/** 項目の番号の並び(行の頭や括弧の後ろの「1.」「(1)」「1)」、有価証券報告書の項目「4【経営者による…】」)。項目の印で、本文の数ではない。 */
|
|
22
22
|
const LABEL_BEFORE = /(?:^|[\s、,,(([[])$/u;
|
|
23
|
-
const LABEL_AFTER = /^[..))]\]]/u;
|
|
23
|
+
const LABEL_AFTER = /^[..))]\]【]/u;
|
|
24
24
|
const LABEL_REACH = 1;
|
|
25
25
|
|
|
26
26
|
/** 注の印(「※1」「(※3)」)。注どうしで決まった書き方をする。 */
|
|
@@ -103,7 +103,7 @@ const KINDS: readonly AlnumKind[] = ["letter", "letters", "digit", "digits"];
|
|
|
103
103
|
|
|
104
104
|
/** 半角の英数字を全角に(NFKC の逆)。 */
|
|
105
105
|
const FULLWIDTH_OFFSET = 0xfee0;
|
|
106
|
-
const toFullwidth = (text: string): string => text.replace(/[A-Za-z0-9
|
|
106
|
+
const toFullwidth = (text: string): string => text.replace(/[A-Za-z0-9./,]/gu, (char) => String.fromCodePoint((char.codePointAt(0) ?? 0) + FULLWIDTH_OFFSET));
|
|
107
107
|
|
|
108
108
|
/** 同じ並びの、もう一方の幅の書き方。 */
|
|
109
109
|
const otherWidth = (run: AlnumRun): string => (run.fullwidth ? run.written.normalize("NFKC") : toFullwidth(run.written));
|
|
@@ -127,6 +127,23 @@ const datelineOf = (doc: ProseDocument): Span | undefined => {
|
|
|
127
127
|
return first !== undefined && DATELINE.test(doc.source.slice(first.span.start, first.span.end).trim()) ? first.span : undefined;
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
+
/** 多いほうの英字の語が何種類あれば、文書の書き方と見るか。BAR を二度書いただけなら、それはその語の書き方。 */
|
|
131
|
+
const HABIT_WORDS = 2;
|
|
132
|
+
|
|
133
|
+
const wordOf = (run: AlnumRun): string => run.written.normalize("NFKC").toUpperCase();
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 英字の語の少ないほうを、文書の書き方からはずれたと言えるか。多いほうが二種類以上の語か、少ないほうと同じ語(URL と URL)のとき。
|
|
137
|
+
* 全角の BAR だけの文書の DELICATE は、別の語を別の書き方で書いただけ。
|
|
138
|
+
*/
|
|
139
|
+
const departsFromHabit =
|
|
140
|
+
(ofKind: readonly Located[], odd: readonly Located[]) =>
|
|
141
|
+
({ run }: Located): boolean => {
|
|
142
|
+
if (run.kind !== "letters") return true;
|
|
143
|
+
const usual = new Set(ofKind.filter((entry) => !odd.includes(entry)).map((entry) => wordOf(entry.run)));
|
|
144
|
+
return usual.size >= HABIT_WORDS || usual.has(wordOf(run));
|
|
145
|
+
};
|
|
146
|
+
|
|
130
147
|
const findingOf = ({ sentence, run }: Located, count: number, of: number, limit: number): Finding => ({
|
|
131
148
|
rule: "",
|
|
132
149
|
severity: "warning",
|
|
@@ -151,6 +168,9 @@ export const fullwidthAlnum: Detector = (doc, options): Finding[] => {
|
|
|
151
168
|
return KINDS.flatMap((kind) => {
|
|
152
169
|
const ofKind = located.filter(({ run }) => run.kind === kind);
|
|
153
170
|
const odd = minorityWithin(ofKind, ({ run }) => run.fullwidth, options.limit);
|
|
154
|
-
return odd
|
|
171
|
+
return odd
|
|
172
|
+
.filter(({ run }) => !isHalfwidthEnglishWord(run))
|
|
173
|
+
.filter(departsFromHabit(ofKind, odd))
|
|
174
|
+
.map((entry) => findingOf(entry, odd.length, ofKind.length, options.limit));
|
|
155
175
|
});
|
|
156
176
|
};
|