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,3 +1,6 @@
|
|
|
1
|
+
import type { Span, Token } from "../plugin.ts";
|
|
2
|
+
import { isFullName } from "./name-run.ts";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* 漢字の連なりを、読み手がもう知っている語(組織の名前、文書がほかで単独で使う組織の名前、決まった語)で割った残り。
|
|
3
6
|
* 知っている語は、連なりの中でも語の切れ目を見せる。残りのそれぞれが、読み手が切れ目を探す長さ。
|
|
@@ -58,3 +61,26 @@ export const standaloneNames = (runs: readonly string[], min: number, max: numbe
|
|
|
58
61
|
return length >= min && length <= max && units.some((unit) => run.endsWith(unit) && length - [...unit].length >= MIN_BODY_LENGTH);
|
|
59
62
|
}),
|
|
60
63
|
);
|
|
64
|
+
|
|
65
|
+
/** words の [from, to) が決まった語(内閣総理大臣)か。 */
|
|
66
|
+
const isKnownWordAt = (words: readonly string[], from: number, to: number, knownWords: ReadonlySet<string>): boolean =>
|
|
67
|
+
from >= 0 && to <= words.length && knownWords.has(words.slice(from, to).join(""));
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 連なりの語(runTokens、その字が words)の piece が、決まった職名(knownWords: 内閣総理大臣)のすぐ前かすぐ後ろに立つ人の姓と名
|
|
71
|
+
* (小泉純一郎内閣総理大臣、内閣総理大臣石破茂)か。職名は maxWords 語まで。人の名前と職名の組は、読み手が切れ目を知っている。
|
|
72
|
+
* 職名の無い名前の並び(田中一郎山田花子)は割らない。
|
|
73
|
+
*/
|
|
74
|
+
export const isTitledPerson = (
|
|
75
|
+
runTokens: readonly Token[],
|
|
76
|
+
words: readonly string[],
|
|
77
|
+
piece: Span,
|
|
78
|
+
knownWords: ReadonlySet<string>,
|
|
79
|
+
maxWords: number,
|
|
80
|
+
): boolean => {
|
|
81
|
+
if (!isFullName(runTokens.slice(piece.start, piece.end))) return false;
|
|
82
|
+
const lengths = Array.from({ length: maxWords }, (_, offset) => offset + 1);
|
|
83
|
+
return lengths.some(
|
|
84
|
+
(length) => isKnownWordAt(words, piece.end, piece.end + length, knownWords) || isKnownWordAt(words, piece.start - length, piece.start, knownWords),
|
|
85
|
+
);
|
|
86
|
+
};
|
|
@@ -11,7 +11,8 @@ const KINDS: readonly Kind[] = [
|
|
|
11
11
|
{ id: "period", usual: "。", western: "." },
|
|
12
12
|
];
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/** 日本語の語と語の間の半角の「,」(自家用自動車,社用車)も、読点を「,」の側で書いたものと数える。 */
|
|
15
|
+
const MARKS = /[、,。.]|(?<=[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}ー]),(?=[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}ー])/gu;
|
|
15
16
|
|
|
16
17
|
const DIGIT = /[\d0-9]/u;
|
|
17
18
|
|
|
@@ -95,6 +96,25 @@ const isItemReference = ({ text, at }: Place): boolean => DIGIT.test(text.charAt
|
|
|
95
96
|
|
|
96
97
|
const isInsideNumber = (text: string, at: number): boolean => DIGIT.test(text.charAt(at - 1)) && DIGIT.test(text.charAt(at + 1));
|
|
97
98
|
|
|
99
|
+
/**
|
|
100
|
+
* 符号(特許の図の符号や記号)。数字に一、二文字の英字を添えたもの(30a、11e、S1)か、一、二文字の英字だけ(a、b)。
|
|
101
|
+
* 「Word,Excel」のような語は符号ではない。
|
|
102
|
+
*/
|
|
103
|
+
const SIGN = /^(?:[A-Za-zA-Za-z]{0,2}[\d0-9]{1,4}[A-Za-zA-Za-z]{0,2}|[A-Za-zA-Za-z]{1,2})$/u;
|
|
104
|
+
const SIGN_BEFORE = /(?:^|[^\dA-Za-z0-9A-Za-z])([\dA-Za-z0-9A-Za-z]+)(?:[((][^()()]{0,20}[))])?$/u;
|
|
105
|
+
const SIGN_AFTER = /^([\dA-Za-z0-9A-Za-z]+)(?![\dA-Za-z0-9A-Za-z])/u;
|
|
106
|
+
const SIGN_REACH = 32;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 符号を並べる「,」(側壁9c,9c間、a,b,c、端部11c(引き出し口側),11d)。特許の公報は本文を「、」で書き、
|
|
110
|
+
* 符号の並びだけを「,」で区切る。前の符号の後ろに括弧の添え書きがあってもよい。
|
|
111
|
+
*/
|
|
112
|
+
const isBetweenSigns = (text: string, at: number): boolean => {
|
|
113
|
+
const before = SIGN_BEFORE.exec(text.slice(Math.max(0, at - SIGN_REACH), at))?.[1];
|
|
114
|
+
const after = SIGN_AFTER.exec(text.slice(at + 1, at + 1 + SIGN_REACH))?.[1];
|
|
115
|
+
return before !== undefined && after !== undefined && SIGN.test(before) && SIGN.test(after);
|
|
116
|
+
};
|
|
117
|
+
|
|
98
118
|
const isLabelPeriod = (place: Place, kana: ReadonlySet<string>): boolean => {
|
|
99
119
|
const { text, at } = place;
|
|
100
120
|
const beforeNumber = text.slice(Math.max(0, at - LIST_NUMBER_REACH), at);
|
|
@@ -116,7 +136,7 @@ const isLabelPeriod = (place: Place, kana: ReadonlySet<string>): boolean => {
|
|
|
116
136
|
*/
|
|
117
137
|
const isNotPunctuation = (place: Place, mark: string, kana: ReadonlySet<string>): boolean => {
|
|
118
138
|
if (mark === ".") return isInsideNumber(place.text, place.at) || isLabelPeriod(place, kana);
|
|
119
|
-
if (mark === ",") return isInsideNumber(place.text, place.at);
|
|
139
|
+
if (mark === ",") return isInsideNumber(place.text, place.at) || isBetweenSigns(place.text, place.at);
|
|
120
140
|
return false;
|
|
121
141
|
};
|
|
122
142
|
|
|
@@ -135,8 +155,8 @@ export const marksIn = (sentence: Sentence, source: string, exceptions: MarkExce
|
|
|
135
155
|
})
|
|
136
156
|
.filter((match) => !isWithinAny(skipped, { start: match.index, end: match.index }))
|
|
137
157
|
.map((match) => {
|
|
138
|
-
const western = match[0]
|
|
139
|
-
const kind = match[0] === "、" || match[0] === "," ? "comma" : "period";
|
|
158
|
+
const western = match[0] !== "、" && match[0] !== "。";
|
|
159
|
+
const kind = match[0] === "、" || match[0] === "," || match[0] === "," ? "comma" : "period";
|
|
140
160
|
return { kind, western, mark: match[0], offset: sentence.span.start + match.index };
|
|
141
161
|
});
|
|
142
162
|
};
|
|
@@ -41,3 +41,14 @@ export const introducesList = (source: string, offset: number): boolean => {
|
|
|
41
41
|
const next = nextWrittenLine(source, end + 1);
|
|
42
42
|
return next !== undefined && isListItem(next);
|
|
43
43
|
};
|
|
44
|
+
|
|
45
|
+
const LINE_OPENING = /^[ \t\u3000—―–]*$/u;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* "――今後の目標を教えてください。" (an interviewer's turn), "— Nina" (a sign-off) and "――――" (a rule across the page):
|
|
49
|
+
* a dash with only blanks and dashes before it on its line marks who speaks or where a block ends. It sets off no words.
|
|
50
|
+
*/
|
|
51
|
+
export const opensLine = (source: string, offset: number): boolean => {
|
|
52
|
+
const start = source.lastIndexOf("\n", offset - 1) + 1;
|
|
53
|
+
return LINE_OPENING.test(source.slice(start, offset));
|
|
54
|
+
};
|
|
@@ -13,3 +13,17 @@ const LETTER_JOINED_NAME = new RegExp(String.raw`(?<![${SPACED_WORD_CHAR}.-])[A-
|
|
|
13
13
|
/** 文の中の、一文字を - で語の前に繋いだ名前の範囲。 */
|
|
14
14
|
export const letterJoinedNameSpans = (text: string): Span[] =>
|
|
15
15
|
[...text.matchAll(LETTER_JOINED_NAME)].map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 大文字の語を - で頭だけ大文字の語に繋いだ名前(NITE SAFE-Lite)。後ろの語が名前を作るので、前の大文字は展開を待つ略語ではない。
|
|
19
|
+
* 後ろに大文字で始まる語が続けば、見出しの語の頭を大文字にした書き方(NASA-Funded Research)で、前の大文字は略語のまま数える。
|
|
20
|
+
* 小文字の語に繋いだもの(API-driven)と、大文字どうし(RT-PCR)も略語のまま。
|
|
21
|
+
*/
|
|
22
|
+
const CAPITAL_JOINED_NAME = new RegExp(
|
|
23
|
+
String.raw`(?<![${SPACED_WORD_CHAR}.-])[A-Z]{2,6}-\p{Lu}\p{Ll}{2,}(?![${SPACED_WORD_CHAR}-]|\.[A-Za-z0-9]|[ \t]+\p{Lu})`,
|
|
24
|
+
"gu",
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
/** 文の中の、大文字の語を頭だけ大文字の語に繋いだ名前の範囲。 */
|
|
28
|
+
export const capitalJoinedNameSpans = (text: string): Span[] =>
|
|
29
|
+
[...text.matchAll(CAPITAL_JOINED_NAME)].map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
package/src/detectors/lexicon.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { restricted, type Restrictors } from "./superlative-clause.ts";
|
|
|
12
12
|
import { stackedHedges, type StackedHedge } from "./stacked-hedge.ts";
|
|
13
13
|
import { comparisonMarkersOf, counterpartBefore, onlyQuoted, quotedRange, type ComparisonMarkers } from "./superlative-comparison.ts";
|
|
14
14
|
import { inPhrase, ownedBefore } from "./superlative-phrase.ts";
|
|
15
|
+
import { asked, contextOf, pointsAtReferent, ranksParts, sought, viewpointBefore, type Context } from "./superlative-context.ts";
|
|
15
16
|
|
|
16
17
|
const PER = 1000;
|
|
17
18
|
|
|
@@ -128,11 +129,12 @@ type Qualifiers = {
|
|
|
128
129
|
readonly restrictors: Restrictors;
|
|
129
130
|
readonly phrases: Lexicon;
|
|
130
131
|
readonly owners: Lexicon;
|
|
132
|
+
readonly context: Context;
|
|
131
133
|
};
|
|
132
134
|
|
|
133
135
|
const qualifiersOf = (doc: ProseDocument): Qualifiers => ({
|
|
134
136
|
comparison: comparisonMarkersOf(doc.lexicons["comparison-marker"] ?? []),
|
|
135
|
-
scope: scopeMarkersOf(doc.lexicons["superlative-scope"] ?? []),
|
|
137
|
+
scope: scopeMarkersOf(doc.lexicons["superlative-scope"] ?? [], doc.lexicons["superlative-purpose"], doc.lexicons["superlative-realm"]),
|
|
136
138
|
quantityNouns: doc.lexicons["quantity-noun"] ?? [],
|
|
137
139
|
suffixes: doc.lexicons["superlative-suffix"] ?? [],
|
|
138
140
|
amounts: doc.lexicons["superlative-amount"] ?? [],
|
|
@@ -143,6 +145,7 @@ const qualifiersOf = (doc: ProseDocument): Qualifiers => ({
|
|
|
143
145
|
},
|
|
144
146
|
phrases: doc.lexicons["superlative-phrase"] ?? [],
|
|
145
147
|
owners: doc.lexicons["superlative-owner"] ?? [],
|
|
148
|
+
context: contextOf(doc.lexicons),
|
|
146
149
|
});
|
|
147
150
|
|
|
148
151
|
/** 範囲・持ち主・節・分詞・形容詞・すぐ前の相手のどれかが最上級を限っているか、最上級が量か名前を言っているか。 */
|
|
@@ -150,6 +153,9 @@ const qualifiedAt = (tokens: readonly Token[], range: TokenRange, qualifiers: Qu
|
|
|
150
153
|
counterpartBefore(tokens, range, qualifiers.comparison.before) ||
|
|
151
154
|
scoped(tokens, range, qualifiers.scope) ||
|
|
152
155
|
ownedBefore(tokens, range, qualifiers.owners) ||
|
|
156
|
+
viewpointBefore(tokens, range, qualifiers.context.viewpoints) ||
|
|
157
|
+
pointsAtReferent(tokens, range, qualifiers.context.referents) ||
|
|
158
|
+
ranksParts(tokens, range, qualifiers.context.parts) ||
|
|
153
159
|
restricted(tokens, range, qualifiers.restrictors) ||
|
|
154
160
|
namesQuantity(tokens, range, qualifiers.quantityNouns) ||
|
|
155
161
|
makesWord(tokens, range, qualifiers.suffixes) ||
|
|
@@ -161,12 +167,19 @@ const everyQualified = (sentence: Sentence, entry: LexiconEntry, qualifiers: Qua
|
|
|
161
167
|
const ranges = entryRanges(sentence, entry);
|
|
162
168
|
return (
|
|
163
169
|
ranges.length > 0 &&
|
|
164
|
-
ranges.every(
|
|
170
|
+
ranges.every(
|
|
171
|
+
(range) =>
|
|
172
|
+
quotedRange(sentence, range) ||
|
|
173
|
+
inPhrase(tokens, range, qualifiers.phrases) ||
|
|
174
|
+
sought(sentence, range, qualifiers.context.goals) ||
|
|
175
|
+
qualifiedAt(tokens, range, qualifiers),
|
|
176
|
+
)
|
|
165
177
|
);
|
|
166
178
|
};
|
|
167
179
|
|
|
168
180
|
const qualified = (sentence: Sentence, entry: LexiconEntry, qualifiers: Qualifiers): boolean =>
|
|
169
181
|
DIGIT.test(sentence.text) ||
|
|
182
|
+
asked(sentence) ||
|
|
170
183
|
onlyQuoted(sentence, entry) ||
|
|
171
184
|
qualifiers.comparison.anywhere.some((marker) => entryIn(sentence, marker)) ||
|
|
172
185
|
everyQualified(sentence, entry, qualifiers);
|
|
@@ -26,7 +26,7 @@ export const firstContent = (scope: ItemScope, item: TokenRange): Token | undefi
|
|
|
26
26
|
|
|
27
27
|
export const lastContent = (scope: ItemScope, item: TokenRange): Token | undefined => last(scope, "content", item);
|
|
28
28
|
|
|
29
|
-
const shapeOfHead = (head: Token | undefined): string | undefined => {
|
|
29
|
+
export const shapeOfHead = (head: Token | undefined): string | undefined => {
|
|
30
30
|
if (head === undefined) return undefined;
|
|
31
31
|
return NOMINAL.has(head.pos) ? "NOMINAL" : head.pos;
|
|
32
32
|
};
|
|
@@ -92,6 +92,42 @@ export const isModifiedNoun = (scope: ItemScope, item: TokenRange): boolean => {
|
|
|
92
92
|
return MODIFIER.has(tokenAt(scope, headAt)?.pos ?? "") && nounPhrase && APPOSITIVE_ANCHOR.has(last(scope, "open", tail)?.pos ?? "");
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
+
/** and / or の直前が読点か。Oxford comma を打った並び。 */
|
|
96
|
+
export const commaBefore = (scope: ItemScope, at: number): boolean => scope.sentence.tokens[at - 1]?.surface === ",";
|
|
97
|
+
|
|
98
|
+
export const lastAt = (scope: ItemScope, name: ColumnName, item: TokenRange): number => lastIn(scope.sentence.column[name], item, scope.level);
|
|
99
|
+
|
|
100
|
+
/** 目的語を待つ語。前置詞と、解析器が小辞と読む to(related to / not limited to)。 */
|
|
101
|
+
const AWAITS_OBJECT: ReadonlySet<string> = new Set(["ADP", "PART"]);
|
|
102
|
+
|
|
103
|
+
/** 前置詞で終わる項目(conditions upon / necessary for / but not limited to)。目的語は読点の後ろにあり、項目はまだ閉じていない。 */
|
|
104
|
+
export const endsWithPreposition = (scope: ItemScope, item: TokenRange): boolean => AWAITS_OBJECT.has(last(scope, "open", item)?.pos ?? "");
|
|
105
|
+
|
|
106
|
+
/** 前置詞だけの項目(on or before Jan 23 の on)。and / or は 2 つの前置詞を結び、目的語を共有する。 */
|
|
107
|
+
export const isBarePreposition = (scope: ItemScope, item: TokenRange): boolean => {
|
|
108
|
+
const words = count(scope, "open", item);
|
|
109
|
+
return words > 0 && words === count(scope, "adposition", item);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** 形容詞と名詞だけの句(issues / use cases)。前置詞や動詞を連れていない。 */
|
|
113
|
+
export const isBareNounPhrase = (scope: ItemScope, item: TokenRange): boolean => {
|
|
114
|
+
const words = count(scope, "open", item);
|
|
115
|
+
return words > 0 && words === count(scope, "nounPhraseTail", item);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/** 副詞でない中身の語がある項目。not だけ、quickly だけの切れ端は項目にならない。 */
|
|
119
|
+
export const hasNonAdverbContent = (scope: ItemScope, item: TokenRange): boolean => count(scope, "contentNotAdverb", item) > 0;
|
|
120
|
+
|
|
121
|
+
/** 不定冠詞と形容詞だけの項目(a simple / a flexible)。名詞がまだ来ていないので、次の項目の名詞にかかる語。 */
|
|
122
|
+
export const isBareIndefiniteModifier = (scope: ItemScope, item: TokenRange): boolean => {
|
|
123
|
+
const at = firstAt(scope, "open", item);
|
|
124
|
+
const article = tokenAt(scope, at);
|
|
125
|
+
if (article === undefined || !(scope.sentence.words.indefinite?.has(article.surface.toLowerCase()) ?? false)) return false;
|
|
126
|
+
const rest = { start: at + 1, end: item.end };
|
|
127
|
+
const words = count(scope, "open", rest);
|
|
128
|
+
return words > 0 && words === count(scope, "adjective", rest);
|
|
129
|
+
};
|
|
130
|
+
|
|
95
131
|
export const isPluralNounPhrase = (scope: ItemScope, item: TokenRange): boolean =>
|
|
96
132
|
count(scope, "content", item) === count(scope, "nounPhraseTail", item) && lastContent(scope, item)?.features?.["Number"] === "Plur";
|
|
97
133
|
|
|
@@ -18,12 +18,14 @@ import { lowerBound, type TokenRange } from "./token-column.ts";
|
|
|
18
18
|
// に答えるための表を足していく。and / or のたびに作るのは、まだ閉じていない最後の 1、2 項目だけ。
|
|
19
19
|
|
|
20
20
|
/** 項目ごとに一度だけ答えを覚えておく問い。 */
|
|
21
|
-
export type Flag =
|
|
21
|
+
export type Flag =
|
|
22
|
+
"closed" | "turn" | "example" | "participle" | "verbalShape" | "hasVerb" | "isClause" | "prepositionalTail" | "notNounHead" | "notProperNounHead";
|
|
22
23
|
|
|
23
24
|
type FlagTest = (scope: ItemScope, item: TokenRange) => boolean;
|
|
24
25
|
|
|
25
26
|
export const FLAG_TESTS: Readonly<Record<Flag, FlagTest>> = {
|
|
26
27
|
closed: (scope, item) => isListConjunction(openingOf(scope, item)),
|
|
28
|
+
turn: (scope, item) => scope.sentence.words.clauseConjunction?.has(openingOf(scope, item)?.surface.toLowerCase() ?? "") ?? false,
|
|
27
29
|
example: (scope, item) => exampleEnd(scope, item) !== -1,
|
|
28
30
|
participle: (scope, item) => participleOpening(scope, item) !== undefined,
|
|
29
31
|
verbalShape: (scope, item) => VERBAL.has(shapeOf(scope, item) ?? ""),
|
|
@@ -40,6 +42,7 @@ type PerFlag<T> = Record<Flag, T>;
|
|
|
40
42
|
|
|
41
43
|
const perFlag = <T>(make: () => T): PerFlag<T> => ({
|
|
42
44
|
closed: make(),
|
|
45
|
+
turn: make(),
|
|
43
46
|
example: make(),
|
|
44
47
|
participle: make(),
|
|
45
48
|
verbalShape: make(),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// An and / or that joins words inside the last item rather than the list's last two items: an item not finished yet
|
|
2
|
+
// ("on or before", "a flexible and lightweight grid") or a run that repeats the conjunction without commas. Pure.
|
|
3
|
+
import { commaBefore, firstAt, firstContent, isBareIndefiniteModifier, isBareNounPhrase, isBarePreposition, lastAt } from "./list-item.ts";
|
|
4
|
+
import type { ItemScope } from "./list-sentence.ts";
|
|
5
|
+
import { lastOf, type View } from "./list-view.ts";
|
|
6
|
+
import type { TokenRange } from "./token-column.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 最後の項目がまだ閉じていない語だけなら、and / or はその語と後ろの語を結び、後ろの名詞や目的語を共有する。前置詞だけ
|
|
10
|
+
* (on or before Jan 23/58)か、不定冠詞と形容詞だけ(Neat, a flexible and lightweight Sass grid)。and / or の後ろが前置詞だけでも、
|
|
11
|
+
* 2 つの小辞を結んでいる(drive in and out)。
|
|
12
|
+
*/
|
|
13
|
+
export const joinsUnfinished = (scope: ItemScope, at: number, view: View, afterItem: TokenRange): boolean => {
|
|
14
|
+
const last = lastOf(view);
|
|
15
|
+
if (last === undefined || commaBefore(scope, at)) return false;
|
|
16
|
+
return isBarePreposition(scope, last.item) || isBareIndefiniteModifier(scope, last.item) || isBarePreposition(scope, afterItem);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** 項目の最初(fromEnd なら最後)の接続詞が、and / or と同じ深さの同じ語ならその位置。でなければ -1。 */
|
|
20
|
+
const sameConjunctionIn = (scope: ItemScope, item: TokenRange, word: string, fromEnd: boolean): number => {
|
|
21
|
+
const at = fromEnd ? lastAt(scope, "conjunction", item) : firstAt(scope, "conjunction", item);
|
|
22
|
+
const sameDepth = scope.sentence.depths[at] === scope.level;
|
|
23
|
+
return sameDepth && scope.sentence.tokens[at]?.surface.toLowerCase() === word ? at : -1;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 読点を打たずに同じ接続詞を重ねた並び(questions and issues and use cases)。読点を打たない書き方なので、最後の and の前に
|
|
28
|
+
* 読点を打つかの選択を見せない。最後の項目か and の後ろの項目に同じ接続詞があり、2 つの接続詞のあいだが形容詞と名詞だけで、
|
|
29
|
+
* 接続詞の後ろの頭の語どうしが同じ品詞のとき。品詞が違えば、並びのあとに述語や節をつないでいる(apples, pears and plums and ship
|
|
30
|
+
* them daily / engineers and they shipped)。あいだに前置詞や動詞があれば、後ろの接続詞は項目の中のもの(clean water and other
|
|
31
|
+
* attributes important to our physical and mental health)。
|
|
32
|
+
*/
|
|
33
|
+
export const repeatsConjunction = (scope: ItemScope, at: number, view: View, afterItem: TokenRange): boolean => {
|
|
34
|
+
const last = lastOf(view);
|
|
35
|
+
const word = scope.sentence.tokens[at]?.surface.toLowerCase() ?? "";
|
|
36
|
+
if (last === undefined || commaBefore(scope, at)) return false;
|
|
37
|
+
const kind = firstContent(scope, afterItem)?.pos;
|
|
38
|
+
const before = sameConjunctionIn(scope, last.item, word, true);
|
|
39
|
+
const later = sameConjunctionIn(scope, afterItem, word, false);
|
|
40
|
+
const bareBefore = before !== -1 && isBareNounPhrase(scope, { start: before + 1, end: at });
|
|
41
|
+
const bareLater = later !== -1 && isBareNounPhrase(scope, { start: at + 1, end: later });
|
|
42
|
+
const startsLike = (conjunction: number, end: number): boolean => firstContent(scope, { start: conjunction + 1, end })?.pos === kind;
|
|
43
|
+
return kind !== undefined && ((bareBefore && startsLike(before, at)) || (bareLater && startsLike(later, afterItem.end)));
|
|
44
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// How the items of one bulleted list stand on the page: which items have a blank line after them. Pure; reads the
|
|
2
|
+
// source between the items' spans. list-item-form-mix reads from this which items to compare with which.
|
|
3
|
+
import type { Span } from "../plugin.ts";
|
|
4
|
+
|
|
5
|
+
/** Whether the text before the next item ends in a blank line: "item\n\n" or "item\n\n " but not "item\n". */
|
|
6
|
+
const endsInBlankLine = (text: string): boolean => text.split("\n").at(-2)?.trim() === "";
|
|
7
|
+
|
|
8
|
+
/** Whether a blank line stands between each item and the next. */
|
|
9
|
+
const blankAfter = (source: string, spans: readonly Span[]): readonly boolean[] =>
|
|
10
|
+
spans.slice(1).map((next, index) => endsInBlankLine(source.slice(spans[index]?.start ?? next.start, next.start)));
|
|
11
|
+
|
|
12
|
+
/** Lone items that label a run: one is a lead-in like any other item's, two or more make groups. */
|
|
13
|
+
const MIN_GROUP_LABELS = 2;
|
|
14
|
+
|
|
15
|
+
/** How a list's items stand: the groups to compare within, and the lone items that head a run. */
|
|
16
|
+
export type ItemLayout = { readonly groups: readonly (readonly Span[])[]; readonly heads: readonly Span[] };
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Items standing alone between blank lines before a run of items without them are a nested list a converter flattened
|
|
20
|
+
* (- 家具からの転落, then its steps). With two or more lone items right before a run, each run is a list of its own and the
|
|
21
|
+
* lone items are compared with none; with fewer, the list is one group. heads: every lone item before a run, with only
|
|
22
|
+
* lone items between.
|
|
23
|
+
*/
|
|
24
|
+
export const itemLayout = (source: string, spans: readonly Span[]): ItemLayout => {
|
|
25
|
+
const blank = blankAfter(source, spans);
|
|
26
|
+
const alone = (index: number): boolean => (index === 0 || blank[index - 1] === true) && blank[index] === true;
|
|
27
|
+
const runAfter = (index: number): readonly Span[] => {
|
|
28
|
+
const end = blank.findIndex((isBlank, gap) => gap > index && isBlank);
|
|
29
|
+
return spans.slice(index + 1, end === -1 ? spans.length : end + 1);
|
|
30
|
+
};
|
|
31
|
+
const runStart = (index: number): number => blank.findIndex((isBlank, gap) => gap > index && !isBlank);
|
|
32
|
+
const headsRun = (index: number): boolean => {
|
|
33
|
+
const start = runStart(index);
|
|
34
|
+
return alone(index) && start !== -1 && spans.slice(index + 1, start).every((_, offset) => alone(index + 1 + offset));
|
|
35
|
+
};
|
|
36
|
+
const labels = spans.flatMap((_, index) => (alone(index) && blank[index + 1] === false ? [index] : []));
|
|
37
|
+
const heads = spans.filter((_, index) => headsRun(index));
|
|
38
|
+
return { groups: labels.length < MIN_GROUP_LABELS ? [spans] : labels.map(runAfter), heads };
|
|
39
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { BulletList, Sentence, Span } from "../plugin.ts";
|
|
1
|
+
import type { BulletList, Detector, DetectorOptions, Finding, ProseDocument, Sentence, Span } from "../plugin.ts";
|
|
2
|
+
import { densityFindings } from "./ai-phrasing.ts";
|
|
2
3
|
import { endsWithColon } from "./lead-in.ts";
|
|
3
4
|
|
|
4
5
|
/** Between a lead-in and its list: only blank space. A thematic break (`***`) separates them; bold marks sit inside the sentence. */
|
|
@@ -36,6 +37,11 @@ const labelWords = (text: string): string => {
|
|
|
36
37
|
/** A noun with no kana inflection (参考, 注意点): a name, not a sentence (以下の通りです) and not a lone symbol (⚠️). */
|
|
37
38
|
const NOUN_LABEL = /^(?=.*\p{L})[^\p{Script=Hiragana}]+$/u;
|
|
38
39
|
|
|
40
|
+
/** An English label is a name of a word or three (See also, Pros); past that it is a sentence (Here's what you need). */
|
|
41
|
+
const MAX_LABEL_WORDS = 3;
|
|
42
|
+
|
|
43
|
+
const isNounLabel = (words: string): boolean => NOUN_LABEL.test(words) && words.split(/\s+/u).length <= MAX_LABEL_WORDS;
|
|
44
|
+
|
|
39
45
|
/**
|
|
40
46
|
* A field of an entry's template: the same noun label before the list of each entry (**参考:** before each entry's link).
|
|
41
47
|
* It names the field the way a table's column does; it does not lead into anything.
|
|
@@ -44,7 +50,21 @@ const fieldLabels = (leadIns: readonly Sentence[]): ReadonlySet<string> => {
|
|
|
44
50
|
const counts = leadIns
|
|
45
51
|
.map((sentence) => labelWords(sentence.text))
|
|
46
52
|
.reduce((tally, words) => tally.set(words, (tally.get(words) ?? 0) + 1), new Map<string, number>());
|
|
47
|
-
return new Set([...counts].filter(([words, count]) => count > 1 &&
|
|
53
|
+
return new Set([...counts].filter(([words, count]) => count > 1 && isNounLabel(words)).map(([words]) => words));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** A line that is only a bold label (**Pros:**, **参考**:), and the label inside the bold marks. */
|
|
57
|
+
const BOLD_LINE = /^(?:\*\*|__)(?<label>[^*_\n]+)(?:\*\*|__)[::]?$/u;
|
|
58
|
+
|
|
59
|
+
const lineAround = (source: string, sentence: Sentence): string => {
|
|
60
|
+
const end = source.indexOf("\n", sentence.span.end);
|
|
61
|
+
return source.slice(source.lastIndexOf("\n", sentence.span.start - 1) + 1, end === -1 ? source.length : end);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** A bold noun label on a line of its own names the list under it, as a heading does (**Pros:** then **Cons:**). */
|
|
65
|
+
const isBoldNounLabel = (sentence: Sentence, source: string): boolean => {
|
|
66
|
+
const label = BOLD_LINE.exec(lineAround(source, sentence).trim())?.groups?.["label"];
|
|
67
|
+
return label !== undefined && isNounLabel(labelWords(label));
|
|
48
68
|
};
|
|
49
69
|
|
|
50
70
|
/**
|
|
@@ -57,5 +77,32 @@ export const colonLeadIns = (sentences: readonly Sentence[], lists: readonly Bul
|
|
|
57
77
|
return before !== undefined && endsWithColon(before.text) && !insideAny(listSpans, before.span.start) ? [before] : [];
|
|
58
78
|
});
|
|
59
79
|
const fields = fieldLabels(leadIns);
|
|
60
|
-
return leadIns.filter((sentence) => !fields.has(labelWords(sentence.text)));
|
|
80
|
+
return leadIns.filter((sentence) => !fields.has(labelWords(sentence.text)) && !isBoldNounLabel(sentence, source));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** Lead-ins in one or two sections are a how-to's procedure or a pair of lists; the rule's why is section after section. */
|
|
84
|
+
const DEFAULT_MIN_SECTIONS = 3;
|
|
85
|
+
|
|
86
|
+
const minSections = (options: DetectorOptions): number => {
|
|
87
|
+
const value = options.settings?.["min_sections"];
|
|
88
|
+
return typeof value === "number" ? value : DEFAULT_MIN_SECTIONS;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/** How many sections hold a lead-in. A document without headings cannot be split, so each lead-in counts as its own. */
|
|
92
|
+
const sectionsHolding = (doc: ProseDocument, leadIns: readonly Sentence[]): number => {
|
|
93
|
+
if (!doc.sections.some((section) => section.depth > 0)) return leadIns.length;
|
|
94
|
+
const sectionOf = (sentence: Sentence): number => doc.sections.findLastIndex((section) => section.span.start <= sentence.span.start);
|
|
95
|
+
return new Set(leadIns.map(sectionOf)).size;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* コロンで箇条書きへ渡す文(以下の通りです:)。1 つなら案内だが、節ごとに続くと説明が箇条書きの前置きだけになる。
|
|
100
|
+
* 数えるのは文書の言語の文だけ。和文の中の英文(Examples include:)は、英語ではふつうの書き方なので数えない。
|
|
101
|
+
*/
|
|
102
|
+
export const colonLeadIn: Detector = (doc, options): Finding[] => {
|
|
103
|
+
const inDocumentLanguage = doc.sentences.filter((sentence) => sentence.embeddedLanguage === undefined);
|
|
104
|
+
const leadIns = colonLeadIns(inDocumentLanguage, doc.lists, doc.listSpans, doc.source);
|
|
105
|
+
if (sectionsHolding(doc, leadIns) < minSections(options)) return [];
|
|
106
|
+
const hits = leadIns.map((sentence) => ({ sentence, matched: sentence.text.trim() }));
|
|
107
|
+
return densityFindings(doc, hits, options.limit);
|
|
61
108
|
};
|
|
@@ -6,6 +6,7 @@ import { isQuotedAt } from "./bold-label.ts";
|
|
|
6
6
|
import { endsAsHeadline, markOrSkipped, withoutFootnoteReference, withoutTrailingMarks } from "./list-item-ending.ts";
|
|
7
7
|
import type { BulletList, Detector, Finding, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
|
|
8
8
|
import { isLinkLabel } from "./link-label.ts";
|
|
9
|
+
import { itemLayout } from "./list-layout.ts";
|
|
9
10
|
|
|
10
11
|
/** What an item is made of: a phrase or a sentence (ending), and the word it opens with (head, English only). */
|
|
11
12
|
export type Axis = "ending" | "head";
|
|
@@ -32,7 +33,7 @@ const isFiniteVerb = (token: Token): boolean => (token.pos === "VERB" || token.p
|
|
|
32
33
|
const withoutClosingAside = (tokens: readonly Token[]): readonly Token[] => {
|
|
33
34
|
const last = tokens.findLastIndex((token) => !SKIPPED_AT_END.has(token.pos) || CLOSING_BRACKETS.has(token.surface));
|
|
34
35
|
if (last === -1 || !CLOSING_BRACKETS.has(tokens[last]?.surface ?? "")) return tokens;
|
|
35
|
-
const open = tokens.findLastIndex((token, index) => index < last && OPENING_BRACKETS.has(token.surface));
|
|
36
|
+
const open = tokens.findLastIndex((token, index) => index < last && OPENING_BRACKETS.has(token.surface.charAt(0)));
|
|
36
37
|
return open <= 0 ? tokens : tokens.slice(0, open);
|
|
37
38
|
};
|
|
38
39
|
|
|
@@ -80,9 +81,36 @@ const japaneseSentenceEnding = (sentence: Sentence | undefined, headlineEndings:
|
|
|
80
81
|
return PREDICATE.has(last.pos) ? "sentence" : undefined;
|
|
81
82
|
};
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
const NAME_PARTS = new Set(["NOUN", "PROPN", "NUM", ...SKIPPED_AT_END]);
|
|
85
|
+
const MIN_NAME_WORDS = 2;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Nouns alone, with no particle or verb between them (消費者庁リコール情報サイト, 記載例(手続補正書), 聖地巡礼/ラブライブ!シリーズ): the
|
|
89
|
+
* name of a page, a form or a work, as a link's words are. It reads as a phrase, but its form is not the writer's to align.
|
|
90
|
+
*/
|
|
91
|
+
const isName = (item: readonly Token[]): boolean => {
|
|
92
|
+
const tokens = withoutClosingAside(item);
|
|
93
|
+
const words = tokens.filter((token) => !SKIPPED_AT_END.has(token.pos));
|
|
94
|
+
// A verbal noun last (各種ライブラリ更新, 不具合修正) names an act done: a phrase.
|
|
95
|
+
const act = words.at(-1)?.features?.["VerbForm"] === "Vnoun";
|
|
96
|
+
return words.length >= MIN_NAME_WORDS && !act && tokens.every((token) => NAME_PARTS.has(token.pos));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** The form of an item that is a name: counted with the phrases, never reported. */
|
|
100
|
+
export const NAME = "name";
|
|
101
|
+
|
|
102
|
+
/** A sentence that ends at a mark a name may hold (ラブライブ!), not at a full stop. */
|
|
103
|
+
const splitInName = (sentence: Sentence): boolean => /[!?!?]$/u.test(sentence.text.trim());
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Japanese: an item that is a name is a name; one that opens with a name and goes on in sentences (a term and its gloss,
|
|
107
|
+
* ステータスメッセージ。ステータスコードの…; an author and a title) is neither form; else an item of several sentences is a
|
|
108
|
+
* sentence (ownEnding aside), and one sentence is read by its ending.
|
|
109
|
+
*/
|
|
84
110
|
const japaneseEnding = (item: readonly Sentence[], headlineEndings: ReadonlySet<string>): string | undefined => {
|
|
85
111
|
const sentences = ownEnding(item);
|
|
112
|
+
if (isName(item.flatMap((sentence) => sentence.tokens ?? [])) && item.slice(0, -1).every(splitInName)) return NAME;
|
|
113
|
+
if (isName(item[0]?.tokens ?? [])) return undefined;
|
|
86
114
|
return sentences.length > 1 ? "sentence" : japaneseSentenceEnding(sentences[0], headlineEndings);
|
|
87
115
|
};
|
|
88
116
|
|
|
@@ -155,9 +183,20 @@ export type HeadContext = {
|
|
|
155
183
|
readonly nounsInList: ReadonlySet<string>;
|
|
156
184
|
/** Words that end a Japanese item as a headline does after a noun (翻訳あり), from headline-ending. */
|
|
157
185
|
readonly headlineEndings: ReadonlySet<string>;
|
|
186
|
+
/** Pronouns that open a clause (you, we), from subject-pronoun. */
|
|
187
|
+
readonly subjectPronouns: ReadonlySet<string>;
|
|
188
|
+
/** Words that open a prohibition before a noun (No calls), from prohibition-opener. */
|
|
189
|
+
readonly prohibitionOpeners: ReadonlySet<string>;
|
|
158
190
|
};
|
|
159
191
|
|
|
160
|
-
export const NO_HEAD_CONTEXT: HeadContext = {
|
|
192
|
+
export const NO_HEAD_CONTEXT: HeadContext = {
|
|
193
|
+
instructionVerbs: new Set(),
|
|
194
|
+
verbOrAdjective: new Set(),
|
|
195
|
+
nounsInList: new Set(),
|
|
196
|
+
headlineEndings: new Set(),
|
|
197
|
+
subjectPronouns: new Set(),
|
|
198
|
+
prohibitionOpeners: new Set(),
|
|
199
|
+
};
|
|
161
200
|
|
|
162
201
|
type HeadReading = "verb" | "noun" | "unjudged" | undefined;
|
|
163
202
|
|
|
@@ -213,18 +252,74 @@ const nounElsewhereInList: HeadReader = (tokens, at, context) => {
|
|
|
213
252
|
return first?.pos === "VERB" && context.nounsInList.has(first.lemma ?? "") && !opensObject(tokens[at + 1]) ? "unjudged" : undefined;
|
|
214
253
|
};
|
|
215
254
|
|
|
216
|
-
|
|
255
|
+
/** No calls, No food in the lab: a prohibition, as much a rule as "Never feed animals". Neither form. */
|
|
256
|
+
const prohibition: HeadReader = (tokens, at, context) => (context.prohibitionOpeners.has(tokens[at]?.surface.toLowerCase() ?? "") ? "unjudged" : undefined);
|
|
217
257
|
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
258
|
+
const HYPHEN = new Set(["-", "‐"]);
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Two words joined by a hyphen at the head: before a noun, a compound adjective (Run-on sentences, Self-managed
|
|
262
|
+
* installs); before "the", "a" or "your", a compound verb (Double-click the icon). Otherwise either.
|
|
263
|
+
*/
|
|
264
|
+
const hyphenCompound: HeadReader = (tokens, at) => {
|
|
265
|
+
const [first, hyphen, second, after] = [tokens[at], tokens[at + 1], tokens[at + 2], tokens[at + 3]];
|
|
266
|
+
if (first === undefined || hyphen === undefined || second === undefined || !HYPHEN.has(hyphen.surface)) return undefined;
|
|
267
|
+
if (first.span.end !== hyphen.span.start || hyphen.span.end !== second.span.start) return undefined;
|
|
268
|
+
if (opensObject(after)) return "verb";
|
|
269
|
+
return after?.pos === "NOUN" ? "noun" : "unjudged";
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const HEAD_READERS: readonly HeadReader[] = [
|
|
273
|
+
subjectContraction,
|
|
274
|
+
prohibition,
|
|
275
|
+
hyphenCompound,
|
|
276
|
+
verbOrAdjective,
|
|
277
|
+
instructionVerb,
|
|
278
|
+
seriesOfVerbs,
|
|
279
|
+
nextWord,
|
|
280
|
+
nounElsewhereInList,
|
|
281
|
+
];
|
|
282
|
+
|
|
283
|
+
const headAt = (tokens: readonly Token[], at: number, context: HeadContext): string | undefined => {
|
|
221
284
|
const first = tokens[at];
|
|
222
|
-
if (
|
|
285
|
+
if (first === undefined) return undefined;
|
|
223
286
|
const reading = HEAD_READERS.reduce<HeadReading>((found, reader) => found ?? reader(tokens, at, context), undefined);
|
|
224
287
|
if (reading === undefined) return headFromTag(first);
|
|
225
288
|
return reading === "unjudged" ? undefined : reading;
|
|
226
289
|
};
|
|
227
290
|
|
|
291
|
+
/** A subject pronoun as written in running text: "IT" in capitals is an acronym (IT issues), "I" is the pronoun. */
|
|
292
|
+
const isSubjectPronoun = (token: Token, context: HeadContext): boolean =>
|
|
293
|
+
context.subjectPronouns.has(token.surface.toLowerCase()) && (token.surface.length === 1 || token.surface !== token.surface.toUpperCase());
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Where an instruction starts after an opening clause with its own subject and verb, closed by a comma: "Next time you
|
|
297
|
+
* log in, let the manager save it" opens, as an item, with "let". -1 when there is no such opener.
|
|
298
|
+
*/
|
|
299
|
+
const instructionAfterOpener = (tokens: readonly Token[], at: number, context: HeadContext): number => {
|
|
300
|
+
const comma = tokens.findIndex((token, index) => index > at && token.surface === ",");
|
|
301
|
+
const verbFollows = (index: number): boolean => {
|
|
302
|
+
const next = tokens[index + 1];
|
|
303
|
+
return next !== undefined && isFiniteVerb(next);
|
|
304
|
+
};
|
|
305
|
+
const first = tokens[at];
|
|
306
|
+
// An item that opens with a subject or a verb (We do X when we …, get …) opens with its main clause.
|
|
307
|
+
const opensMain = first === undefined || isSubjectPronoun(first, context) || isFiniteVerb(first);
|
|
308
|
+
const clause = !opensMain && tokens.some((token, index) => index > at && index < comma && isSubjectPronoun(token, context) && verbFollows(index));
|
|
309
|
+
return clause && headAt(tokens, comma + 1, context) === "verb" ? comma + 1 : -1;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/** A question (Do you have …?, What is …?) opens with its question form, neither an instruction nor a noun phrase. */
|
|
313
|
+
const isQuestion = (sentence: Sentence | undefined): boolean => /\?["'”’)]*$/u.test(sentence?.text.trim() ?? "");
|
|
314
|
+
|
|
315
|
+
const englishHead = (sentences: readonly Sentence[], context: HeadContext): string | undefined => {
|
|
316
|
+
const tokens = sentences[0]?.tokens ?? [];
|
|
317
|
+
const at = tokens.findIndex((token) => !SKIPPED_AT_END.has(token.pos));
|
|
318
|
+
if (at === -1 || isTitleCase(sentences[0]?.text ?? "") || isQuestion(sentences[0])) return undefined;
|
|
319
|
+
const instruction = instructionAfterOpener(tokens, at, context);
|
|
320
|
+
return headAt(tokens, instruction === -1 ? at : instruction, context);
|
|
321
|
+
};
|
|
322
|
+
|
|
228
323
|
/** An item's form on an axis, or undefined when its words do not tell. Japanese items have no head axis (the verb comes last). */
|
|
229
324
|
/** An item that ends in a colon (Other kinds of decisions:) leads into what follows it: its ending is not its own, its opening still is. */
|
|
230
325
|
const LEAD_IN = /[::]$/u;
|
|
@@ -325,6 +420,8 @@ const headContext = (doc: ProseDocument, items: readonly (readonly Sentence[])[]
|
|
|
325
420
|
instructionVerbs: wordsOf(doc, "instruction-verb"),
|
|
326
421
|
verbOrAdjective: wordsOf(doc, "verb-or-adjective"),
|
|
327
422
|
headlineEndings: wordsOf(doc, "headline-ending"),
|
|
423
|
+
subjectPronouns: wordsOf(doc, "subject-pronoun"),
|
|
424
|
+
prohibitionOpeners: wordsOf(doc, "prohibition-opener"),
|
|
328
425
|
nounsInList: new Set(
|
|
329
426
|
items.flatMap((sentences) =>
|
|
330
427
|
sentences.flatMap((sentence) => (sentence.tokens ?? []).flatMap((token) => (token.pos === "NOUN" && token.lemma !== undefined ? [token.lemma] : []))),
|
|
@@ -333,15 +430,24 @@ const headContext = (doc: ProseDocument, items: readonly (readonly Sentence[])[]
|
|
|
333
430
|
});
|
|
334
431
|
|
|
335
432
|
const listFindings = (doc: ProseDocument, list: BulletList, limit: number): Finding[] => {
|
|
433
|
+
const layout = itemLayout(doc.source, list.itemSpans);
|
|
434
|
+
return layout.groups.flatMap((spans) => groupFindings(doc, spans, layout.heads, limit));
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
/** A phrase heading a run of items (- 使用する際の注意ポイント): the heading of a flattened nested list, not one of its items. */
|
|
438
|
+
const isGroupLabel = (sentences: readonly Sentence[], language: string): boolean =>
|
|
439
|
+
[FORMS.ending[0], NAME].includes(formOf("ending", sentences, language) ?? "");
|
|
440
|
+
|
|
441
|
+
const groupFindings = (doc: ProseDocument, itemSpans: readonly Span[], heads: readonly Span[], limit: number): Finding[] => {
|
|
336
442
|
const noteLeads = (doc.lexicons["list-note-lead"] ?? []).map((entry) => entry.pattern);
|
|
337
443
|
const linkEndings = (doc.lexicons["link-label-ending"] ?? []).map((entry) => entry.pattern);
|
|
338
|
-
const sentencesOf =
|
|
444
|
+
const sentencesOf = itemSpans.map((span) => ownSentences(doc, span, noteLeads));
|
|
339
445
|
if (sentencesOf.some(runsOn)) return [];
|
|
340
446
|
const judged = sentencesOf.filter((sentences, index) => {
|
|
341
|
-
const span =
|
|
447
|
+
const span = itemSpans[index];
|
|
342
448
|
if (span === undefined) return false;
|
|
343
449
|
const written = doc.source.slice(span.start, sentences.at(-1)?.span.end ?? span.end);
|
|
344
|
-
return isJudged(written, sentences) && !isLinkLabel(written, linkEndings);
|
|
450
|
+
return isJudged(written, sentences) && !isLinkLabel(written, linkEndings) && !(heads.includes(span) && isGroupLabel(sentences, doc.language));
|
|
345
451
|
});
|
|
346
452
|
const context = headContext(doc, judged);
|
|
347
453
|
return axesOf(judged).flatMap((axis) => {
|
|
@@ -349,8 +455,8 @@ const listFindings = (doc: ProseDocument, list: BulletList, limit: number): Find
|
|
|
349
455
|
const form = formOf(axis, sentences, doc.language, context);
|
|
350
456
|
return form === undefined ? [] : [{ sentences, form }];
|
|
351
457
|
});
|
|
352
|
-
const odd = minorityWithin(items, (item) => item.form === FORMS[axis][0], limit);
|
|
353
|
-
return odd.map((item) => findingOf(axis, item, odd.length, items.length, limit));
|
|
458
|
+
const odd = minorityWithin(items, (item) => (item.form === NAME ? FORMS.ending[0] : item.form) === FORMS[axis][0], limit);
|
|
459
|
+
return odd.filter((item) => item.form !== NAME).map((item) => findingOf(axis, item, odd.length, items.length, limit));
|
|
354
460
|
});
|
|
355
461
|
};
|
|
356
462
|
|