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
|
@@ -46,12 +46,12 @@ export const HUMAN_SHARES: HumanShares = {
|
|
|
46
46
|
"bold-emphasis": {
|
|
47
47
|
academic: { documents: 10, fired: 0 },
|
|
48
48
|
blog: { documents: 23, fired: 0 },
|
|
49
|
-
business: { documents: 78, fired:
|
|
50
|
-
docs: { documents: 21, fired:
|
|
51
|
-
legal: { documents: 28, fired:
|
|
49
|
+
business: { documents: 78, fired: 0 },
|
|
50
|
+
docs: { documents: 21, fired: 0 },
|
|
51
|
+
legal: { documents: 28, fired: 0 },
|
|
52
52
|
literature: { documents: 4, fired: 0 },
|
|
53
53
|
speech: { documents: 7, fired: 0 },
|
|
54
|
-
technical: { documents: 26, fired:
|
|
54
|
+
technical: { documents: 26, fired: 0 },
|
|
55
55
|
},
|
|
56
56
|
"bold-label-list": {
|
|
57
57
|
academic: { documents: 10, fired: 0 },
|
|
@@ -81,15 +81,35 @@ export const HUMAN_SHARES: HumanShares = {
|
|
|
81
81
|
literature: { documents: 13, fired: 0 },
|
|
82
82
|
speech: { documents: 7, fired: 0 },
|
|
83
83
|
},
|
|
84
|
+
"closing-exhortation": {
|
|
85
|
+
academic: { documents: 10, fired: 0 },
|
|
86
|
+
blog: { documents: 23, fired: 0 },
|
|
87
|
+
business: { documents: 80, fired: 0 },
|
|
88
|
+
docs: { documents: 21, fired: 0 },
|
|
89
|
+
legal: { documents: 35, fired: 0 },
|
|
90
|
+
literature: { documents: 13, fired: 0 },
|
|
91
|
+
speech: { documents: 7, fired: 0 },
|
|
92
|
+
technical: { documents: 26, fired: 0 },
|
|
93
|
+
},
|
|
94
|
+
"cold-open": {
|
|
95
|
+
academic: { documents: 10, fired: 0 },
|
|
96
|
+
blog: { documents: 23, fired: 0 },
|
|
97
|
+
business: { documents: 80, fired: 0 },
|
|
98
|
+
docs: { documents: 21, fired: 0 },
|
|
99
|
+
legal: { documents: 35, fired: 0 },
|
|
100
|
+
literature: { documents: 13, fired: 0 },
|
|
101
|
+
speech: { documents: 7, fired: 0 },
|
|
102
|
+
technical: { documents: 26, fired: 0 },
|
|
103
|
+
},
|
|
84
104
|
"colon-lead-in": {
|
|
85
|
-
academic: { documents:
|
|
86
|
-
blog: { documents:
|
|
87
|
-
business: { documents:
|
|
88
|
-
docs: { documents:
|
|
89
|
-
legal: { documents:
|
|
90
|
-
literature: { documents:
|
|
91
|
-
speech: { documents:
|
|
92
|
-
technical: { documents:
|
|
105
|
+
academic: { documents: 10, fired: 0 },
|
|
106
|
+
blog: { documents: 23, fired: 0 },
|
|
107
|
+
business: { documents: 80, fired: 3 },
|
|
108
|
+
docs: { documents: 21, fired: 0 },
|
|
109
|
+
legal: { documents: 35, fired: 0 },
|
|
110
|
+
literature: { documents: 13, fired: 0 },
|
|
111
|
+
speech: { documents: 7, fired: 0 },
|
|
112
|
+
technical: { documents: 26, fired: 3 },
|
|
93
113
|
},
|
|
94
114
|
"contrast-framing": {
|
|
95
115
|
academic: { documents: 10, fired: 0 },
|
|
@@ -101,6 +121,16 @@ export const HUMAN_SHARES: HumanShares = {
|
|
|
101
121
|
speech: { documents: 7, fired: 0 },
|
|
102
122
|
technical: { documents: 26, fired: 0 },
|
|
103
123
|
},
|
|
124
|
+
"email-stock-courtesy": {
|
|
125
|
+
academic: { documents: 5, fired: 0 },
|
|
126
|
+
blog: { documents: 9, fired: 0 },
|
|
127
|
+
business: { documents: 41, fired: 1 },
|
|
128
|
+
docs: { documents: 11, fired: 0 },
|
|
129
|
+
legal: { documents: 14, fired: 0 },
|
|
130
|
+
literature: { documents: 9, fired: 0 },
|
|
131
|
+
speech: { documents: 3, fired: 0 },
|
|
132
|
+
technical: { documents: 13, fired: 0 },
|
|
133
|
+
},
|
|
104
134
|
"emoji-density": {
|
|
105
135
|
academic: { documents: 10, fired: 0 },
|
|
106
136
|
blog: { documents: 23, fired: 0 },
|
|
@@ -178,6 +208,7 @@ export const HUMAN_SHARES: HumanShares = {
|
|
|
178
208
|
"rule-of-three": {
|
|
179
209
|
academic: { documents: 10, fired: 0 },
|
|
180
210
|
blog: { documents: 23, fired: 0 },
|
|
211
|
+
business: { documents: 80, fired: 0 },
|
|
181
212
|
docs: { documents: 21, fired: 0 },
|
|
182
213
|
legal: { documents: 35, fired: 0 },
|
|
183
214
|
literature: { documents: 13, fired: 0 },
|
|
@@ -232,4 +263,14 @@ export const HUMAN_SHARES: HumanShares = {
|
|
|
232
263
|
speech: { documents: 7, fired: 0 },
|
|
233
264
|
technical: { documents: 49, fired: 0 },
|
|
234
265
|
},
|
|
266
|
+
"unprompted-denial": {
|
|
267
|
+
academic: { documents: 10, fired: 0 },
|
|
268
|
+
blog: { documents: 23, fired: 0 },
|
|
269
|
+
business: { documents: 80, fired: 0 },
|
|
270
|
+
docs: { documents: 21, fired: 0 },
|
|
271
|
+
legal: { documents: 35, fired: 1 },
|
|
272
|
+
literature: { documents: 13, fired: 0 },
|
|
273
|
+
speech: { documents: 7, fired: 0 },
|
|
274
|
+
technical: { documents: 26, fired: 0 },
|
|
275
|
+
},
|
|
235
276
|
};
|
|
@@ -14,10 +14,13 @@ const STRUCTURE_RULE = "ai-structure";
|
|
|
14
14
|
/** The genre group a genre's human shares are measured under: business for business/report. */
|
|
15
15
|
export const genreGroupOf = (genre: string): string => genre.split("/")[0] ?? genre;
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/** Business runs ai-structure for its textbook outline, but the structure baseline is articles, not business documents. */
|
|
18
|
+
const NOT_ARTICLES = "business";
|
|
19
|
+
|
|
20
|
+
/** The structure baseline is human articles: it is compared only in the article genres ai-structure runs in. */
|
|
18
21
|
const structureApplies = (rules: readonly RuleDefinition[], genre: string): boolean => {
|
|
19
22
|
const rule = rules.find((entry) => entry.id === STRUCTURE_RULE);
|
|
20
|
-
return rule !== undefined && standingIn(rule, genre, presetLevels(genre)).kind === "on";
|
|
23
|
+
return rule !== undefined && genreGroupOf(genre) !== NOT_ARTICLES && standingIn(rule, genre, presetLevels(genre)).kind === "on";
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
type SignalResult = { readonly runs: SignalRun[]; readonly compositeFired: string[] };
|
package/src/body-section.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { Section } from "./plugin.ts";
|
|
2
2
|
|
|
3
|
+
/** 何行にも渡る深さ 1 の見出しは、罫線(=====)の上の段落を Setext の見出しと読んだもので、節の始まりではない。 */
|
|
4
|
+
const isSiblingSection = (section: Section, index: number, titleIndex: number): boolean =>
|
|
5
|
+
section.depth === 1 && index > titleIndex && !section.heading.includes("\n");
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
|
-
* 本題の始まり: 最初の中見出し(深さ 2
|
|
8
|
+
* 本題の始まり: 最初の中見出し(深さ 2 以上)の節か、表題と同じ深さ 1 の二つ目の見出しの、先に来る方。
|
|
9
|
+
* 表題(最初の深さ 1)の直後から数えると、表題しか無い文書で全文が前置きになる。節をすべて深さ 1 で書く文書
|
|
10
|
+
* (官報の AGENCY: / ACTION: / SUMMARY:)では、二つ目の深さ 1 が最初の節で、その後ろは前置きではない。
|
|
5
11
|
* 無ければ、本題の前を測る rule は動けない(rule の requires の headings)。
|
|
6
12
|
*/
|
|
7
|
-
export const bodySectionOf = (sections: readonly Section[]): Section | undefined =>
|
|
13
|
+
export const bodySectionOf = (sections: readonly Section[]): Section | undefined => {
|
|
14
|
+
const titleIndex = sections.findIndex((section) => section.depth === 1);
|
|
15
|
+
return sections.find((section, index) => section.depth >= 2 || isSiblingSection(section, index, titleIndex));
|
|
16
|
+
};
|
|
@@ -21,3 +21,19 @@ const isPickedOut = (word: string, acronyms: readonly string[]): boolean => {
|
|
|
21
21
|
* as written: leaving it out for one part would hide a variant in another (GitHub-SENDs, Github-SENDs).
|
|
22
22
|
*/
|
|
23
23
|
export const isCapitalsNotSpelling = (word: string, acronyms: readonly string[]): boolean => CAPITALS_WITH_ENDING.test(word) || isPickedOut(word, acronyms);
|
|
24
|
+
|
|
25
|
+
/** A surname in capitals after its prefix in small letters (McCAUL, DesJARLAIS, MacARTHUR): one capital, a short prefix, capitals. */
|
|
26
|
+
const CAPITALS_AFTER_PREFIX = /^\p{Lu}\p{Ll}{1,3}\p{Lu}{2,}$/u;
|
|
27
|
+
const NAME_PART = /\p{L}+\.?/gu;
|
|
28
|
+
const INITIAL = /^\p{Lu}\.$/u;
|
|
29
|
+
const CAPITALS_WORD = /^\p{Lu}{2,}$/u;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether a word at `start` in text is a surname set in capitals after a given name in capitals (MICHAEL T. McCAUL, SCOTT
|
|
33
|
+
* DesJARLAIS): a roster's capitals, not another spelling of McCaul. An initial between the two (T.) is passed over.
|
|
34
|
+
*/
|
|
35
|
+
export const isNameInCapitals = (text: string, start: number, word: string): boolean => {
|
|
36
|
+
if (!CAPITALS_AFTER_PREFIX.test(word)) return false;
|
|
37
|
+
const before = [...text.slice(0, start).matchAll(NAME_PART)].map((match) => match[0]).filter((part) => !INITIAL.test(part));
|
|
38
|
+
return CAPITALS_WORD.test(before.at(-1) ?? "");
|
|
39
|
+
};
|
package/src/checks.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join } from "node:path";
|
|
2
3
|
import { readYamlFile } from "./config/yaml-file.ts";
|
|
3
4
|
import type { Level, Severity } from "./plugin.ts";
|
|
4
5
|
|
|
@@ -17,6 +18,27 @@ export type UserCheck = {
|
|
|
17
18
|
readonly level: Level;
|
|
18
19
|
readonly how_to_fix: string;
|
|
19
20
|
readonly source: string;
|
|
21
|
+
/** The document languages the check is asked for; undefined asks it for every language. */
|
|
22
|
+
readonly languages?: readonly string[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Whether a check is asked for a document in this language. */
|
|
26
|
+
export const checkAppliesTo = (check: Pick<UserCheck, "languages">, language: string): boolean =>
|
|
27
|
+
check.languages === undefined || check.languages.includes(language);
|
|
28
|
+
|
|
29
|
+
/** The folder of the check sets chaff ships (`--checks ai-tells`). */
|
|
30
|
+
export const BUNDLED_CHECKS_DIR = "checks";
|
|
31
|
+
|
|
32
|
+
const YAML_FILE = /\.ya?ml$/u;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The checks file to read: checks.yaml in the folder without --checks; the path given when it names a file
|
|
36
|
+
* (a separator or a .yaml ending); otherwise the set of that name chaff ships. Pure: the caller joins the folders.
|
|
37
|
+
*/
|
|
38
|
+
export const checksPathOf = (given: string | undefined, cwd: string, bundledDir: string): string => {
|
|
39
|
+
if (given === undefined) return join(cwd, CHECKS_FILE);
|
|
40
|
+
if (given.includes("/") || given.includes("\\") || YAML_FILE.test(given)) return isAbsolute(given) ? given : join(cwd, given);
|
|
41
|
+
return join(bundledDir, `${given}.yaml`);
|
|
20
42
|
};
|
|
21
43
|
|
|
22
44
|
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -47,8 +69,10 @@ const toCheck = (raw: unknown, index: number, source: string): UserCheck | undef
|
|
|
47
69
|
const name = str(raw["name"]);
|
|
48
70
|
const check = str(raw["check"]);
|
|
49
71
|
if (name === undefined || check === undefined) return undefined;
|
|
72
|
+
const id = str(raw["id"]);
|
|
50
73
|
return {
|
|
51
|
-
|
|
74
|
+
// A shipped set names its checks, so a check keeps one id in both of its languages.
|
|
75
|
+
id: idOf(id ?? name, index),
|
|
52
76
|
name,
|
|
53
77
|
use_for: useForOf(raw["use_for"]),
|
|
54
78
|
check,
|
|
@@ -56,9 +80,16 @@ const toCheck = (raw: unknown, index: number, source: string): UserCheck | undef
|
|
|
56
80
|
level: asLevel(raw["level"]),
|
|
57
81
|
how_to_fix: str(raw["how_to_fix"]) ?? "",
|
|
58
82
|
source,
|
|
83
|
+
...languagesOf(raw["languages"]),
|
|
59
84
|
};
|
|
60
85
|
};
|
|
61
86
|
|
|
87
|
+
/** languages は 1 つでも配列でも書ける。書かなければどの言語にも聞く。 */
|
|
88
|
+
const languagesOf = (value: unknown): Pick<UserCheck, "languages"> => {
|
|
89
|
+
if (typeof value === "string") return { languages: [value] };
|
|
90
|
+
return Array.isArray(value) ? { languages: value.map((entry) => String(entry)) } : {};
|
|
91
|
+
};
|
|
92
|
+
|
|
62
93
|
export const loadChecks = (path: string): UserCheck[] => {
|
|
63
94
|
if (!existsSync(path)) return [];
|
|
64
95
|
const raw: unknown = readYamlFile(path);
|
package/src/cli-args.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Options of the commands that take files to check, whose value is the next argument. That value is not a file.
|
|
3
3
|
* `--why` (relax), `--format` and `--language` (tree) belong to commands that read their own arguments.
|
|
4
4
|
*/
|
|
5
|
-
const VALUE_FLAGS: ReadonlySet<string> = new Set(["--sarif", "--genre", "--rule", "--line", "--include"]);
|
|
5
|
+
const VALUE_FLAGS: ReadonlySet<string> = new Set(["--sarif", "--genre", "--rule", "--line", "--include", "--checks"]);
|
|
6
6
|
|
|
7
7
|
/** The arguments that name what to check: everything that is neither an option nor an option's value. */
|
|
8
8
|
export const targetsOf = (args: readonly string[]): string[] =>
|
package/src/cli-text.ts
CHANGED
|
@@ -30,6 +30,7 @@ const USAGE_JA = `chaff — 文章の読みにくいところを見つけます
|
|
|
30
30
|
chaff . この場所の Markdown を全部
|
|
31
31
|
chaff test <file|dir>... 意味を読む検査も動かす(API key が要ります)
|
|
32
32
|
判定役は chaff.yaml の ai_backend で選びます
|
|
33
|
+
--checks <ファイル|ai-tells> は checks.yaml の代わりにその検査を聞く(ai-tells は同梱の AI らしさの問い)
|
|
33
34
|
chaff init chaff.yaml を作る(端末ならジャンルを尋ねる。--genre <ジャンル> でも選べる)
|
|
34
35
|
chaff init --plugin <名前> YAML だけのルールの束(chaff-plugin-<名前>/)を作る
|
|
35
36
|
chaff plugin-test [フォルダ] プラグインの各ルールを、そのルールの例にかけて確かめる
|
|
@@ -57,6 +58,7 @@ const USAGE_JA = `chaff — 文章の読みにくいところを見つけます
|
|
|
57
58
|
--variant-key は variant の欄の代わりにその欄で出力を分けて並べる。--json は --format json と同じ。markdown は PR のコメント向け
|
|
58
59
|
chaff fix-plan <file> [--depth light|structure|register] [--json]
|
|
59
60
|
指摘をルールごとにまとめ、直す方向と確かめのコマンドを、書き直す人や AI 向けの計画にする(何も送らない)
|
|
61
|
+
--all-ai-signs は AI らしさのルールを全部動かし、点と止めるときを足す。--before <元の文書> は元より増えた指摘を出す
|
|
60
62
|
chaff rules ルールの一覧を、グループごとに表で出す(いまの段階つき)
|
|
61
63
|
chaff rules --json いまの設定とルールの説明を JSON で出す(AI に渡す用)
|
|
62
64
|
chaff baseline <dir> いまある指摘を棚上げする(既存の repo に入れるとき)
|
|
@@ -90,6 +92,7 @@ const USAGE_EN = `chaff — finds what makes writing hard to read. It never rewr
|
|
|
90
92
|
chaff . every Markdown file here
|
|
91
93
|
chaff test <file|dir>... also run the checks that read meaning (needs an API key)
|
|
92
94
|
the judge is chosen by ai_backend in chaff.yaml
|
|
95
|
+
--checks <file|ai-tells> asks those checks instead of checks.yaml (ai-tells: the AI-likeness questions chaff ships)
|
|
93
96
|
chaff init create chaff.yaml (asks for the genre at a terminal; --genre <genre> chooses it)
|
|
94
97
|
chaff init --plugin <name> create a YAML rule pack, chaff-plugin-<name>/
|
|
95
98
|
chaff plugin-test [folder] run each rule of a plugin on the rule's own example
|
|
@@ -117,6 +120,7 @@ const USAGE_EN = `chaff — finds what makes writing hard to read. It never rewr
|
|
|
117
120
|
--variant-key splits the outputs by that field instead of variant; --json is --format json; markdown is for a PR comment
|
|
118
121
|
chaff fix-plan <file> [--depth light|structure|register] [--json]
|
|
119
122
|
a plan for whoever rewrites the file, a person or an AI: findings by rule, how to rewrite each, the checks to run after (sends nothing)
|
|
123
|
+
--all-ai-signs runs every AI-likeness rule and adds the score and when to stop; --before <original> lists the findings the rewrite raised
|
|
120
124
|
chaff rules the rules as a table, by group, with the level each runs at now
|
|
121
125
|
chaff rules --json the current settings and what each rule is, as JSON (to give to an AI)
|
|
122
126
|
chaff baseline <dir> shelve today's findings (when adding chaff to an existing repository)
|
package/src/commands/fix-plan.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { outlineOf } from "../outline/shape.ts";
|
|
3
3
|
import { structureOf } from "../structure-shape/of-document.ts";
|
|
4
|
-
import { buildFixPlan } from "../fix-plan/plan.ts";
|
|
4
|
+
import { buildFixPlan, type AiScoreSummary, type SincePlan } from "../fix-plan/plan.ts";
|
|
5
5
|
import { renderFixPlanJson, renderFixPlanMarkdown } from "../fix-plan/render.ts";
|
|
6
6
|
import { FIX_PLAN_TEXT } from "../fix-plan/text.ts";
|
|
7
7
|
import { chosenDepthOf } from "../fix-plan/chosen-depth.ts";
|
|
8
|
+
import { allSignRules, runAllSigns, withAllSigns, type LintResult } from "../fix-plan/all-signs.ts";
|
|
9
|
+
import { risenRules } from "../fix-plan/risen.ts";
|
|
10
|
+
import { aiScoreOfDocument } from "../ai-score/of-document.ts";
|
|
11
|
+
import { shownSignsOf, type AiScore } from "../ai-score/score.ts";
|
|
8
12
|
import type { Checked } from "./feedback.ts";
|
|
9
13
|
import { readDocument } from "./read-document.ts";
|
|
10
14
|
import type { TreeContext } from "./tree.ts";
|
|
@@ -13,7 +17,9 @@ import { showsGuide } from "../cli-args.ts";
|
|
|
13
17
|
import type { Config } from "../config/load.ts";
|
|
14
18
|
|
|
15
19
|
/** Options whose value is the next argument. That value is not a file. */
|
|
16
|
-
const VALUED: ReadonlySet<string> = new Set(["--language", "--genre", "--depth"]);
|
|
20
|
+
const VALUED: ReadonlySet<string> = new Set(["--language", "--genre", "--depth", "--before"]);
|
|
21
|
+
|
|
22
|
+
const ALL_SIGNS_FLAG = "--all-ai-signs";
|
|
17
23
|
|
|
18
24
|
/** --depth's value: undefined when not given, empty when given with nothing after it (which is then reported). */
|
|
19
25
|
const depthFlag = (argv: readonly string[], context: FixPlanContext): string | undefined =>
|
|
@@ -31,6 +37,58 @@ export type FixPlanContext = TreeContext & {
|
|
|
31
37
|
const guideOf = (checked: Omit<Checked, "conditions">, config: Config, argv: readonly string[]): ReportedGuide | undefined =>
|
|
32
38
|
genreWasSet(checked.genreFrom) && showsGuide(argv) ? reportedGuide(config, checked.genre, checked.language, checked.rules) : undefined;
|
|
33
39
|
|
|
40
|
+
/** One file as the plan reads it: what lint found, the findings the plan is built from, and the score with --all-ai-signs. */
|
|
41
|
+
type PlanRead = { readonly checked: Omit<Checked, "conditions">; readonly found: LintResult; readonly allSigns: AllSigns | undefined };
|
|
42
|
+
|
|
43
|
+
type AllSigns = { readonly aiScore: AiScoreSummary; readonly ruleIds: ReadonlySet<string> };
|
|
44
|
+
|
|
45
|
+
const summaryOf = (score: AiScore): AiScoreSummary => ({
|
|
46
|
+
level: score.level ?? null,
|
|
47
|
+
notScored: score.notScored?.reason ?? null,
|
|
48
|
+
signs: score.signs,
|
|
49
|
+
compared: score.compared,
|
|
50
|
+
shown: shownSignsOf(score),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* With --all-ai-signs, every AI-likeness rule's findings take the place of lint's own for them, and the plan carries the
|
|
55
|
+
* AI-likeness score. The document is read with part-of-speech tags, as ai-score reads it.
|
|
56
|
+
*/
|
|
57
|
+
const readForPlan = async (path: string, argv: readonly string[], context: FixPlanContext): Promise<PlanRead | undefined> => {
|
|
58
|
+
const checked = await context.check(path);
|
|
59
|
+
if (!argv.includes(ALL_SIGNS_FLAG)) return { checked, found: checked, allSigns: undefined };
|
|
60
|
+
const prose = await readDocument(path, ["fix-plan", "--language", checked.language, ...argv.slice(1)], context, true);
|
|
61
|
+
if (prose === undefined) return undefined;
|
|
62
|
+
const signs = runAllSigns(prose.doc, checked.rules, checked.genre);
|
|
63
|
+
const ruleIds = new Set(allSignRules(checked.rules, checked.language).map((rule) => rule.id));
|
|
64
|
+
return {
|
|
65
|
+
checked,
|
|
66
|
+
found: withAllSigns(checked, signs, ruleIds),
|
|
67
|
+
allSigns: { aiScore: summaryOf(aiScoreOfDocument(prose.doc, checked.rules, checked.genre)), ruleIds },
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** The original given with --before, read the same way: the rules whose findings the rewrite raised, and its score. */
|
|
72
|
+
const sinceOf = async (path: string, after: PlanRead, argv: readonly string[], context: FixPlanContext): Promise<SincePlan | undefined> => {
|
|
73
|
+
const before = await readForPlan(path, argv, context);
|
|
74
|
+
return before === undefined ? undefined : { path, risen: risenRules(before.found.findings, after.found.findings), aiScore: before.allSigns?.aiScore ?? null };
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** --before's file, read; a problem to report when it is missing. */
|
|
78
|
+
const sinceFor = async (
|
|
79
|
+
argv: readonly string[],
|
|
80
|
+
after: PlanRead,
|
|
81
|
+
context: FixPlanContext,
|
|
82
|
+
): Promise<{ readonly since: SincePlan | undefined } | { readonly problem: string | undefined }> => {
|
|
83
|
+
if (!argv.includes("--before")) return { since: undefined };
|
|
84
|
+
const path = context.flag(argv, "--before");
|
|
85
|
+
// "--before --json" names no original; reading --json as a file name would report the wrong problem.
|
|
86
|
+
if (path === undefined || path.startsWith("--")) return { problem: FIX_PLAN_TEXT[context.ui ?? "ja"].usage };
|
|
87
|
+
if (!existsSync(path)) return { problem: FIX_PLAN_TEXT[context.ui ?? "ja"].notFound(path) };
|
|
88
|
+
const since = await sinceOf(path, after, argv, context);
|
|
89
|
+
return since === undefined ? { problem: undefined } : { since };
|
|
90
|
+
};
|
|
91
|
+
|
|
34
92
|
/**
|
|
35
93
|
* An instruction document for whoever rewrites the file: the findings grouped by rule, each rule's rewrite direction,
|
|
36
94
|
* the document-level signals, the structure targets from human articles, a recommended mode and the checks to run after. Deterministic; sends nothing anywhere.
|
|
@@ -51,7 +109,14 @@ export const runFixPlan = async (targets: readonly string[], argv: readonly stri
|
|
|
51
109
|
console.error(FIX_PLAN_TEXT[context.ui ?? "ja"].notFound(path));
|
|
52
110
|
return 1;
|
|
53
111
|
}
|
|
54
|
-
const
|
|
112
|
+
const read = await readForPlan(path, argv, context);
|
|
113
|
+
if (read === undefined) return 1;
|
|
114
|
+
const since = await sinceFor(argv, read, context);
|
|
115
|
+
if ("problem" in since) {
|
|
116
|
+
if (since.problem !== undefined) console.error(since.problem);
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
119
|
+
const { checked } = read;
|
|
55
120
|
// The outline is read in the language lint chose, so the plan's findings and its outline describe one reading.
|
|
56
121
|
const prose = await readDocument(path, ["fix-plan", "--language", checked.language, ...argv.slice(1)], context, false);
|
|
57
122
|
if (prose === undefined) return 1;
|
|
@@ -61,14 +126,16 @@ export const runFixPlan = async (targets: readonly string[], argv: readonly stri
|
|
|
61
126
|
genre: checked.genre,
|
|
62
127
|
experimental: context.config.experimental || argv.includes("--experimental"),
|
|
63
128
|
genreFlag: context.flag(argv, "--genre"),
|
|
64
|
-
findings:
|
|
129
|
+
findings: read.found.findings,
|
|
65
130
|
rules: checked.rules,
|
|
66
|
-
skipped:
|
|
131
|
+
skipped: read.found.skipped,
|
|
67
132
|
outline: outlineOf(prose.doc),
|
|
68
133
|
structure: structureOf(prose.doc),
|
|
69
134
|
phrases: prose.doc.lexicons["ai-tell"] ?? [],
|
|
70
135
|
chosenDepth: depth.chosen,
|
|
71
136
|
guide: guideOf(checked, context.config, argv),
|
|
137
|
+
allSigns: read.allSigns,
|
|
138
|
+
since: since.since,
|
|
72
139
|
});
|
|
73
140
|
console.log(argv.includes("--json") ? renderFixPlanJson(plan) : renderFixPlanMarkdown(plan));
|
|
74
141
|
return 0;
|
package/src/commands/test.ts
CHANGED
|
@@ -6,7 +6,9 @@ import { guessLanguage } from "../detect.ts";
|
|
|
6
6
|
import { collectTargets, readDocumentFile } from "../files.ts";
|
|
7
7
|
import { loadRules } from "../rule-load.ts";
|
|
8
8
|
import { counted } from "../render/plural.ts";
|
|
9
|
-
import {
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { BUNDLED_CHECKS_DIR, checksPathOf, loadChecks, type UserCheck } from "../checks.ts";
|
|
11
|
+
import { PACKAGE_DIR } from "../package-files.ts";
|
|
10
12
|
import { CACHE_DIR, credentialHint, describeFailure, hasCredentials, type JudgeOptions } from "../judge.ts";
|
|
11
13
|
import { ENV_FILE, loadEnvFile } from "../env.ts";
|
|
12
14
|
import { planSemantic, runSemantic, semanticNeeds } from "../run-semantic.ts";
|
|
@@ -32,6 +34,7 @@ const TEXT: Texts<{
|
|
|
32
34
|
readonly noCause: string;
|
|
33
35
|
readonly tally: (machine: number, ai: number) => string;
|
|
34
36
|
readonly untouched: string;
|
|
37
|
+
readonly noChecks: (given: string, path: string) => string;
|
|
35
38
|
}> = {
|
|
36
39
|
ja: {
|
|
37
40
|
total: (total) => ` 合計 ${total} 箇所を送ります。--dry-run なので API は呼んでいません。`,
|
|
@@ -47,6 +50,7 @@ const TEXT: Texts<{
|
|
|
47
50
|
noCause: "原因は返ってきませんでした",
|
|
48
51
|
tally: (machine, ai) => ` 機械 ${machine} 件 / AI ${ai} 件`,
|
|
49
52
|
untouched: " 文章は書き換えていません。直すのは書いた人です。",
|
|
53
|
+
noChecks: (given, path) => `chaff: --checks ${given} の検査が見つかりません(${path})。同梱の組は ai-tells です。`,
|
|
50
54
|
},
|
|
51
55
|
en: {
|
|
52
56
|
total: (total) => ` ${counted(total, "passage")} in all would be sent. With --dry-run the API was not called.`,
|
|
@@ -62,11 +66,15 @@ const TEXT: Texts<{
|
|
|
62
66
|
noCause: "No reason was given.",
|
|
63
67
|
tally: (machine, ai) => ` ${machine} by machine / ${ai} by AI`,
|
|
64
68
|
untouched: " The text was not changed. Fixing it is the writer's job.",
|
|
69
|
+
noChecks: (given, path) => `chaff: there are no checks for --checks ${given} (${path}). The set chaff ships is ai-tells.`,
|
|
65
70
|
},
|
|
66
71
|
};
|
|
67
72
|
|
|
68
73
|
const DIVIDER = "─".repeat(60);
|
|
69
74
|
|
|
75
|
+
/** --checks's value; "--checks --dry-run" names no checks, since --dry-run is an option, not a set. */
|
|
76
|
+
const checksNamed = (next: string | undefined): string => (next === undefined || next.startsWith("--") ? "" : next);
|
|
77
|
+
|
|
70
78
|
export type TestContext = {
|
|
71
79
|
readonly config: Config;
|
|
72
80
|
readonly resolveGenre: (path: string, source: string, config: Config) => { genre: string; from: string };
|
|
@@ -163,7 +171,15 @@ export const runTest = async (targets: readonly string[], argv: readonly string[
|
|
|
163
171
|
const { config, resolveGenre, inspect } = context;
|
|
164
172
|
// 鍵の置き場所で「設定したのに効かない」を起こさせない。シェルの環境変数のほうが勝つ。
|
|
165
173
|
const envFile = loadEnvFile(process.cwd());
|
|
166
|
-
const
|
|
174
|
+
const at = argv.indexOf("--checks");
|
|
175
|
+
const given = at === -1 ? undefined : checksNamed(argv[at + 1]);
|
|
176
|
+
const checksPath = checksPathOf(given, process.cwd(), join(PACKAGE_DIR, BUNDLED_CHECKS_DIR));
|
|
177
|
+
// checks.yaml is optional; a set named on the command line that is not there is a mistake to say.
|
|
178
|
+
if (given !== undefined && !existsSync(checksPath)) {
|
|
179
|
+
console.error(TEXT[context.ui].noChecks(given, checksPath));
|
|
180
|
+
return 1;
|
|
181
|
+
}
|
|
182
|
+
const checks = loadChecks(checksPath);
|
|
167
183
|
const results = await Promise.all(paths.map((path) => inspect(path, config, argv)));
|
|
168
184
|
results.forEach((result) => {
|
|
169
185
|
console.log(result.text.replace(/\n/u, `\n${machineBanner(result.language).join("\n")}`));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ROMAN_NUMERAL, romanRangeOf } from "./roman-numeral.ts";
|
|
2
2
|
import { citationKeySpans } from "./citation-key.ts";
|
|
3
3
|
import { dottedNameSpans } from "./dotted-name.ts";
|
|
4
|
-
import { letterJoinedNameSpans } from "./letter-joined-name.ts";
|
|
4
|
+
import { capitalJoinedNameSpans, letterJoinedNameSpans } from "./letter-joined-name.ts";
|
|
5
5
|
import { loneNumeralSpans, nameNumeralSpans } from "./name-numeral.ts";
|
|
6
6
|
import { placeholderSpans } from "./placeholder.ts";
|
|
7
7
|
import { numeralWordSpans } from "./numeral-word.ts";
|
|
@@ -13,6 +13,8 @@ import { referenceListSpans } from "../reference-lists.ts";
|
|
|
13
13
|
import { linkTitleSpans } from "./acronym-link.ts";
|
|
14
14
|
import { citationNoteSpans } from "./citation-note.ts";
|
|
15
15
|
import { documentCitationSpans } from "./case-citation.ts";
|
|
16
|
+
import { referenceEntrySpans } from "./reference-entry.ts";
|
|
17
|
+
import { chatLogSpans } from "./chat-log-line.ts";
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* 大文字の語が略語ではなく、決まった書き方の一部として読める所(3:30 PM、1pm ET、USD 1,000、Kansas City, MO 64108、Fort Lauderdale FL 33304)。
|
|
@@ -39,6 +41,8 @@ export type NotationWords = {
|
|
|
39
41
|
readonly titles: readonly string[];
|
|
40
42
|
/** 日付・時刻の数字の後ろに書く単位(年、月、日、時、分)。その前の同じ大文字の繰り返し(YY年)は書式の置き場所。 */
|
|
41
43
|
readonly dateTimeUnits: readonly string[];
|
|
44
|
+
/** ショートメッセージでキーワードを送る動詞(text GNPCGS to 333111 の text)。 */
|
|
45
|
+
readonly textMessageVerbs?: readonly string[];
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
const MINUTES = String.raw`:[0-5]\d`;
|
|
@@ -96,6 +100,13 @@ const titledName = (titles: string): readonly RegExp[] => [
|
|
|
96
100
|
const placeAndState = (states: string): RegExp =>
|
|
97
101
|
new RegExp(String.raw`(?<=\p{Lu}\p{Ll}[\p{L}'’.-]*,\s+)${states}(?=[ \t]*(?:\r?\n|$)|[,.;:)\]!?]|\s+\p{Ll})`, "gu");
|
|
98
102
|
|
|
103
|
+
/**
|
|
104
|
+
* ショートメッセージで送るキーワード(texting GNPCGS to 333111)。動詞と短い番号の間の大文字は、そのまま打ち込む文字列。
|
|
105
|
+
* 番号は短縮番号の桁(4 から 6 桁)で、動詞の無い「GDP to 3000」は略語のまま数える。
|
|
106
|
+
*/
|
|
107
|
+
const textMessageKeyword = (verbs: readonly string[]): RegExp =>
|
|
108
|
+
new RegExp(String.raw`(?<![\p{L}\p{N}_])${oneOf(verbs)}\s+["“']?[A-Z][A-Z0-9]+["”']?\s+to\s+\d{4,6}(?!\d)`, "giu");
|
|
109
|
+
|
|
99
110
|
/** メールアドレス(OASH-RFI@hhs.gov)。@ の前の大文字は宛先の名前で、略語ではない。 */
|
|
100
111
|
const EMAIL_ADDRESS = /(?<![\p{L}\p{N}._%+-])[\p{L}\p{N}._%+-]+@[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)+/gu;
|
|
101
112
|
|
|
@@ -112,6 +123,7 @@ const patternsOf = (words: NotationWords): readonly RegExp[] => [
|
|
|
112
123
|
new RegExp(String.raw`(?<![\p{L}\p{N}_])${oneOf(words.honorifics)}\s+${SURNAME_IN_CAPITALS}`, "gu"),
|
|
113
124
|
capitalHonorific(words.honorifics),
|
|
114
125
|
...titledName(oneOf(words.titles)),
|
|
126
|
+
textMessageKeyword(words.textMessageVerbs ?? []),
|
|
115
127
|
EMAIL_ADDRESS,
|
|
116
128
|
];
|
|
117
129
|
|
|
@@ -128,6 +140,7 @@ export const notAcronymSpansOf = (words: NotationWords): NotAcronymSpans => {
|
|
|
128
140
|
...citationKeySpans(text),
|
|
129
141
|
...dottedNameSpans(text),
|
|
130
142
|
...letterJoinedNameSpans(text),
|
|
143
|
+
...capitalJoinedNameSpans(text),
|
|
131
144
|
...nameNumeralSpans(text),
|
|
132
145
|
...loneNumeralSpans(text),
|
|
133
146
|
...seriesLabelSpans(text),
|
|
@@ -151,6 +164,7 @@ export const lexiconNotationOf = (wordsOf: (id: string) => string[]): NotAcronym
|
|
|
151
164
|
honorifics: wordsOf("honorific"),
|
|
152
165
|
titles: wordsOf("name-title"),
|
|
153
166
|
dateTimeUnits: wordsOf("date-time-unit"),
|
|
167
|
+
textMessageVerbs: wordsOf("text-message-verb"),
|
|
154
168
|
});
|
|
155
169
|
const names = nameSpansOf({
|
|
156
170
|
legalForms: wordsOf("legal-form"),
|
|
@@ -161,6 +175,7 @@ export const lexiconNotationOf = (wordsOf: (id: string) => string[]): NotAcronym
|
|
|
161
175
|
namePrefixes: wordsOf("name-prefix"),
|
|
162
176
|
streetSuffixes: wordsOf("street-suffix"),
|
|
163
177
|
capitalPhrases: wordsOf("capital-phrase"),
|
|
178
|
+
productNames: wordsOf("product-name"),
|
|
164
179
|
});
|
|
165
180
|
return (text) => [...notation(text), ...names(text)];
|
|
166
181
|
};
|
|
@@ -173,7 +188,8 @@ export const sourceNotAcronymSpans = (source: string, wordsOf: (id: string) => s
|
|
|
173
188
|
];
|
|
174
189
|
|
|
175
190
|
/**
|
|
176
|
-
*
|
|
191
|
+
* 数には入れるが指さない略語の範囲。リンク先の題名、文献を引いて始まる注、判例の引用の当事者・裁判所・事件番号、
|
|
192
|
+
* 角括弧の見出しで始まる文献の項目([FETCH] WHATWG, "Fetch")、貼り付けたチャットの発言(<jinxer-wm> FIRING: …)は、書き手が直せない。
|
|
177
193
|
*/
|
|
178
194
|
export const unreportedAcronymSpans = (
|
|
179
195
|
source: string,
|
|
@@ -184,4 +200,6 @@ export const unreportedAcronymSpans = (
|
|
|
184
200
|
...linkTitleSpans(source, links),
|
|
185
201
|
...citationNoteSpans(source, sentences, wordsOf("citation-author-joiner")),
|
|
186
202
|
...documentCitationSpans(sentences, source, wordsOf("case-party-joiner")),
|
|
203
|
+
...referenceEntrySpans(source),
|
|
204
|
+
...chatLogSpans(source),
|
|
187
205
|
];
|
|
@@ -13,6 +13,7 @@ import { escapeRegExp } from "../orthography.ts";
|
|
|
13
13
|
* 人事部(以下「HR」という。) 括弧の中が定義の語と略語だけ
|
|
14
14
|
* overnight reverse repurchase agreement (ON RRP) 括弧の中が空白で繋いだ略語だけで、前の名前から文字が順に拾える
|
|
15
15
|
* Partnership On Wide Energy and Resources Resilience Asia (POWERR Asia) 括弧の中が略語と添えた語で、前の名前の頭文字と揃う
|
|
16
|
+
* Regional Alliances and Multistakeholder Partnerships to Stimulate … (RAMPS program) 括弧の中が略語と小文字の語で、前の名前の頭の頭文字と揃う
|
|
16
17
|
* End User Technical Advisory Board (“End User TAB”) 括弧の中が名前の頭の語と略語で、前の名前の頭文字と揃う
|
|
17
18
|
* Special Interest Groups, or SIGs 名前の後ろの読点と言い換えの語(語彙表の definition-alternative)の後ろで、名前の頭文字と揃う
|
|
18
19
|
* Department of Health and Human Services (HHS or the Department) 括弧の最初の項目が略語で、言い換えの語の後ろに別の呼び名を添え、直前の語の頭文字と揃う
|
|
@@ -201,6 +202,30 @@ const isQualifiedAt = (body: string, acronym: string, at: number): boolean => {
|
|
|
201
202
|
return spellsOut(name.endsWith(words) ? name.slice(0, -words.length) : name, acronym);
|
|
202
203
|
};
|
|
203
204
|
|
|
205
|
+
/** 括弧の中で略語に添えた、小文字の 1、2 語((RAMPS program))と、閉じる括弧。 */
|
|
206
|
+
const LOWER_QUALIFIER = new RegExp(String.raw`^(?: \p{Ll}+){1,2}${WRAP}[))]`, "u");
|
|
207
|
+
|
|
208
|
+
/** 名前の頭から拾う略語の文字数の下限。2 字は名前の途中の頭文字にたまたま揃いやすい。 */
|
|
209
|
+
const MIN_HEAD_LETTERS = 3;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 括弧の中が略語と、それが何かを言う小文字の語だけの形(Regional Alliances and Multistakeholder Partnerships to Stimulate
|
|
213
|
+
* Cybersecurity Education and Workforce Development (RAMPS program))。略語は名前の頭の部分だけを縮めることがあるので、前の名前の
|
|
214
|
+
* 大文字で始まる語の頭文字の中に、略語の文字が続けて現れるときだけ展開と見なす。
|
|
215
|
+
*/
|
|
216
|
+
const isLowerQualifiedAt = (body: string, acronym: string, at: number): boolean => {
|
|
217
|
+
const letters = lettersOf(acronym);
|
|
218
|
+
if (letters.length < MIN_HEAD_LETTERS || !OPENED.test(body.slice(Math.max(0, at - NEAR), at))) return false;
|
|
219
|
+
if (!LOWER_QUALIFIER.test(body.slice(at + acronym.length, at + acronym.length + DEFINITION_REACH))) return false;
|
|
220
|
+
const words = body
|
|
221
|
+
.slice(0, at)
|
|
222
|
+
.replace(ANY_OPENED, "")
|
|
223
|
+
.trim()
|
|
224
|
+
.split(/\s+/u)
|
|
225
|
+
.slice(-letters.length * 3);
|
|
226
|
+
return initialsOf(words).includes(letters);
|
|
227
|
+
};
|
|
228
|
+
|
|
204
229
|
/** 括弧の中で略語の前に置いた、大文字で始まる語((“End User TAB”) の End User)。 */
|
|
205
230
|
const PREFIX = new RegExp(String.raw`[((]${WRAP}(?<words>(?:[A-Z][a-z]+ )+)$`, "u");
|
|
206
231
|
|
|
@@ -239,6 +264,7 @@ const isBracketedAt = (body: string, acronym: string, at: number): boolean => {
|
|
|
239
264
|
isNamedBeforeAt(body, acronym, at) ||
|
|
240
265
|
isJointBracketedAt(body, acronym, at) ||
|
|
241
266
|
isQualifiedAt(body, acronym, at) ||
|
|
267
|
+
isLowerQualifiedAt(body, acronym, at) ||
|
|
242
268
|
isPrefixedAt(body, acronym, at) ||
|
|
243
269
|
isSuffixedAt(body, acronym, at)
|
|
244
270
|
);
|