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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// An acronym the document explains without the "Name (ACR)" form. Pure.
|
|
2
|
+
import { numberedSeries } from "./acronym-series.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* "The VIX—a forward-looking measure of near-term stock market volatility—declined": an apposition between dashes right
|
|
@@ -32,3 +33,125 @@ export const headingsSpellingOut = (headings: readonly string[]): ((acronym: str
|
|
|
32
33
|
const spelled = new Set(headings.flatMap((heading) => spelledBy(heading) ?? []));
|
|
33
34
|
return (acronym) => spelled.has(acronym.replaceAll(/[^A-Z]/gu, ""));
|
|
34
35
|
};
|
|
36
|
+
|
|
37
|
+
/** The longest acronym read as spelled out in a sentence; a run of name words stops being followed past it. */
|
|
38
|
+
const MAX_SPELLED = 10;
|
|
39
|
+
/** A word that can be part of a name: a capital first, then letters, apostrophes, dots or hyphens (Nat'l, Comm'n, U.S.). */
|
|
40
|
+
const NAME_WORD = /^\p{Lu}[\p{L}'’.-]*$/u;
|
|
41
|
+
/** Marks before a word that are not part of it, and that open a new phrase: brackets and quotes. */
|
|
42
|
+
const OPENING_MARKS = /^[([“‘"']+/u;
|
|
43
|
+
const CLOSING_MARKS: ReadonlySet<string> = new Set(")]”’\"',.;:!?");
|
|
44
|
+
|
|
45
|
+
const withoutClosingMarks = (word: string): string => {
|
|
46
|
+
const characters = [...word];
|
|
47
|
+
return characters.slice(0, characters.findLastIndex((character) => !CLOSING_MARKS.has(character)) + 1).join("");
|
|
48
|
+
};
|
|
49
|
+
/** Punctuation after a word that ends the name it is in ("Administration,", "Mass.:"). The dot of an initialism (U.S.) does too. */
|
|
50
|
+
const NAME_BREAK = /[)\]”’",;:!?.]$/u;
|
|
51
|
+
/**
|
|
52
|
+
* A bracket opened right after the name, or after more words of it, and still open at the acronym (Services (HHS and the
|
|
53
|
+
* Department), Agency for Health (ARPA-H program), Agreement (hereinafter "SLA")): that is the bracketed expansion, which the
|
|
54
|
+
* expansion reader decides, with its own conditions.
|
|
55
|
+
*/
|
|
56
|
+
const BRACKET_AFTER_NAME = /^[\s\p{L}'’.&-]*[((][^))]*$/u;
|
|
57
|
+
const SPELLED_ACRONYM = new RegExp(String.raw`(?<![\p{L}\p{N}_&])[A-Z]{${MIN_SPELLED},${MAX_SPELLED}}(?![\p{L}\p{N}_&])`, "gu");
|
|
58
|
+
|
|
59
|
+
type SentenceWord = { readonly core: string; readonly end: number; readonly opens: boolean; readonly closes: boolean };
|
|
60
|
+
|
|
61
|
+
const sentenceWords = (sentence: string): SentenceWord[] =>
|
|
62
|
+
[...sentence.matchAll(/\S+/gu)].map((match) => {
|
|
63
|
+
const core = withoutClosingMarks(match[0].replace(OPENING_MARKS, ""));
|
|
64
|
+
const leading = match[0].length - match[0].replace(OPENING_MARKS, "").length;
|
|
65
|
+
return { core, end: match.index + leading + core.length, opens: leading > 0, closes: NAME_BREAK.test(match[0]) };
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/** Initials and where they end, for the runs of name words that start at `from`. Small words join a run, never open or close one. */
|
|
69
|
+
type Spelled = { readonly letters: string; readonly end: number };
|
|
70
|
+
|
|
71
|
+
// A loop that stops at the run's end: slicing the rest of the sentence for every word would be quadratic in a long one.
|
|
72
|
+
const runsFrom = (words: readonly SentenceWord[], from: number): Spelled[] => {
|
|
73
|
+
const runs: Spelled[] = [];
|
|
74
|
+
const letters: string[] = [];
|
|
75
|
+
for (let index = from; index < words.length && letters.length < MAX_SPELLED; index += 1) {
|
|
76
|
+
const word = words[index];
|
|
77
|
+
if (word === undefined || (index > from && word.opens)) break;
|
|
78
|
+
const named = NAME_WORD.test(word.core);
|
|
79
|
+
if (!named && (index === from || !JOINERS.has(word.core))) break;
|
|
80
|
+
if (named) letters.push(word.core.charAt(0));
|
|
81
|
+
if (named && letters.length >= MIN_SPELLED) runs.push({ letters: letters.join(""), end: word.end });
|
|
82
|
+
if (word.closes) break;
|
|
83
|
+
}
|
|
84
|
+
return runs;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Acronyms whose name is written out earlier in the same sentence, without brackets: a citation names the publisher and then
|
|
89
|
+
* gives its short name ("U.S. Small Business Administration, … (Washington: SBA, August)", "(Nat'l Indian Gaming Comm'n May
|
|
90
|
+
* 30, 2002) (NIGC Final Order)"). The name must give the acronym's letters word for word, and come before the acronym's first
|
|
91
|
+
* use: a name written out only after the reader has met the acronym, or in another sentence, does not explain it.
|
|
92
|
+
*/
|
|
93
|
+
export const spelledInSentence = (sentences: readonly string[]): ReadonlySet<string> => {
|
|
94
|
+
const seen = new Set<string>();
|
|
95
|
+
const spelledFirst = new Set<string>();
|
|
96
|
+
sentences.forEach((sentence) => {
|
|
97
|
+
const acronyms = [...sentence.matchAll(SPELLED_ACRONYM)].filter((match) => !seen.has(match[0]));
|
|
98
|
+
if (acronyms.length === 0) return;
|
|
99
|
+
const words = sentenceWords(sentence);
|
|
100
|
+
const spelled = words.flatMap((_, index) => runsFrom(words, index));
|
|
101
|
+
acronyms.forEach((match) => {
|
|
102
|
+
if (seen.has(match[0])) return;
|
|
103
|
+
seen.add(match[0]);
|
|
104
|
+
const spelledBefore = (name: Spelled): boolean =>
|
|
105
|
+
name.letters === match[0] && name.end <= match.index && !BRACKET_AFTER_NAME.test(sentence.slice(name.end, match.index));
|
|
106
|
+
if (spelled.some(spelledBefore)) spelledFirst.add(match[0]);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
return spelledFirst;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** An acronym, and the noun after it when it is used as a modifier ("IR plans"). */
|
|
113
|
+
const MODIFIER_ACRONYM = /(?<![\p{L}\p{N}_&])(?<acronym>[A-Z]{2,10})(?![\p{L}\p{N}_&])(?:\s+(?<noun>\p{Ll}+))?/gu;
|
|
114
|
+
|
|
115
|
+
/** A noun without its plural ending: "plans" and "plan" are one noun. */
|
|
116
|
+
const singularOf = (word: string): string => word.toLowerCase().replace(/(?:es|s)$/u, "");
|
|
117
|
+
|
|
118
|
+
/** Whether the words before index, ending with the noun, spell the acronym in lower case ("incident response plan" → IR plan). */
|
|
119
|
+
const spellsBeforeNoun = (words: readonly string[], index: number, acronym: string, noun: string): boolean => {
|
|
120
|
+
const name = words.slice(index - acronym.length, index);
|
|
121
|
+
return (
|
|
122
|
+
name.length === acronym.length &&
|
|
123
|
+
name.every((word) => /^\p{Ll}+$/u.test(word)) &&
|
|
124
|
+
name.map((word) => word.charAt(0)).join("") === acronym.toLowerCase() &&
|
|
125
|
+
singularOf(words[index] ?? "") === singularOf(noun)
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Acronyms written out in lower case earlier in the same sentence, before the same noun ("Have an incident response plan
|
|
131
|
+
* and use it: … exercise IR plans"). The repeated noun ties the two: two letters alone are spelled by chance too often.
|
|
132
|
+
*/
|
|
133
|
+
export const spelledBeforeSameNoun = (sentences: readonly string[]): ReadonlySet<string> => {
|
|
134
|
+
const seen = new Set<string>();
|
|
135
|
+
const spelled = new Set<string>();
|
|
136
|
+
sentences.forEach((sentence) => {
|
|
137
|
+
[...sentence.matchAll(MODIFIER_ACRONYM)].forEach((match) => {
|
|
138
|
+
const acronym = match.groups?.["acronym"] ?? "";
|
|
139
|
+
const noun = match.groups?.["noun"];
|
|
140
|
+
if (seen.has(acronym)) return;
|
|
141
|
+
seen.add(acronym);
|
|
142
|
+
if (noun === undefined) return;
|
|
143
|
+
const words = sentenceWords(sentence.slice(0, match.index)).map((word) => word.core);
|
|
144
|
+
if (words.some((_, index) => spellsBeforeNoun(words, index, acronym, noun))) spelled.add(acronym);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
return spelled;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The acronyms the text explains without brackets: glossed between dashes, named earlier in the sentence (capitalised, or in
|
|
152
|
+
* lower case before the same noun), or a series cited by number.
|
|
153
|
+
*/
|
|
154
|
+
export const explainedInText = (body: string, sentences: readonly { readonly text: string }[]): ReadonlySet<string> => {
|
|
155
|
+
const texts = sentences.map((sentence) => sentence.text);
|
|
156
|
+
return new Set([...glossedAcronyms(body), ...spelledInSentence(texts), ...spelledBeforeSameNoun(texts), ...numberedSeries(body)]);
|
|
157
|
+
};
|
|
@@ -26,6 +26,8 @@ export type NameWords = {
|
|
|
26
26
|
readonly streetSuffixes: readonly string[];
|
|
27
27
|
/** 大文字で書く決まり文句(NOW, THEREFORE、AND/OR)。句のままでだけ外す。OR だけなら Oregon でもある。 */
|
|
28
28
|
readonly capitalPhrases: readonly string[];
|
|
29
|
+
/** 大文字で終わる製品の名前(Acrobat Reader DC)。名前のまま書いたときだけ外す。DC だけなら略語。 */
|
|
30
|
+
readonly productNames?: readonly string[];
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
const EDGE_BEFORE = String.raw`(?<![\p{L}\p{N}_&])`;
|
|
@@ -93,14 +95,25 @@ const CURRENCY_PREFIX = new RegExp(String.raw`${EDGE_BEFORE}\p{Lu}{1,3}(?=[$€
|
|
|
93
95
|
|
|
94
96
|
export const currencySymbolSpans = (text: string): Span[] => spansOf(text, CURRENCY_PREFIX);
|
|
95
97
|
|
|
98
|
+
/** 登録商標や商標の印のすぐ前の大文字(Acrobat DC®、XYZ™)。製品の名前の部品で、略語ではない。 */
|
|
99
|
+
const TRADEMARKED = new RegExp(String.raw`${EDGE_BEFORE}\p{Lu}{2,}(?=[®™])`, "gu");
|
|
100
|
+
|
|
101
|
+
export const trademarkSpans = (text: string): Span[] => spansOf(text, TRADEMARKED);
|
|
102
|
+
|
|
96
103
|
/**
|
|
97
|
-
* 引用の形の中の、法令の名前(45 CFR Parts 160、CFR §164.524、21 USC §301、22 CCR §§ 12701、94/820/EC)。後ろに条(§、Part、
|
|
98
|
-
* 番号)があるか、/
|
|
104
|
+
* 引用の形の中の、法令の名前(45 CFR Parts 160、CFR §164.524、21 USC §301、44 USC. 3502、22 CCR §§ 12701、94/820/EC)。後ろに条(§、Part、
|
|
105
|
+
* 番号)があるか、/ で繋いだ番号の後ろのときだけ。名前の後ろの点(USC.)は略しの印で、条の前に書いてもよい。§ の前には大文字で始まる
|
|
106
|
+
* 1 語を挟んでもよい(15 USCA Appendix § 12)。巻の番号の後ろで点で終わる名前(See 44 USC. 3502)も引用で、文を分ける読み手は
|
|
107
|
+
* 点の後ろの条を次の文に送る。法令集そのものを言う所(the CFR title、the 2 CFR export)は略語のまま数える。
|
|
99
108
|
*/
|
|
100
109
|
export const citationSpans = (text: string, series: readonly string[]): Span[] => {
|
|
101
110
|
if (series.length === 0) return [];
|
|
102
111
|
const name = oneOf(series);
|
|
103
|
-
|
|
112
|
+
const section = String.raw`(?:\p{Lu}\p{L}*\.?[ \t]+)?§`;
|
|
113
|
+
return spansOf(
|
|
114
|
+
text,
|
|
115
|
+
new RegExp(String.raw`(?<=\d/)${name}${EDGE_AFTER}|${EDGE_BEFORE}${name}(?=\.?[ \t]*(?:${section}|[Pp]arts?[ \t]+\d|\d))|(?<=\d[ \t]+)${name}(?=\.)`, "gu"),
|
|
116
|
+
);
|
|
104
117
|
};
|
|
105
118
|
|
|
106
119
|
/** 運送会社の名前。同じ文に 2 社以上を並べた所(Federal Express, UPS, DHL)だけ、どれも名前と読む。1 社だけの UPS は電源装置でもある。 */
|
|
@@ -125,6 +138,10 @@ export const streetSuffixSpans = (text: string, suffixes: readonly string[]): Sp
|
|
|
125
138
|
export const capitalPhraseSpans = (text: string, phrases: readonly string[]): Span[] =>
|
|
126
139
|
phrases.length === 0 ? [] : spansOf(text, new RegExp(`${EDGE_BEFORE}${oneOf(phrases)}${EDGE_AFTER}`, "gu"));
|
|
127
140
|
|
|
141
|
+
/** 大文字で終わる製品の名前(Adobe Acrobat Reader DC)。日本語の文では仮名が続く(Reader DCのダウンロード)ので、英字と数字だけを語の続きと見る。 */
|
|
142
|
+
export const productNameSpans = (text: string, names: readonly string[]): Span[] =>
|
|
143
|
+
names.length === 0 ? [] : spansOf(text, new RegExp(String.raw`(?<![A-Za-z0-9_&])${oneOf(names)}(?![A-Za-z0-9_&])`, "gu"));
|
|
144
|
+
|
|
128
145
|
/** 文の中で、名前の部品と決まり文句として略語から外す大文字を含む範囲。語彙表から一度だけ組み立てて、文ごとに呼ぶ。 */
|
|
129
146
|
export const nameSpansOf =
|
|
130
147
|
(words: NameWords) =>
|
|
@@ -132,9 +149,11 @@ export const nameSpansOf =
|
|
|
132
149
|
...companyNameSpans(text, words.legalForms, words.determiners),
|
|
133
150
|
...japaneseCompanyNameSpans(text, words.companyForms),
|
|
134
151
|
...currencySymbolSpans(text),
|
|
152
|
+
...trademarkSpans(text),
|
|
135
153
|
...citationSpans(text, words.citationSeries),
|
|
136
154
|
...carrierListSpans(text, words.carriers),
|
|
137
155
|
...namePrefixSpans(text, words.namePrefixes),
|
|
138
156
|
...streetSuffixSpans(text, words.streetSuffixes),
|
|
139
157
|
...capitalPhraseSpans(text, words.capitalPhrases),
|
|
158
|
+
...productNameSpans(text, words.productNames ?? []),
|
|
140
159
|
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Capitals a document uses as the name of a numbered series (RFC 5785 and RFC 7230, BCP 78 and BCP 14, DR 4339 and
|
|
2
|
+
// DR 4340). Pure.
|
|
3
|
+
|
|
4
|
+
/** Capitals, a space, and a whole number that is not part of a decimal, a range or a longer identifier. */
|
|
5
|
+
const NUMBERED = /(?<![\p{L}\p{N}_&.-])(?<series>[A-Z]{2,6}) (?<number>\d{1,6})(?![\p{L}\p{N}_&]|[.,:/-]\d)/gu;
|
|
6
|
+
|
|
7
|
+
/** A year after capitals is when something was held or issued (FOSDEM 2024, SKO 2025), not a number in a series. */
|
|
8
|
+
const YEAR = /^(?:19|20)\d\d$/u;
|
|
9
|
+
|
|
10
|
+
/** One number is a single thing cited (STD 66); two different numbers make the capitals a series the reader looks up by number. */
|
|
11
|
+
const MIN_NUMBERS = 2;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The capitals the document writes before at least two different numbers. A numbered series is known by its numbers: a
|
|
15
|
+
* reader of "BCP 78 … BCP 14" looks the numbers up, and the name needs no expansion. Capitals before one number, or before
|
|
16
|
+
* years only, are not read so.
|
|
17
|
+
*/
|
|
18
|
+
export const numberedSeries = (source: string): ReadonlySet<string> => {
|
|
19
|
+
const numbers = new Map<string, Set<string>>();
|
|
20
|
+
[...source.matchAll(NUMBERED)].forEach((match) => {
|
|
21
|
+
const series = match.groups?.["series"] ?? "";
|
|
22
|
+
const number = match.groups?.["number"] ?? "";
|
|
23
|
+
if (YEAR.test(number)) return;
|
|
24
|
+
numbers.set(series, (numbers.get(series) ?? new Set<string>()).add(number));
|
|
25
|
+
});
|
|
26
|
+
return new Set([...numbers].filter(([, seen]) => seen.size >= MIN_NUMBERS).map(([series]) => series));
|
|
27
|
+
};
|
|
@@ -4,7 +4,6 @@ import { MIN_DOCUMENT_LENGTH } from "./signals.ts";
|
|
|
4
4
|
import { entryIn, entryOpens } from "./lexicon-match.ts";
|
|
5
5
|
import { contrastSentences, type ContrastWords } from "./contrast-frame.ts";
|
|
6
6
|
import { placeholderSpans } from "./placeholder-text.ts";
|
|
7
|
-
import { colonLeadIns } from "./list-lead-in.ts";
|
|
8
7
|
import { followsInlineCode } from "./code-before.ts";
|
|
9
8
|
import { isSentenceTail } from "./opener-tail.ts";
|
|
10
9
|
|
|
@@ -44,16 +43,28 @@ const contrastWordsOf = (doc: ProseDocument, frames: Lexicon): ContrastWords =>
|
|
|
44
43
|
frames,
|
|
45
44
|
leads: doc.lexicons["contrast-lead"] ?? [],
|
|
46
45
|
turns: doc.lexicons["contrast-turn"] ?? [],
|
|
46
|
+
amounts: doc.lexicons["contrast-amount"] ?? [],
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
/**
|
|
49
|
+
/** 対比の枠は、一つなら論点の整理。二つ目から数える(割合の上限が、長い文書の二つを落とす)。 */
|
|
50
|
+
const MIN_CONTRASTS = 2;
|
|
51
|
+
const PERCENT = 100;
|
|
52
|
+
|
|
53
|
+
/** 文書の言語の文のうち、対比の枠で書いた文の割合(百分率、小数 1 桁)。文の長さが言語で違っても同じ物差しで比べられる。 */
|
|
54
|
+
export const contrastShare = (doc: ProseDocument, contrasts: number): number => {
|
|
55
|
+
const sentences = doc.sentences.filter((sentence) => sentence.embeddedLanguage === undefined).length;
|
|
56
|
+
return sentences === 0 ? 0 : Math.round((contrasts / sentences) * PERCENT * TENTHS) / TENTHS;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** 対比の枠(It's not X, it's Y、単なる X ではなく)。1 つなら論点の整理だが、文の割合が上限を超えると言い回しの癖になる。 */
|
|
50
60
|
export const contrastFraming: Detector = (doc, options): Finding[] => {
|
|
51
61
|
const words = contrastWordsOf(doc, options.lexicon ?? []);
|
|
52
|
-
const hits = contrastSentences(doc.sentences, words)
|
|
53
|
-
sentence
|
|
54
|
-
matched: (firstIn(sentence, words.frames) ?? firstIn(sentence, words.leads))?.pattern ?? ""
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
const hits = contrastSentences(doc.sentences, words)
|
|
63
|
+
.filter((sentence) => sentence.embeddedLanguage === undefined)
|
|
64
|
+
.map((sentence) => ({ sentence, matched: (firstIn(sentence, words.frames) ?? firstIn(sentence, words.leads))?.pattern ?? "" }));
|
|
65
|
+
if (hits.length < MIN_CONTRASTS || wordsOf(doc) < MIN_DOCUMENT_LENGTH[doc.lengthUnit]) return [];
|
|
66
|
+
const share = contrastShare(doc, hits.length);
|
|
67
|
+
return share <= options.limit ? [] : hits.map((hit) => findingOf(hit, { count: hits.length, share, limit: options.limit }));
|
|
57
68
|
};
|
|
58
69
|
|
|
59
70
|
/** 語彙表の語で始まる文。 */
|
|
@@ -82,16 +93,6 @@ export const openerPile: Detector = (doc, options): Finding[] => {
|
|
|
82
93
|
return hits.length === 0 || hits.length < options.limit ? [] : hits.map((hit) => findingOf(hit, { count: hits.length, limit: options.limit }));
|
|
83
94
|
};
|
|
84
95
|
|
|
85
|
-
/**
|
|
86
|
-
* コロンで箇条書きへ渡す文(以下の通りです:)。1 つなら案内だが、節ごとに続くと説明が箇条書きの前置きだけになる。
|
|
87
|
-
* 数えるのは文書の言語の文だけ。和文の中の英文(Examples include:)は、英語ではふつうの書き方なので数えない。
|
|
88
|
-
*/
|
|
89
|
-
export const colonLeadIn: Detector = (doc, options): Finding[] => {
|
|
90
|
-
const inDocumentLanguage = doc.sentences.filter((sentence) => sentence.embeddedLanguage === undefined);
|
|
91
|
-
const hits = colonLeadIns(inDocumentLanguage, doc.lists, doc.listSpans, doc.source).map((sentence) => ({ sentence, matched: sentence.text.trim() }));
|
|
92
|
-
return densityFindings(doc, hits, options.limit);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
96
|
const distinct = (lexicon: Lexicon): LexiconEntry[] => [...new Map(lexicon.map((entry) => [entry.pattern.toLowerCase(), entry])).values()];
|
|
96
97
|
|
|
97
98
|
const weightOf = (entry: LexiconEntry): number => entry.weight ?? 1;
|
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
import type { Detector, Finding } from "../plugin.ts";
|
|
2
|
-
import { uiLanguageOf } from "../ui.ts";
|
|
1
|
+
import type { Detector, Finding, ProseDocument } from "../plugin.ts";
|
|
2
|
+
import { uiLanguageOf, type Texts } from "../ui.ts";
|
|
3
3
|
import { STRUCTURE_TEXT } from "../outline/structure-text.ts";
|
|
4
4
|
import { structureOf } from "../structure-shape/of-document.ts";
|
|
5
|
+
import { headedSections } from "../structure-shape/features.ts";
|
|
6
|
+
import { headingWords } from "../structure-shape/heading-words.ts";
|
|
7
|
+
import { isTemplateOutline, templateSectionsOf } from "../structure-shape/template-outline.ts";
|
|
8
|
+
|
|
9
|
+
/** The template outline's name in the message, beside the structure measures past the human articles. */
|
|
10
|
+
const TEMPLATE_NAME: Texts<string> = { ja: "提案書・報告書の定型の見出し", en: "the textbook proposal or report headings" };
|
|
11
|
+
|
|
12
|
+
const templateSections = (doc: ProseDocument): string[] =>
|
|
13
|
+
templateSectionsOf(
|
|
14
|
+
headedSections(doc.sections).map((section) => headingWords(section.heading)),
|
|
15
|
+
doc.lexicons["template-heading"] ?? [],
|
|
16
|
+
);
|
|
5
17
|
|
|
6
18
|
/**
|
|
7
19
|
* The document's outline is past the human articles on several structure measures at once (chaff outline's structure
|
|
8
20
|
* block): many headings, three-way splits, bold labels, uniform sections. One alone is ordinary; the limit is how many.
|
|
21
|
+
* A textbook outline (Summary, Current Situation, Proposed Solution, Expected Benefits…) counts as one more.
|
|
9
22
|
*/
|
|
10
23
|
export const aiStructure: Detector = (doc, options): Finding[] => {
|
|
11
24
|
const scored = structureOf(doc);
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
25
|
+
const template = isTemplateOutline(templateSections(doc));
|
|
26
|
+
const count = scored.score + (template ? 1 : 0);
|
|
27
|
+
if (count < options.limit) return [];
|
|
28
|
+
const language = uiLanguageOf(doc.language);
|
|
29
|
+
const text = STRUCTURE_TEXT[language];
|
|
30
|
+
const measures = scored.placements.filter((placement) => placement.beyond).map((placement) => text.features[placement.feature.id].name);
|
|
31
|
+
const names = template ? [...measures, TEMPLATE_NAME[language]] : measures;
|
|
15
32
|
const heading = (doc.markup?.headings ?? []).find((entry) => entry.depth > 1) ?? doc.markup?.headings[0];
|
|
16
33
|
return [
|
|
17
34
|
{
|
|
@@ -20,7 +37,7 @@ export const aiStructure: Detector = (doc, options): Finding[] => {
|
|
|
20
37
|
line: 0,
|
|
21
38
|
column: 0,
|
|
22
39
|
quote: heading?.text ?? "",
|
|
23
|
-
values: { word: names.join(text.listSeparator), count
|
|
40
|
+
values: { word: names.join(text.listSeparator), count, limit: options.limit, offset: heading?.start ?? 0 },
|
|
24
41
|
},
|
|
25
42
|
];
|
|
26
43
|
};
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
const HALF_NUMBER = String.raw`(?<![\d./])\d+[./]\d+(?!\d|[./]\d)[A-Za-z]*`;
|
|
7
7
|
const FULL_NUMBER = String.raw`(?<![0-9./])[0-9]+[./][0-9]+(?![0-9]|[./][0-9])[A-Za-z]*`;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/** 三桁ごとに区切った数(5,500、1,200.5)。5,500 の 5 は一桁の数ではない。 */
|
|
10
|
+
const HALF_GROUPED = String.raw`(?<![\d,.])\d{1,3}(?:,\d{3})+(?:\.\d+)?(?![\d,]|\.\d)[A-Za-z]*`;
|
|
11
|
+
const FULL_GROUPED = String.raw`(?<![0-9,,.])[0-9]{1,3}(?:[,,][0-9]{3})+(?:.[0-9]+)?(?![0-9,,]|.[0-9])[A-Za-z]*`;
|
|
12
|
+
|
|
13
|
+
export const ALNUM_RUN = new RegExp(String.raw`${HALF_GROUPED}|${FULL_GROUPED}|${HALF_NUMBER}|${FULL_NUMBER}|[A-Za-z0-9A-Za-z0-9]+`, "gu");
|
|
14
|
+
/** 並び(ALNUM_RUN が切り出したもの)が一つの幅だけで書かれているか。区切りの点・斜線・コンマは数字の間にしか来ない。 */
|
|
15
|
+
export const FULLWIDTH = /^[A-Za-z0-9][A-Za-z0-9./,,]*$/u;
|
|
16
|
+
export const HALFWIDTH = /^[A-Za-z0-9][A-Za-z0-9./,]*$/u;
|
|
@@ -3,6 +3,7 @@ import { quotedIn } from "../quoted-span.ts";
|
|
|
3
3
|
import { followsInlineCode } from "./code-before.ts";
|
|
4
4
|
import { followsTwoExamples } from "./example-baseline.ts";
|
|
5
5
|
import { isNamedStep, plainStepKeys } from "./graded-step.ts";
|
|
6
|
+
import { comparesComparatives, comparesKinds, followsCause, madeComparative, opensWithCause, withoutNegation } from "./comparative-context.ts";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* 比べる相手の無い比較(より良い結果、さらに高速に、The new engine is faster.)。何より良いのか、何より速いのかが書かれていない。
|
|
@@ -14,6 +15,8 @@ import { isNamedStep, plainStepKeys } from "./graded-step.ts";
|
|
|
14
15
|
* intent は比べた語より後ろで、比較を願いや目的の中に置く語(より広く進めたい、より円滑にするためには)。比べる相手は今の状態。
|
|
15
16
|
* phrase は比べた形で終わる決まった言い方(to be more precise)。前の言葉を言い直すだけで、何も比べていない。
|
|
16
17
|
* pointer は文の頭で、いま見せた例を指す語(This is much better!)。二つのコードの例のすぐ後ろなら、相手は前の例。
|
|
18
|
+
* cause は比べた形より前で、比較が何の結果か、何に対してかを言う語(これにより、…できるため、…, but)。opener は文の頭で同じことをする語(As …, By …)。
|
|
19
|
+
* 英語の aim は比べた形の少し前で、今の状態から変えると言う動詞(to make results more predictable、do better)。
|
|
17
20
|
* 同じ文か前の二文に相手を言う語があれば、相手は書いてある。
|
|
18
21
|
*/
|
|
19
22
|
|
|
@@ -29,9 +32,12 @@ export type ComparativeLists = {
|
|
|
29
32
|
readonly intents: ReadonlySet<string>;
|
|
30
33
|
readonly phrases: readonly string[];
|
|
31
34
|
readonly pointers: ReadonlySet<string>;
|
|
35
|
+
readonly causes: ReadonlySet<string>;
|
|
36
|
+
readonly openers: ReadonlySet<string>;
|
|
32
37
|
};
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
/** head は英語の比べた形の前の述語(is faster の is)。 */
|
|
40
|
+
export type BareComparative = { readonly first: Token; readonly last: Token; readonly head?: Token };
|
|
35
41
|
|
|
36
42
|
/** 前に立てば、比べた形が述語として読める語の品詞(is faster、runs faster)。 */
|
|
37
43
|
const PREDICATE_HEAD = new Set(["VERB", "AUX"]);
|
|
@@ -85,10 +91,25 @@ const endsInAim = (tokens: readonly Token[], at: number, aims: ReadonlySet<strin
|
|
|
85
91
|
return end > at && aims.has(tokens[end]?.surface ?? "");
|
|
86
92
|
};
|
|
87
93
|
|
|
88
|
-
/**
|
|
94
|
+
/** 名詞の並びの中の語か。名詞の前に付いた形容詞(多文化の「多」)も並びの一部。 */
|
|
95
|
+
const inNounPhrase = (tokens: readonly Token[], at: number): boolean =>
|
|
96
|
+
tokens[at]?.pos === "NOUN" || (tokens[at]?.pos === "ADJ" && tokens[at + 1]?.pos === "NOUN");
|
|
97
|
+
|
|
98
|
+
/** 名詞の並びに「の」と目当ての語が続くか(より良い多文化共生の実現)。比べた語は、その目当ての中の語。 */
|
|
99
|
+
const aimAfterOf = (tokens: readonly Token[], at: number, aims: ReadonlySet<string>): boolean => {
|
|
100
|
+
const length = tokens.slice(at).findIndex((_, index) => !inNounPhrase(tokens, at + index));
|
|
101
|
+
const of = at + (length === -1 ? tokens.length - at : length);
|
|
102
|
+
return length > 0 && tokens[of]?.surface === "の" && runsFrom(tokens, of + 1).some(({ run }) => aims.has(run));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** 程度を言う語(at)の後ろが、今より良くする目当てか(より良い社会、より豊かな暮らし、より良いものにする、より良い共生の実現)。 */
|
|
89
106
|
const namesAim = (tokens: readonly Token[], at: number, aims: ReadonlySet<string>): boolean => {
|
|
90
107
|
const next = tokens[at]?.pos === "NOUN" && ADJECTIVAL_TAIL.has(tokens[at + 1]?.surface ?? "") ? at + 2 : at + 1;
|
|
91
|
-
return
|
|
108
|
+
return (
|
|
109
|
+
runsFrom(tokens, next).some(({ run, after }) => aims.has(run) && !headsCompound(tokens, after)) ||
|
|
110
|
+
endsInAim(tokens, next, aims) ||
|
|
111
|
+
aimAfterOf(tokens, next, aims)
|
|
112
|
+
);
|
|
92
113
|
};
|
|
93
114
|
|
|
94
115
|
/** 日本語: 副詞の「より」「さらに」の直後の、程度を言える語。比較の決まった言い方(より多くの)と、今より良くする目当て(より良い社会)は除く。 */
|
|
@@ -126,13 +147,15 @@ const predicateAt = (tokens: readonly Token[], at: number, lists: ComparativeLis
|
|
|
126
147
|
const first = tokens[start] ?? word;
|
|
127
148
|
const adverbs = tokens.slice(Math.max(0, start - MAX_ADVERBS), start).reverse();
|
|
128
149
|
const skipped = adverbs.findIndex((token) => token.pos !== "ADV");
|
|
129
|
-
const
|
|
130
|
-
|
|
150
|
+
const headAt = start - 1 - (skipped === -1 ? adverbs.length : skipped);
|
|
151
|
+
const head = tokens[headAt];
|
|
152
|
+
if (head === undefined || !(PREDICATE_HEAD.has(head.pos) || isThirdPersonVerb(head))) return undefined;
|
|
153
|
+
return comparesComparatives(tokens, headAt, new Set([...lists.comparatives, ...lists.more])) ? undefined : { first, last: word, head };
|
|
131
154
|
};
|
|
132
155
|
|
|
133
156
|
/** 比べた形より前に、条件か仮定を言う語があるか。並べる「と」(A と B)は条件でない。 */
|
|
134
157
|
const isConditional = (tokens: readonly Token[], found: BareComparative, conditions: ReadonlySet<string>): boolean =>
|
|
135
|
-
tokens.some((token) => token.span.start < found.first.span.start && token.pos !== "CCONJ" && conditions.has(lower(token)));
|
|
158
|
+
tokens.some((token) => token.span.start < found.first.span.start && token.pos !== "CCONJ" && conditions.has(withoutNegation(lower(token))));
|
|
136
159
|
|
|
137
160
|
/** 比べた形のすぐ前が、いま述べたものを越えると言う語か(performed even better)。 */
|
|
138
161
|
const goesBeyond = (tokens: readonly Token[], found: BareComparative, beyond: ReadonlySet<string>): boolean => {
|
|
@@ -175,7 +198,9 @@ export const bareComparativesIn = (tokens: readonly Token[], lists: ComparativeL
|
|
|
175
198
|
!isConditional(tokens, found, lists.conditions) &&
|
|
176
199
|
!goesBeyond(tokens, found, lists.beyond) &&
|
|
177
200
|
!isIntended(tokens, found, lists.intents) &&
|
|
178
|
-
!endsSetPhrase(tokens, found, lists.phrases)
|
|
201
|
+
!endsSetPhrase(tokens, found, lists.phrases) &&
|
|
202
|
+
!followsCause(tokens, found.first, lists.causes) &&
|
|
203
|
+
!(found.head !== undefined && madeComparative(tokens, found.first, lists.aims)),
|
|
179
204
|
);
|
|
180
205
|
|
|
181
206
|
/**
|
|
@@ -186,14 +211,13 @@ const isBaselineWord = (token: Token, baselines: readonly string[]): boolean =>
|
|
|
186
211
|
return baselines.some((baseline) => surface === baseline || lemma === baseline || ([...baseline].length === 1 && surface.startsWith(baseline)));
|
|
187
212
|
};
|
|
188
213
|
|
|
189
|
-
/**
|
|
214
|
+
/** 相手を言う語が、続く語に分かれて書かれているか(これ・まで、で・は・なく、that follows)。語を詰めても、空白でつないでも照らす。 */
|
|
190
215
|
const MAX_BASELINE_TOKENS = 3;
|
|
216
|
+
const runsJoinedBy = (surfaces: readonly string[], glue: string): string[] =>
|
|
217
|
+
surfaces.reduce<string[]>((runs, surface) => [...runs, runs.length === 0 ? surface : `${runs.at(-1) ?? ""}${glue}${surface}`], []).slice(1);
|
|
191
218
|
const isSplitBaseline = (tokens: readonly Token[], at: number, baselines: readonly string[]): boolean => {
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
.map((token) => token.surface.toLowerCase())
|
|
195
|
-
.reduce<string[]>((runs, surface) => [...runs, `${runs.at(-1) ?? ""}${surface}`], []);
|
|
196
|
-
return joined.slice(1).some((run) => baselines.includes(run));
|
|
219
|
+
const surfaces = tokens.slice(at, at + MAX_BASELINE_TOKENS).map((token) => token.surface.toLowerCase());
|
|
220
|
+
return [...runsJoinedBy(surfaces, ""), ...runsJoinedBy(surfaces, " ")].some((run) => baselines.includes(run));
|
|
197
221
|
};
|
|
198
222
|
|
|
199
223
|
/** 文の中に、比べる相手を言う語か、相手を受ける助詞の「より」(従来より)があるか。 */
|
|
@@ -219,6 +243,8 @@ export const listsOf = (lexicon: Lexicon): ComparativeLists => ({
|
|
|
219
243
|
intents: new Set(groupOf(lexicon, "intent")),
|
|
220
244
|
phrases: groupOf(lexicon, "phrase"),
|
|
221
245
|
pointers: new Set(groupOf(lexicon, "pointer")),
|
|
246
|
+
causes: new Set(groupOf(lexicon, "cause")),
|
|
247
|
+
openers: new Set(groupOf(lexicon, "opener")),
|
|
222
248
|
});
|
|
223
249
|
|
|
224
250
|
/** 鉤括弧の中の比較(「給与所得の確定申告がさらに簡単に!」ページ)は題や語を挙げたもので、書き手の比較ではない。 */
|
|
@@ -244,9 +270,11 @@ export const bareComparative: Detector = (doc): Finding[] => {
|
|
|
244
270
|
const nearby = doc.sentences.slice(Math.max(0, at - BASELINE_REACH), at + 1);
|
|
245
271
|
if (sentence.embeddedLanguage !== undefined || nearby.some((near) => namesBaseline(near, lists.baselines))) return [];
|
|
246
272
|
if (pointsAtExample(sentence, lists.pointers) && followsTwoExamples(doc.source, spans, at)) return [];
|
|
273
|
+
if (opensWithCause(sentence.tokens ?? [], lists.openers)) return [];
|
|
247
274
|
const quoted = quotedIn(sentence);
|
|
248
275
|
return bareComparativesIn(sentence.tokens ?? [], lists)
|
|
249
276
|
.filter((found) => !quoted.some((span) => insideSpan(found, span)) && !isThanAfterCode(doc, found))
|
|
277
|
+
.filter((found) => !comparesKinds(doc.sentences[at - 1]?.tokens ?? [], sentence.tokens ?? [], found.head))
|
|
250
278
|
.filter((found) => !lists.markers.has(found.first.surface) || !isNamedStep(sentence.tokens ?? [], found.last, steps))
|
|
251
279
|
.map((found) => ({
|
|
252
280
|
rule: "",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
|
|
3
|
+
/** Quote marks at the head of a line (`> > `), with the indent before them. */
|
|
4
|
+
const QUOTE_MARKS = /^[ \t]*(?:>[ \t]*)*/u;
|
|
5
|
+
|
|
6
|
+
/** The bullet or number that opens a list item. */
|
|
7
|
+
const ITEM_MARKER = /^(?:[-*+]|\d{1,9}[.)])[ \t]+/u;
|
|
8
|
+
|
|
9
|
+
/** A task box after the marker. */
|
|
10
|
+
const TASK_BOX = /^\[[ xX]\][ \t]+/u;
|
|
11
|
+
|
|
12
|
+
/** The end of a sentence, or a colon announcing what follows, past closing quotes, brackets, bold and a hard-break backslash. */
|
|
13
|
+
const CLOSED = /[.!?:。!?:]["'”’)\]*_]*\\?$/u;
|
|
14
|
+
|
|
15
|
+
/** A bold run whose first character, past an opening quote or bracket, is a capital: a name, as a button or a title is. */
|
|
16
|
+
const CAPITALISED = /^(?:\*\*|__)["'“‘([]*\p{Lu}/u;
|
|
17
|
+
|
|
18
|
+
/** How far back a bold looks for the end of the sentence before it. */
|
|
19
|
+
const LOOK_BACK = 200;
|
|
20
|
+
|
|
21
|
+
const lineStartOf = (source: string, offset: number): number => source.lastIndexOf("\n", offset - 1) + 1;
|
|
22
|
+
|
|
23
|
+
const previousLineOf = (source: string, lineStart: number): string | undefined =>
|
|
24
|
+
lineStart === 0 ? undefined : source.slice(lineStartOf(source, lineStart - 1), lineStart - 1);
|
|
25
|
+
|
|
26
|
+
/** What stands before a bold on its line, read as quote marks, an item marker and a task box; `rest` is what is left. */
|
|
27
|
+
const lineOpeningOf = (opening: string): { readonly item: boolean; readonly rest: string } => {
|
|
28
|
+
const unquoted = opening.replace(QUOTE_MARKS, "");
|
|
29
|
+
const unmarked = unquoted.replace(ITEM_MARKER, "");
|
|
30
|
+
return { item: unmarked !== unquoted, rest: unmarked.replace(TASK_BOX, "") };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** A line opening with bold: in a run of such lines (From:, To:, Date:) each line is a field. */
|
|
34
|
+
const opensWithBold = (line: string): boolean => /^(?:\*\*|__)/u.test(line.replace(QUOTE_MARKS, ""));
|
|
35
|
+
|
|
36
|
+
/** Whether the line before closes a block or a sentence, or is itself a bold field: the line after it starts afresh. */
|
|
37
|
+
const followsAClosedLine = (previous: string | undefined): boolean =>
|
|
38
|
+
previous === undefined || previous.trim() === "" || CLOSED.test(previous.trimEnd()) || opensWithBold(previous);
|
|
39
|
+
|
|
40
|
+
/** A bold that opens its line and its block: a list item's lead, a field (From:), a run-in heading (Pros:), a dateline. */
|
|
41
|
+
export const opensItsBlock = (source: string, span: Span): boolean => {
|
|
42
|
+
const lineStart = lineStartOf(source, span.start);
|
|
43
|
+
const opening = lineOpeningOf(source.slice(lineStart, span.start));
|
|
44
|
+
return opening.rest === "" && (opening.item || followsAClosedLine(previousLineOf(source, lineStart)));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Whether a bold starts a sentence: nothing before it, or the end of a sentence. */
|
|
48
|
+
const startsASentence = (before: string): boolean => {
|
|
49
|
+
const trimmed = before.trimEnd();
|
|
50
|
+
return trimmed === "" || CLOSED.test(trimmed);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** A capitalised bold inside a sentence: the name of a button, a setting or a title (click **Add Printer**), not emphasis. */
|
|
54
|
+
export const isNameMidSentence = (source: string, span: Span): boolean =>
|
|
55
|
+
CAPITALISED.test(source.slice(span.start, span.end)) && !startsASentence(source.slice(Math.max(0, span.start - LOOK_BACK), span.start));
|
|
56
|
+
|
|
57
|
+
/** Whether a bold span emphasises words in running text, rather than labelling, heading or naming something. */
|
|
58
|
+
export const isEmphasisBold = (source: string, span: Span): boolean => !opensItsBlock(source, span) && !isNameMidSentence(source, span);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Detector, Finding, ProseDocument, Sentence } from "../plugin.ts";
|
|
2
|
-
import {
|
|
1
|
+
import type { Detector, Finding, ProseDocument, Sentence, Span } from "../plugin.ts";
|
|
2
|
+
import { isEmphasisBold } from "./bold-emphasis-form.ts";
|
|
3
3
|
import { proseText } from "../measure.ts";
|
|
4
4
|
import { wordsOf } from "./structure.ts";
|
|
5
5
|
import { MIN_DOCUMENT_LENGTH } from "./signals.ts";
|
|
@@ -9,29 +9,28 @@ const TENTHS = 10;
|
|
|
9
9
|
/** Two bold spans are what a careful writer keeps for a deadline or a warning, and in a short text they alone pass any rate. */
|
|
10
10
|
const MIN_SPANS = 3;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The bold spans of the prose that emphasise (Section.strongs already leaves out headings and tables). A bold opening its
|
|
14
|
+
* line and block is a label, a field or a run-in heading (bold-label-list counts the list labels); a capitalised bold
|
|
15
|
+
* mid-sentence is a name.
|
|
16
|
+
*/
|
|
17
|
+
const emphasisSpans = (doc: ProseDocument): Span[] =>
|
|
18
|
+
doc.sections.flatMap((section) => section.strongs ?? []).filter((span) => isEmphasisBold(doc.source, span));
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
const labelItemCount = (doc: ProseDocument): number =>
|
|
16
|
-
doc.lists
|
|
17
|
-
.flatMap((list) => list.itemSpans)
|
|
18
|
-
.filter((span) => !isQuotedAt(doc.source, span.start) && opensWithBoldLabel(doc.source.slice(span.start, span.end))).length;
|
|
20
|
+
export const emphasisSpanCount = (doc: ProseDocument): number => emphasisSpans(doc).length;
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
export const emphasisSpanCount = (doc: ProseDocument): number =>
|
|
22
|
-
Math.max(0, doc.sections.reduce((sum, section) => sum + section.strongCount, 0) - labelItemCount(doc));
|
|
23
|
-
|
|
24
|
-
const firstBoldSentence = (doc: ProseDocument): Sentence | undefined =>
|
|
25
|
-
doc.sentences.find((sentence) => BOLD_OPENING.test(doc.source.slice(sentence.span.start, sentence.span.end)));
|
|
22
|
+
const sentenceAt = (doc: ProseDocument, offset: number): Sentence | undefined => doc.sentences.find((sentence) => offset < sentence.span.end);
|
|
26
23
|
|
|
27
24
|
/** A rate over the whole document, not per section: the reader notices bold scattered through every part of it. */
|
|
28
25
|
export const boldEmphasis: Detector = (doc, options): Finding[] => {
|
|
29
26
|
const length = wordsOf(doc);
|
|
30
|
-
const
|
|
27
|
+
const spans = emphasisSpans(doc);
|
|
28
|
+
const count = spans.length;
|
|
31
29
|
if (count < MIN_SPANS || length < MIN_DOCUMENT_LENGTH[doc.lengthUnit]) return [];
|
|
32
30
|
const density = Math.round((count / length) * PER * TENTHS) / TENTHS;
|
|
33
31
|
if (density <= options.limit) return [];
|
|
34
|
-
const
|
|
32
|
+
const offset = spans[0]?.start ?? 0;
|
|
33
|
+
const at = sentenceAt(doc, offset);
|
|
35
34
|
return [
|
|
36
35
|
{
|
|
37
36
|
rule: "bold-emphasis",
|
|
@@ -39,7 +38,7 @@ export const boldEmphasis: Detector = (doc, options): Finding[] => {
|
|
|
39
38
|
line: 0,
|
|
40
39
|
column: 0,
|
|
41
40
|
quote: at === undefined ? "" : proseText(at),
|
|
42
|
-
values: { count, density, limit: options.limit, offset: at?.span.start ??
|
|
41
|
+
values: { count, density, limit: options.limit, offset: at?.span.start ?? offset },
|
|
43
42
|
},
|
|
44
43
|
];
|
|
45
44
|
};
|
|
@@ -120,8 +120,11 @@ export const isWithinSorted = (spans: readonly Span[], inner: Span): boolean =>
|
|
|
120
120
|
|
|
121
121
|
/** Columns on a line: two spaces or more, or a tab, stand between them. */
|
|
122
122
|
const COLUMN_CELL = /[^\t ]+(?: [^\t ]+)*/gu;
|
|
123
|
-
/**
|
|
124
|
-
|
|
123
|
+
/**
|
|
124
|
+
* A name in capitals, a comma, and a place or office in ordinary case, which may be followed by the member's role:
|
|
125
|
+
* JANE Q. DOE, Ohio / JOHN DOE, JR., New Mexico / MARY ANN SMITH, West Virginia, Ranking Member.
|
|
126
|
+
*/
|
|
127
|
+
const ROSTER_CELL = /^([A-Z][A-Z.'’-]*(?: [A-Z][A-Z.'’-]*)*(?:, [JS]R\.)?)(?:, \p{Lu}\p{Ll}+(?: \p{Lu}\p{Ll}+)*)+$/u;
|
|
125
128
|
|
|
126
129
|
/**
|
|
127
130
|
* The names of a roster: a column that holds a name in capitals and the member's place in ordinary case (a committee's
|
|
@@ -135,3 +138,22 @@ export const rosterNameSpans = (source: string): Span[] =>
|
|
|
135
138
|
return name === undefined ? [] : [{ start, end: start + name.length }];
|
|
136
139
|
}),
|
|
137
140
|
);
|
|
141
|
+
|
|
142
|
+
/** Square brackets on one line, and what follows them. */
|
|
143
|
+
const BRACKETS = /\[[^[\]\n]*\]/gu;
|
|
144
|
+
const LINK_AFTER = /^[(:[]/u;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Whether bracketed text holds capitals and no lower-case letter, as a placeholder does: [GRAPHIC(S) NOT AVAILABLE IN TIFF
|
|
148
|
+
* FORMAT]. The text of a Markdown link ([READ THIS](url)) is the writer's own words, so it is not one.
|
|
149
|
+
*/
|
|
150
|
+
const isCapitalPlaceholder = (bracketed: string, after: string): boolean => UPPER.test(bracketed) && !/\p{Ll}/u.test(bracketed) && !LINK_AFTER.test(after);
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Placeholders a publisher or editor puts in square brackets, wholly in capitals, for what the text leaves out (an image the
|
|
154
|
+
* text edition drops, a name withheld for review). Brackets mark an insertion that is not the writer's, so it is not shouting.
|
|
155
|
+
*/
|
|
156
|
+
export const bracketPlaceholderSpans = (source: string): Span[] =>
|
|
157
|
+
[...source.matchAll(BRACKETS)]
|
|
158
|
+
.filter((hit) => isCapitalPlaceholder(hit[0], source.slice(hit.index + hit[0].length, hit.index + hit[0].length + 1)))
|
|
159
|
+
.map((hit) => ({ start: hit.index, end: hit.index + hit[0].length }));
|