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,17 +1,11 @@
|
|
|
1
|
-
import type { Detector, Finding,
|
|
2
|
-
import { externalLinkTitleSpans } from "../link-title.ts";
|
|
1
|
+
import type { Detector, Finding, Sentence, Span, TableCell, Token } from "../plugin.ts";
|
|
3
2
|
import { groupBy, oddSpellings, type KeyedWord, type OddSpelling } from "../spelling-variants.ts";
|
|
4
3
|
import { dropsOkurigana, kanjiKeyAmong, katakanaKey, lemmaReading } from "../kana-spelling.ts";
|
|
5
4
|
import { isKatakanaWord, stemOf } from "../long-vowel.ts";
|
|
6
5
|
import { withNounsAfterParticles } from "../nominal-stem.ts";
|
|
7
|
-
import {
|
|
8
|
-
import { singleQuotedSpans } from "../single-quoted-span.ts";
|
|
9
|
-
import { nameSpans, touchesAny } from "../team-names.ts";
|
|
10
|
-
import { furiganaSpans } from "../furigana.ts";
|
|
11
|
-
import { contactEntrySpans } from "../contact-entry.ts";
|
|
6
|
+
import { isWithinAny } from "../quoted-span.ts";
|
|
12
7
|
import { withCutNounsJoined } from "../split-noun.ts";
|
|
13
|
-
import {
|
|
14
|
-
import { acronymsIn, isCapitalsNotSpelling } from "../capitals-with-small.ts";
|
|
8
|
+
import { acronymsIn, isCapitalsNotSpelling, isNameInCapitals } from "../capitals-with-small.ts";
|
|
15
9
|
import { isPartOfAddress } from "./address-word.ts";
|
|
16
10
|
import { isInCapitalsPassage } from "../capitals-passage.ts";
|
|
17
11
|
import { withoutCoinedNames } from "../coined-hyphen-name.ts";
|
|
@@ -19,10 +13,21 @@ import { wholeWordRuns, type WholeWordRun } from "../whole-word-runs.ts";
|
|
|
19
13
|
import { entriesForGenre } from "../lexicon-genres.ts";
|
|
20
14
|
import { asNounWhereNominal, documentNounKeys } from "../nominal-stem.ts";
|
|
21
15
|
import { isCompoundHead } from "../compound-head.ts";
|
|
22
|
-
import { leadingLabelSpans } from "../leading-label.ts";
|
|
23
16
|
import { voiceAt, voiceStarts } from "../voice-parts.ts";
|
|
24
|
-
import {
|
|
25
|
-
|
|
17
|
+
import {
|
|
18
|
+
isCopulaReadAsVerb,
|
|
19
|
+
isCutFromKatakana,
|
|
20
|
+
isNumeral,
|
|
21
|
+
isPieceOfKatakanaRun,
|
|
22
|
+
isTouching,
|
|
23
|
+
isWrittenOntoWord,
|
|
24
|
+
useOf,
|
|
25
|
+
type InContext,
|
|
26
|
+
type Uses,
|
|
27
|
+
} from "../word-use.ts";
|
|
28
|
+
import { titleCaseNameRuns } from "../title-case-name.ts";
|
|
29
|
+
import { withoutQuotedSpellings, type Quoted } from "../quoted-spelling.ts";
|
|
30
|
+
import { citedSpans, isOpenIn, namesOf, patternsOf, type IsOpen, type Names } from "./orthographic-variant-open.ts";
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
33
|
* A word found in the document: where it is, which sentence it is in, its key and spelling, how it is written when that differs, and
|
|
@@ -35,10 +40,12 @@ type Placed = KeyedWord & {
|
|
|
35
40
|
readonly compoundHead?: boolean;
|
|
36
41
|
/** Where a run of words ends (タイヤレバー). */
|
|
37
42
|
readonly end?: number;
|
|
43
|
+
/** Whether a Latin word stands in a name of capitalised words (the Interagency Group) or in a cited work. */
|
|
44
|
+
readonly quoted?: Quoted | undefined;
|
|
45
|
+
/** The name a word stands in, as written. */
|
|
46
|
+
readonly name?: string | undefined;
|
|
38
47
|
};
|
|
39
48
|
|
|
40
|
-
type IsOpen = (start: number, end: number) => boolean;
|
|
41
|
-
|
|
42
49
|
/** Parts of speech that carry a word of their own. Particles and endings are written one way by the grammar. */
|
|
43
50
|
const CONTENT = new Set(["NOUN", "VERB", "ADJ", "ADV", "PRON", "CCONJ", "DET"]);
|
|
44
51
|
const JAPANESE_WORD = /^[\p{Script=Han}々ぁ-ゖァ-ヺー]+$/u;
|
|
@@ -50,7 +57,6 @@ const MIN_LATIN_KEY = 3;
|
|
|
50
57
|
|
|
51
58
|
/** Lexicons: readings and spellings whose kanji and kana forms mean different things (成る and なる, 者 and もの), and adverbs hiragana-fukushi reads. */
|
|
52
59
|
const DISTINCT = "orthographic-variant-distinct";
|
|
53
|
-
const SPELLING_MENTION = "spelling-mention";
|
|
54
60
|
const FUKUSHI = "hiragana-fukushi";
|
|
55
61
|
/** Lexicon: idioms written as noun, particle and verb (気をつける). The verb there is compared apart from the verb on its own. */
|
|
56
62
|
const IDIOM = "orthographic-variant-idiom";
|
|
@@ -78,48 +84,12 @@ const PHRASE_SUFFIX = "orthographic-variant-phrase-suffix";
|
|
|
78
84
|
* spelling is not compared with that reading's kana. Read the other way (行っ as 行う), it is compared as usual.
|
|
79
85
|
*/
|
|
80
86
|
const TWO_READINGS = "orthographic-variant-two-readings";
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
* outside page's title (link-title.ts), placed in the source.
|
|
88
|
-
*/
|
|
89
|
-
type Names = {
|
|
90
|
-
readonly team: readonly string[];
|
|
91
|
-
readonly companyForms: readonly string[];
|
|
92
|
-
readonly linkTitles: readonly Span[];
|
|
93
|
-
/** Quotations in single quotation marks (an opinion quoting a statute), placed in the source: they can span sentences. */
|
|
94
|
-
readonly singleQuoted: readonly Span[];
|
|
95
|
-
/** Phrases that say a word is also spelled another way (とも書く): the bracketed words before them are spellings mentioned. */
|
|
96
|
-
readonly mentions: readonly string[];
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/** Spans placed in the source, placed in a sentence's text instead. */
|
|
100
|
-
const inSentence = (sentence: Sentence, spans: readonly Span[]): Span[] =>
|
|
101
|
-
spans.map((span) => ({ start: span.start - sentence.span.start, end: span.end - sentence.span.start }));
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Whether a stretch of the sentence is outside a quotation, the team's names, a company's name (関東珪曹硝子㈱), a reading in
|
|
105
|
-
* brackets (HTTP(えいちてぃーてぃーぴー)), a label opening the sentence ((答)), a spelling mentioned ((曇)とも書く) and a
|
|
106
|
-
* contact's name beside its phone number: the first three and the last keep their own spelling, a reading is not a spelling at
|
|
107
|
-
* all, a label is a fixed short form, and a mention is the subject.
|
|
108
|
-
*/
|
|
109
|
-
const isOpenIn = (sentence: Sentence, names: Names): IsOpen => {
|
|
110
|
-
const closed = [
|
|
111
|
-
...quotedSpans(sentence.text, QUOTATION_MARKS),
|
|
112
|
-
...furiganaSpans(sentence.text),
|
|
113
|
-
...contactEntrySpans(sentence.text),
|
|
114
|
-
...japaneseCompanyNameSpans(sentence.text, names.companyForms),
|
|
115
|
-
...inSentence(sentence, names.linkTitles),
|
|
116
|
-
...inSentence(sentence, names.singleQuoted),
|
|
117
|
-
...leadingLabelSpans(sentence.text),
|
|
118
|
-
...mentionedSpellingSpans(sentence.text, names.mentions),
|
|
119
|
-
];
|
|
120
|
-
const named = nameSpans(sentence.text, names.team);
|
|
121
|
-
return (start, end) => !isWithinAny(closed, { start, end }) && !touchesAny(named, start, end);
|
|
122
|
-
};
|
|
87
|
+
/** Lexicon: verbs whose て-form after を or で, with no verb after it, is 以て (決意をもって). Compared apart from the verb. */
|
|
88
|
+
const MEANS = "orthographic-variant-means";
|
|
89
|
+
/** Lexicon: the humble する (いたす), a helper after と (議題といたします) as it is written onto a noun. */
|
|
90
|
+
const LIGHT_VERB = "orthographic-variant-light-verb";
|
|
91
|
+
/** Lexicon shared with other rules: the small words inside a capitalised name (of, and). */
|
|
92
|
+
const NAME_JOINER = "name-joiner";
|
|
123
93
|
|
|
124
94
|
type Skips = Uses & {
|
|
125
95
|
readonly skip: ReadonlySet<string>;
|
|
@@ -142,6 +112,9 @@ const readsTwoWays = ({ token, following }: InContext, reading: string, twoReadi
|
|
|
142
112
|
return (twoReadings.get(token.surface) ?? withNext) === reading;
|
|
143
113
|
};
|
|
144
114
|
|
|
115
|
+
/** A piece the tokenizer cut from a word (ラオ|カイ, 誂ら|え), a pronoun's kana (私みたような) or a numeral (三十の三). */
|
|
116
|
+
const isNotAWordOfItsOwn = (word: InContext): boolean => isPieceOfKatakanaRun(word) || isNumeral(word.token) || isWrittenOntoWord(word);
|
|
117
|
+
|
|
145
118
|
const readingKeyOf = (word: InContext, skips: Skips): string | undefined => {
|
|
146
119
|
const { skip } = skips;
|
|
147
120
|
const { token } = word;
|
|
@@ -150,8 +123,7 @@ const readingKeyOf = (word: InContext, skips: Skips): string | undefined => {
|
|
|
150
123
|
if (isOutsideComparative(word, skips.comparative)) return undefined;
|
|
151
124
|
const reading = lemmaReading(token.surface, lemma, token.reading);
|
|
152
125
|
if (reading === undefined || [...reading].length < MIN_READING || skip.has(reading) || isCutFromKatakana(word) || isCopulaReadAsVerb(word)) return undefined;
|
|
153
|
-
if (readsTwoWays(word, reading, skips.twoReadings)) return undefined;
|
|
154
|
-
if (isNumeral(token) || isWrittenOntoWord(word)) return undefined;
|
|
126
|
+
if (readsTwoWays(word, reading, skips.twoReadings) || isNotAWordOfItsOwn(word)) return undefined;
|
|
155
127
|
return `${token.pos}|${useOf(word, skips)}|${reading}`;
|
|
156
128
|
};
|
|
157
129
|
|
|
@@ -196,8 +168,14 @@ const readingWords = (sentence: Sentence, isOpen: IsOpen, skips: Skips): Placed[
|
|
|
196
168
|
* Same reading is not yet same word: 書く and 描く are both カク. Spellings meet only when they keep the same kanji (引っ越し, 引越し)
|
|
197
169
|
* or one is all kana. A kana spelling joins the kanji one only when the reading has a single kanji spelling in the document;
|
|
198
170
|
* with two (橋 and 箸 beside はし) it cannot say which, and is left out. Official Japanese drops okurigana at the head of a compound
|
|
199
|
-
* (取扱事業者 beside 個人情報の取扱い), so where the document writes a word both ways, its compound heads are compared apart.
|
|
171
|
+
* (取扱事業者 beside 個人情報の取扱い), so where the document writes a word both ways, its compound heads are compared apart. A head of
|
|
172
|
+
* one kanji without its okurigana (曇 of 曇雨天, beside 曇り) is a Sino-Japanese element of the compound and is not compared at all.
|
|
200
173
|
*/
|
|
174
|
+
const ONE_KANJI = /^\p{Script=Han}$/u;
|
|
175
|
+
|
|
176
|
+
const isOneKanjiElement = (word: Placed, spellings: readonly string[]): boolean =>
|
|
177
|
+
word.compoundHead === true && ONE_KANJI.test(word.spelling) && dropsOkurigana(word.spelling, spellings);
|
|
178
|
+
|
|
201
179
|
const byKanji = (words: readonly Placed[]): Placed[] =>
|
|
202
180
|
[...groupBy(words, (word) => word.key).values()].flatMap((group) => {
|
|
203
181
|
const spellings = [...new Set(group.map((word) => word.spelling))];
|
|
@@ -206,7 +184,7 @@ const byKanji = (words: readonly Placed[]): Placed[] =>
|
|
|
206
184
|
const apart = spellings.some((spelling) => dropsOkurigana(spelling, spellings)) ? "|compound" : "";
|
|
207
185
|
return group.flatMap((word): Placed[] => {
|
|
208
186
|
const own = skeletonOf(word.spelling);
|
|
209
|
-
if (own === "" && skeletons.length > 1) return [];
|
|
187
|
+
if ((own === "" && skeletons.length > 1) || isOneKanjiElement(word, spellings)) return [];
|
|
210
188
|
const use = word.compoundHead === true ? apart : "";
|
|
211
189
|
return [{ ...word, key: `${word.key}|${own === "" ? (skeletons[0] ?? "") : own}${use}` }];
|
|
212
190
|
});
|
|
@@ -259,6 +237,12 @@ const katakanaRunWords = (sentence: Sentence, isOpen: IsOpen): Placed[] =>
|
|
|
259
237
|
/** Whether a run holds a place another key already points at: the word inside it is said, not the run around it. */
|
|
260
238
|
const coversOffset = (run: Placed, offset: number): boolean => offset >= run.offset && offset < (run.end ?? run.offset + 1);
|
|
261
239
|
|
|
240
|
+
const HASHTAG_MARK = "#";
|
|
241
|
+
const WORD_CHARACTER = /[\p{L}\p{N}_]/u;
|
|
242
|
+
|
|
243
|
+
/** A word written as a hashtag (#vimconf): spelled as the service matches it, like an address. */
|
|
244
|
+
const isHashtag = (text: string, start: number): boolean => text.charAt(start - 1) === HASHTAG_MARK && !WORD_CHARACTER.test(text.charAt(start - 2));
|
|
245
|
+
|
|
262
246
|
const LATIN_WORD = /[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*/gu;
|
|
263
247
|
const LOWER = /\p{Ll}/u;
|
|
264
248
|
|
|
@@ -277,15 +261,25 @@ const latinSpelling = (word: string): string =>
|
|
|
277
261
|
* emphasis or an acronym, not a spelling of the word, and is left out; so are a name in capitals with an ending (SENDs) and
|
|
278
262
|
* the letters of an acronym of the sentence picked out (CLImatology for CLIPER).
|
|
279
263
|
*/
|
|
280
|
-
const latinWords = (sentence
|
|
281
|
-
const
|
|
282
|
-
|
|
264
|
+
const latinWords = ({ sentence, isOpen, cited }: Place, skip: ReadonlySet<string>, joiners: readonly string[]): Placed[] => {
|
|
265
|
+
const { text } = sentence;
|
|
266
|
+
const acronyms = acronymsIn(text);
|
|
267
|
+
const names = titleCaseNameRuns(text, joiners);
|
|
268
|
+
const quotedAt = (start: number, end: number): Pick<Placed, "quoted" | "name"> => {
|
|
269
|
+
if (isWithinAny(cited, { start, end })) return { quoted: "cited" };
|
|
270
|
+
const run = names.find(({ name }) => name.start <= start && end <= name.end);
|
|
271
|
+
if (run === undefined) return {};
|
|
272
|
+
const name = text.slice(run.name.start, run.name.end);
|
|
273
|
+
return run.quoted !== undefined && isWithinAny([run.quoted], { start, end }) ? { quoted: "name", name } : { name };
|
|
274
|
+
};
|
|
275
|
+
return [...text.matchAll(LATIN_WORD)].flatMap((match): Placed[] => {
|
|
283
276
|
const word = match[0];
|
|
284
277
|
const plain = word.toLowerCase().replaceAll("-", "");
|
|
285
|
-
const end = match.index + word.length;
|
|
278
|
+
const [start, end] = [match.index, match.index + word.length];
|
|
286
279
|
if (plain.length < MIN_LATIN_KEY || !LOWER.test(word) || isCapitalsNotSpelling(word, acronyms) || skip.has(word.toLowerCase())) return [];
|
|
287
|
-
if (isPartOfAddress(
|
|
288
|
-
|
|
280
|
+
if (isPartOfAddress(text, start, end) || isHashtag(text, start) || !isOpen(start, end) || isInCapitalsPassage(text, start, end)) return [];
|
|
281
|
+
if (isNameInCapitals(text, start, word)) return [];
|
|
282
|
+
return [{ key: `latin|${plain}`, spelling: latinSpelling(word), shown: word, sentence, offset: sentence.span.start + start, ...quotedAt(start, end) }];
|
|
289
283
|
});
|
|
290
284
|
};
|
|
291
285
|
|
|
@@ -305,7 +299,11 @@ const findingOf = (words: readonly Placed[], odd: OddSpelling<Placed>): Finding
|
|
|
305
299
|
/** A cell that is one Latin word in lower case (openapi, contentType): a field name or a value, spelled by the data and not by the writer. */
|
|
306
300
|
const DATA_KEY_CELL = /^\p{Ll}[A-Za-z0-9]*$/u;
|
|
307
301
|
|
|
308
|
-
|
|
302
|
+
/** A sentence or a table cell, where its words are the writer's, whether its Latin words are read, and its cited works. */
|
|
303
|
+
type Place = { readonly sentence: Sentence; readonly isOpen: IsOpen; readonly readsLatin: boolean; readonly cited: readonly Span[] };
|
|
304
|
+
|
|
305
|
+
/** What the words of a document are read with besides the lexicons of uses: the dictionary, and the small words inside a name (of). */
|
|
306
|
+
type Reading = { readonly isWord: (word: string) => boolean; readonly nameJoiners: readonly string[] };
|
|
309
307
|
|
|
310
308
|
/** A link's brackets and where it goes (`[`, `](#contentType)`, `][ref]`). The prose hides them outside tables; a cell keeps the Markdown as written. */
|
|
311
309
|
const LINK_CHROME = /\]\([^)]*\)|\]\[[^\]]*\]|\[/gu;
|
|
@@ -316,16 +314,19 @@ const withoutLinkChrome = (text: string): string => text.replaceAll(LINK_CHROME,
|
|
|
316
314
|
const cellPlace = (cell: TableCell, names: Names): Place => {
|
|
317
315
|
const text = withoutLinkChrome(cell.text);
|
|
318
316
|
const sentence: Sentence = { span: { start: cell.start, end: cell.end }, text, tokens: cell.tokens ?? [] };
|
|
319
|
-
return { sentence, isOpen: isOpenIn(sentence, names), readsLatin: !DATA_KEY_CELL.test(text.trim()) };
|
|
317
|
+
return { sentence, isOpen: isOpenIn(sentence, names), readsLatin: !DATA_KEY_CELL.test(text.trim()), cited: citedSpans(sentence, names) };
|
|
320
318
|
};
|
|
321
319
|
|
|
322
320
|
/** The odd spellings among places that speak in one voice. */
|
|
323
|
-
const findingsIn = (placed: readonly Place[], skips: Skips, isWord
|
|
321
|
+
const findingsIn = (placed: readonly Place[], skips: Skips, { isWord, nameJoiners }: Reading, limit: number): Finding[] => {
|
|
324
322
|
const reading = byKanji(placed.flatMap(({ sentence, isOpen }) => readingWords(withCutNounsJoined(sentence, skips.nouns), isOpen, skips)));
|
|
325
323
|
const katakana = placed.flatMap(({ sentence, isOpen }) => katakanaWords(sentence, isOpen));
|
|
326
324
|
const runs = placed.flatMap(({ sentence, isOpen }) => katakanaRunWords(sentence, isOpen));
|
|
327
|
-
const latin =
|
|
328
|
-
|
|
325
|
+
const latin = withoutQuotedSpellings(
|
|
326
|
+
withoutCoinedNames(
|
|
327
|
+
placed.flatMap((place) => (place.readsLatin ? latinWords(place, skips.skip, nameJoiners) : [])),
|
|
328
|
+
isWord,
|
|
329
|
+
),
|
|
329
330
|
isWord,
|
|
330
331
|
);
|
|
331
332
|
const odd = [reading, katakana, latin].flatMap((words) => oddSpellings(words, limit));
|
|
@@ -341,15 +342,9 @@ const findingsIn = (placed: readonly Place[], skips: Skips, isWord: (word: strin
|
|
|
341
342
|
* document writes less is pointed at. No way is called right; limit is the largest share, in percent, the minority may have.
|
|
342
343
|
*/
|
|
343
344
|
export const orthographicVariant: Detector = (doc, options): Finding[] => {
|
|
344
|
-
const names
|
|
345
|
-
team: doc.names ?? [],
|
|
346
|
-
companyForms: (doc.lexicons["company-form"] ?? []).map((entry) => entry.pattern),
|
|
347
|
-
linkTitles: externalLinkTitleSpans(doc.source, doc.links),
|
|
348
|
-
singleQuoted: singleQuotedSpans(doc.source),
|
|
349
|
-
mentions: (doc.lexicons[SPELLING_MENTION] ?? []).map((entry) => entry.pattern),
|
|
350
|
-
};
|
|
345
|
+
const names = namesOf(doc, options.genre);
|
|
351
346
|
const placed: Place[] = [
|
|
352
|
-
...doc.sentences.map((sentence) => ({ sentence, isOpen: isOpenIn(sentence, names), readsLatin: true })),
|
|
347
|
+
...doc.sentences.map((sentence) => ({ sentence, isOpen: isOpenIn(sentence, names), readsLatin: true, cited: citedSpans(sentence, names) })),
|
|
353
348
|
...(doc.tableCells?.() ?? []).map((cell) => cellPlace(cell, names)),
|
|
354
349
|
];
|
|
355
350
|
const phraseSuffixes = new Set(patternsOf(doc, PHRASE_SUFFIX, options.genre));
|
|
@@ -359,6 +354,8 @@ export const orthographicVariant: Detector = (doc, options): Finding[] => {
|
|
|
359
354
|
conjunctions: new Set(patternsOf(doc, CONJUNCTION, options.genre)),
|
|
360
355
|
judging: new Set(patternsOf(doc, JUDGING, options.genre)),
|
|
361
356
|
senses: new Set(patternsOf(doc, SENSE, options.genre)),
|
|
357
|
+
means: new Set(patternsOf(doc, MEANS, options.genre)),
|
|
358
|
+
lightVerbs: new Set(patternsOf(doc, LIGHT_VERB, options.genre)),
|
|
362
359
|
comparative: new Set(patternsOf(doc, COMPARATIVE, options.genre)),
|
|
363
360
|
wholeWords: new Map((doc.lexicons[WHOLE_WORD] ?? []).map((entry) => [entry.pattern, entry.group ?? entry.pattern])),
|
|
364
361
|
phraseSuffixes,
|
|
@@ -369,11 +366,14 @@ export const orthographicVariant: Detector = (doc, options): Finding[] => {
|
|
|
369
366
|
),
|
|
370
367
|
};
|
|
371
368
|
const dictionary = doc.dictionary?.();
|
|
372
|
-
const
|
|
369
|
+
const reading: Reading = {
|
|
370
|
+
isWord: (word: string): boolean => dictionary?.has(word) ?? true,
|
|
371
|
+
nameJoiners: (doc.lexicons[NAME_JOINER] ?? []).map((entry) => entry.pattern),
|
|
372
|
+
};
|
|
373
373
|
const starts = voiceStarts(
|
|
374
374
|
doc.sentences,
|
|
375
375
|
patternsOf(doc, VOICE, options.genre).map((pattern) => new RegExp(pattern, "u")),
|
|
376
376
|
);
|
|
377
377
|
const voices = groupBy(placed, ({ sentence }) => String(voiceAt(starts, sentence.span.start)));
|
|
378
|
-
return [...voices.values()].flatMap((voice) => findingsIn(voice, skips,
|
|
378
|
+
return [...voices.values()].flatMap((voice) => findingsIn(voice, skips, reading, options.limit));
|
|
379
379
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Detector, Finding, Lexicon, ProseDocument, Sentence } from "../plugin.ts";
|
|
2
|
-
import { entryEnds, entryIn } from "./lexicon-match.ts";
|
|
1
|
+
import type { Detector, Finding, Lexicon, LexiconEntry, ProseDocument, Sentence, Token } from "../plugin.ts";
|
|
2
|
+
import { comparableWords, entryEnds, entryIn, entryRanges, type TokenRange } from "./lexicon-match.ts";
|
|
3
3
|
import { wordsOf } from "./structure.ts";
|
|
4
4
|
import { MIN_DOCUMENT_LENGTH } from "./signals.ts";
|
|
5
5
|
|
|
@@ -13,14 +13,115 @@ const MIN_PHRASES = 2;
|
|
|
13
13
|
/** 一つの文の、大きく括る言い方。使った回数だけ並ぶ。 */
|
|
14
14
|
export type SweepingSentence = { readonly sentence: Sentence; readonly phrases: readonly string[] };
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/** 語彙表の組。general は常に、subject は動詞の主語のときだけ数え、who は誰のことかが近くで決まっていれば数えない。残りはその決まり方を言う語。 */
|
|
17
|
+
type Vocabulary = {
|
|
18
|
+
readonly general: Lexicon;
|
|
19
|
+
readonly subject: Lexicon;
|
|
20
|
+
readonly who: Lexicon;
|
|
21
|
+
readonly groupNouns: Lexicon;
|
|
22
|
+
readonly addressees: Lexicon;
|
|
23
|
+
readonly rightAfter: Lexicon;
|
|
24
|
+
readonly presentForms: Lexicon;
|
|
25
|
+
readonly relatives: Lexicon;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const inGroup = (lexicon: Lexicon, group: string): Lexicon => lexicon.filter((entry) => entry.group === group);
|
|
29
|
+
|
|
30
|
+
const vocabularyOf = (lexicon: Lexicon): Vocabulary => ({
|
|
31
|
+
general: inGroup(lexicon, "general"),
|
|
32
|
+
subject: inGroup(lexicon, "subject"),
|
|
33
|
+
who: inGroup(lexicon, "who"),
|
|
34
|
+
groupNouns: inGroup(lexicon, "group-noun"),
|
|
35
|
+
addressees: inGroup(lexicon, "addressee"),
|
|
36
|
+
rightAfter: inGroup(lexicon, "right-after"),
|
|
37
|
+
presentForms: inGroup(lexicon, "present-form"),
|
|
38
|
+
relatives: inGroup(lexicon, "relative"),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const NOMINAL = new Set(["NOUN", "PROPN"]);
|
|
42
|
+
const VERBAL = new Set(["VERB", "AUX", "PART"]);
|
|
43
|
+
|
|
44
|
+
const isNominal = (token: Token | undefined): boolean => NOMINAL.has(token?.pos ?? "");
|
|
45
|
+
const isWord = (token: Token | undefined, entries: Lexicon): boolean =>
|
|
46
|
+
token !== undefined && entries.some((entry) => comparableWords(entry.pattern) === comparableWords(token.surface));
|
|
47
|
+
|
|
48
|
+
/** 後ろの名詞を飾る位置(family photos)。動詞とも読める語(family shares)は、tagger が動詞を名詞と読み違えたことがあるので数えない。 */
|
|
49
|
+
const modifiesNext = (next: Token | undefined): boolean => isNominal(next) && next?.features?.["AlsoVerb"] !== "Yes";
|
|
50
|
+
|
|
51
|
+
/** 人の集まりを名指す名詞が、句の中心に立つ(the team、family members)。後ろの名詞を飾るだけ(family photos)なら名指していない。 */
|
|
52
|
+
const headsPhrase = (tokens: readonly Token[], range: TokenRange): boolean => isNominal(tokens[range.start]) && !modifiesNext(tokens[range.end]);
|
|
53
|
+
|
|
54
|
+
/** 文が人の集まりを名指す(the team、our family、all of you)。 */
|
|
55
|
+
const namesGroup = (sentence: Sentence | undefined, vocabulary: Vocabulary): boolean => {
|
|
56
|
+
if (sentence === undefined) return false;
|
|
57
|
+
const tokens = sentence.tokens ?? [];
|
|
58
|
+
const named = vocabulary.groupNouns.some((entry) => entryRanges(sentence, entry).some((range) => headsPhrase(tokens, range)));
|
|
59
|
+
return named || vocabulary.addressees.some((entry) => entryIn(sentence, entry));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** 規則どおりの三人称単数現在(loves、watches、tries)。 */
|
|
63
|
+
const isThirdPersonPresent = (surface: string, lemma: string): boolean => [`${lemma}s`, `${lemma}es`, `${lemma.replace(/y$/u, "")}ies`].includes(surface);
|
|
64
|
+
|
|
65
|
+
/** 過去形の動詞(caught、jumped、was)。原形・現在形・-ing 形は過去でない。 */
|
|
66
|
+
const isPastVerb = (token: Token | undefined, vocabulary: Vocabulary): boolean => {
|
|
67
|
+
if (token?.pos !== "VERB" || token.lemma === undefined || token.features?.["VerbForm"] === "Ger") return false;
|
|
68
|
+
const surface = token.surface.toLowerCase();
|
|
69
|
+
const lemma = token.lemma.toLowerCase();
|
|
70
|
+
return surface !== lemma && !isThirdPersonPresent(surface, lemma) && !isWord(token, vocabulary.presentForms);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** 括る言い方のすぐ後の動詞。副詞と関係代名詞(everyone who quickly jumped)は飛ばす。動詞の前に別の語があれば無い。 */
|
|
74
|
+
const verbAfter = (tokens: readonly Token[], from: number, vocabulary: Vocabulary): Token | undefined => {
|
|
75
|
+
const rest = tokens.slice(from);
|
|
76
|
+
const verb = rest.find((token) => token.pos !== "ADV" && !isWord(token, vocabulary.relatives));
|
|
77
|
+
return VERBAL.has(verb?.pos ?? "") ? verb : undefined;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const UNFINISHED = new Set(["Part", "Ger"]);
|
|
81
|
+
|
|
82
|
+
/** 主語として動詞が続く(many people keep)。名詞の前の飾り(the many people connected)や目的語(see many people on the trail)は人の一般論でない。 */
|
|
83
|
+
const isSubject = (tokens: readonly Token[], range: TokenRange, vocabulary: Vocabulary): boolean => {
|
|
84
|
+
const verb = verbAfter(tokens, range.end, vocabulary);
|
|
85
|
+
return verb !== undefined && verb.pos !== "PART" && !UNFINISHED.has(verb.features?.["VerbForm"] ?? "");
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** 主語として使った subject の組の語の数。品詞が無ければ位置を言えないので、すべて数える。 */
|
|
89
|
+
const subjectUses = (sentence: Sentence, entry: LexiconEntry, vocabulary: Vocabulary): number => {
|
|
90
|
+
if (sentence.tokens === undefined || entry.tokens === undefined) return entryEnds(sentence, entry).length;
|
|
91
|
+
const tokens = sentence.tokens;
|
|
92
|
+
return entryRanges(sentence, entry).filter((range) => isSubject(tokens, range, vocabulary)).length;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** 誰のことかが決まっている: すぐ後の語(everyone here)、過去形の動詞(nobody caught it、一度の出来事)、この文か前の文の集まり。 */
|
|
96
|
+
const isBounded = (sentence: Sentence, previous: Sentence | undefined, range: TokenRange, vocabulary: Vocabulary): boolean => {
|
|
97
|
+
const tokens = sentence.tokens ?? [];
|
|
98
|
+
if (isWord(tokens[range.end], vocabulary.rightAfter)) return true;
|
|
99
|
+
if (isPastVerb(verbAfter(tokens, range.end, vocabulary), vocabulary)) return true;
|
|
100
|
+
return namesGroup(sentence, vocabulary) || namesGroup(previous, vocabulary);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** who の組の語の、誰のことかが決まっていない出現。品詞が無ければ位置を言えないので、すべて数える。 */
|
|
104
|
+
const openUses = (sentence: Sentence, previous: Sentence | undefined, entry: LexiconEntry, vocabulary: Vocabulary): number => {
|
|
105
|
+
if (sentence.tokens === undefined || entry.tokens === undefined) return entryEnds(sentence, entry).length;
|
|
106
|
+
return entryRanges(sentence, entry).filter((range) => !isBounded(sentence, previous, range, vocabulary)).length;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const repeated = (pattern: string, times: number): string[] => Array.from({ length: times }, () => pattern);
|
|
110
|
+
|
|
111
|
+
const usesIn = (sentence: Sentence, previous: Sentence | undefined, vocabulary: Vocabulary): string[] => [
|
|
112
|
+
...vocabulary.general.flatMap((entry) => repeated(entry.pattern, entryEnds(sentence, entry).length)),
|
|
113
|
+
...vocabulary.subject.flatMap((entry) => repeated(entry.pattern, subjectUses(sentence, entry, vocabulary))),
|
|
114
|
+
...vocabulary.who.flatMap((entry) => repeated(entry.pattern, openUses(sentence, previous, entry, vocabulary))),
|
|
115
|
+
];
|
|
17
116
|
|
|
18
117
|
/** 大きく括る言い方を使った文。weasel-word が言う文(most people agree)は、同じ文を二度言わないので数えない。 */
|
|
19
118
|
export const sweepingSentences = (doc: ProseDocument, lexicon: Lexicon): SweepingSentence[] => {
|
|
20
119
|
const weasel = doc.lexicons["weasel-word"] ?? [];
|
|
120
|
+
const vocabulary = vocabularyOf(lexicon);
|
|
21
121
|
return doc.sentences
|
|
22
|
-
.
|
|
23
|
-
.
|
|
122
|
+
.map((sentence, index) => ({ sentence, previous: doc.sentences[index - 1] }))
|
|
123
|
+
.filter(({ sentence }) => sentence.embeddedLanguage === undefined && !weasel.some((entry) => entryIn(sentence, entry)))
|
|
124
|
+
.map(({ sentence, previous }) => ({ sentence, phrases: usesIn(sentence, previous, vocabulary) }))
|
|
24
125
|
.filter((found) => found.phrases.length > 0);
|
|
25
126
|
};
|
|
26
127
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Detector, Finding, Lexicon, Token } from "../plugin.ts";
|
|
2
2
|
import {
|
|
3
|
+
commaBefore,
|
|
3
4
|
contentCount,
|
|
4
5
|
exampleEnd,
|
|
5
6
|
firstAt,
|
|
@@ -11,6 +12,8 @@ import {
|
|
|
11
12
|
hasListConjunction,
|
|
12
13
|
hasParticiple,
|
|
13
14
|
hasVerb,
|
|
15
|
+
endsWithPreposition,
|
|
16
|
+
hasNonAdverbContent,
|
|
14
17
|
isClause,
|
|
15
18
|
isModifiedNoun,
|
|
16
19
|
isModifier,
|
|
@@ -19,11 +22,11 @@ import {
|
|
|
19
22
|
itemAfter,
|
|
20
23
|
lastContent,
|
|
21
24
|
lastNoun,
|
|
22
|
-
leadShape,
|
|
23
25
|
openingKind,
|
|
24
26
|
openingOf,
|
|
25
27
|
participleOpening,
|
|
26
28
|
shapeOf,
|
|
29
|
+
shapeOfHead,
|
|
27
30
|
} from "./list-item.ts";
|
|
28
31
|
import { listReader, type ItemList } from "./list-items.ts";
|
|
29
32
|
import { APPOSITIVE_ANCHOR, isListConjunction, listSentenceOf, NOMINAL, VERBAL, type ItemScope, type ListWords } from "./list-sentence.ts";
|
|
@@ -50,11 +53,12 @@ import { followsPostcode } from "./postcode-end.ts";
|
|
|
50
53
|
import { withoutCoordinateAdjective } from "./coordinate-adjective.ts";
|
|
51
54
|
import { dashBreaks } from "./dash-break.ts";
|
|
52
55
|
import { namesDivision, qualifiesPrevious } from "./list-comma-aside.ts";
|
|
56
|
+
import { inExcerpt } from "./quoted-excerpt.ts";
|
|
57
|
+
import { listContinues, walker, type Walk } from "./list-run.ts";
|
|
58
|
+
import { joinsUnfinished, repeatsConjunction } from "./list-joint.ts";
|
|
53
59
|
|
|
54
60
|
const EMPTY: TokenRange = { start: 0, end: 0 };
|
|
55
61
|
|
|
56
|
-
const commaBefore = (scope: ItemScope, at: number): boolean => scope.sentence.tokens[at - 1]?.surface === ",";
|
|
57
|
-
|
|
58
62
|
/**
|
|
59
63
|
* 導入の句(After the review, / If it fails, / Finally, / To test it, / Based on the review,)は並列の項目ではない。
|
|
60
64
|
* 節の最初の項目が前置詞・接続詞・副詞・to・過去分詞で始まり、次の項目と頭の形が違えば外す。
|
|
@@ -66,10 +70,14 @@ const LEAD_POS = new Set(["ADP", "SCONJ", "ADV", "PART"]);
|
|
|
66
70
|
|
|
67
71
|
const isSequenceWord = (scope: ItemScope, token: Token | undefined): boolean => scope.sentence.words.sequence?.has(token?.surface.toLowerCase() ?? "") ?? false;
|
|
68
72
|
|
|
73
|
+
/** 順番の語か、前の文とつなぐ語(However,)。どちらも文頭の導入で、並びの項目ではない。 */
|
|
74
|
+
const isOpenerWord = (scope: ItemScope, token: Token | undefined): boolean =>
|
|
75
|
+
isSequenceWord(scope, token) || (scope.sentence.words.connective?.has(token?.surface.toLowerCase() ?? "") ?? false);
|
|
76
|
+
|
|
69
77
|
const SENTENCE_MARKS = new Set(["PUNCT", "SYM"]);
|
|
70
78
|
|
|
71
79
|
/**
|
|
72
|
-
*
|
|
80
|
+
* 順番の語やつなぎの語と読点(First, / Next, / However,)で始まる最初の項目から、その語を外した並び。解析器は First を形容詞と読み、読点で項目を切らないことがある。
|
|
73
81
|
* 文頭の語だけ。文の途中の first は項目のことがある(We support first, fallback, and legacy modes)。
|
|
74
82
|
* 次の項目も順番の語なら、順番の語の並び(first, second and third)なので外さない。
|
|
75
83
|
*/
|
|
@@ -80,7 +88,7 @@ const withoutSequenceWord = (view: View): View | undefined => {
|
|
|
80
88
|
const at = firstAt(scope, "open", first.item);
|
|
81
89
|
const { tokens } = scope.sentence;
|
|
82
90
|
const opensSentence = tokens.slice(0, at).every((token) => SENTENCE_MARKS.has(token.pos));
|
|
83
|
-
if (!opensSentence || !
|
|
91
|
+
if (!opensSentence || !isOpenerWord(scope, tokens[at]) || tokens[at + 1]?.surface !== "," || isSequenceWord(scope, openingOf(scope, second.item)))
|
|
84
92
|
return undefined;
|
|
85
93
|
const rest = { start: at + 2, end: first.item.end };
|
|
86
94
|
return hasContent(scope, rest) ? { ...withoutFirst(view), pre: rest } : withoutFirst(view);
|
|
@@ -110,7 +118,30 @@ const afterClosedList = (view: View): View => {
|
|
|
110
118
|
const body = { start: conjunction === -1 ? closing.item.start : conjunction + 1, end: closing.item.end };
|
|
111
119
|
const head = firstAt(scope, "content", body);
|
|
112
120
|
const rest = VERBAL.has(scope.sentence.tokens[head]?.pos ?? "") ? { start: head + 1, end: body.end } : body;
|
|
113
|
-
return
|
|
121
|
+
return isItem(scope, rest) ? { ...after(view, closing), pre: rest } : withoutLead(after(view, closing));
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 項目として立つ切れ端か。副詞だけ(does not の not)や、目的語を後ろに残した前置詞で終わるもの(or impose conditions upon,
|
|
126
|
+
* certain transmittals / directly related to, and necessary for, the licensing)は、読点の後ろへ続く句の頭で、項目ではない。
|
|
127
|
+
*/
|
|
128
|
+
const isItem = (scope: ItemScope, rest: TokenRange): boolean => hasNonAdverbContent(scope, rest) && !endsWithPreposition(scope, rest);
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 節だけをつなぐ接続詞(but / yet)で始まる項目があれば、そこまでは節の並びで、項目の並びは後ろから
|
|
132
|
+
* (If you need help with something, but it's not a priority right now, add it to the backlog and bring it up は並びではない)。
|
|
133
|
+
* 節の最後の語が次の項目の頭と同じ品詞なら、その語が並びの最初の項目(but other teams may use JIRA, waffle.io, or another
|
|
134
|
+
* system / but your system for issuing, receiving and storing invoices)なので、切らない。目的語を待つ語で終われば節ではない
|
|
135
|
+
* (including, but not limited to, BB, Pellet and Paint Guns)。
|
|
136
|
+
*/
|
|
137
|
+
const afterClauseTurn = (view: View, afterItem: TokenRange): View => {
|
|
138
|
+
const turn = findLast(view, "turn");
|
|
139
|
+
if (turn === undefined) return view;
|
|
140
|
+
const { scope } = view.list;
|
|
141
|
+
const rest = after(view, turn);
|
|
142
|
+
const next = firstOf(rest)?.item ?? afterItem;
|
|
143
|
+
const carriesFirstItem = shapeOfHead(lastContent(scope, turn.item)) === shapeOf(scope, next);
|
|
144
|
+
return carriesFirstItem || endsWithPreposition(scope, turn.item) ? view : rest;
|
|
114
145
|
};
|
|
115
146
|
|
|
116
147
|
const opensAsNoun = (scope: ItemScope, item: TokenRange): boolean => {
|
|
@@ -118,6 +149,9 @@ const opensAsNoun = (scope: ItemScope, item: TokenRange): boolean => {
|
|
|
118
149
|
return opening !== undefined && (opening.pos === "DET" || NOMINAL.has(opening.pos));
|
|
119
150
|
};
|
|
120
151
|
|
|
152
|
+
/** 項目が読点で閉じず、節の終わり(文の終わりか ; : —)まで続く。 */
|
|
153
|
+
const runsToClauseEnd = (scope: ItemScope, item: TokenRange): boolean => scope.sentence.tokens[item.end]?.surface !== ",";
|
|
154
|
+
|
|
121
155
|
const opensAsPredicate = (scope: ItemScope, item: TokenRange): boolean => {
|
|
122
156
|
const opening = openingOf(scope, item);
|
|
123
157
|
return opening !== undefined && VERBAL.has(opening.pos) && !isParticiple(opening);
|
|
@@ -129,13 +163,19 @@ const opensAsPredicate = (scope: ItemScope, item: TokenRange): boolean => {
|
|
|
129
163
|
* 並びがあるなら句の後ろから(are excluded and are not authorized は 2 つ)。例の中の分詞(connected)は名詞にかかる語で、
|
|
130
164
|
* 述語と同じ形と読まない。句の前は並びの最初の項目で、名詞の句(主語)。動詞で始まれば述語の並びの項目
|
|
131
165
|
* (Review backups, such as daily snapshots, update indexes and archive logs は 3 つ)。
|
|
166
|
+
* 解析器が述語の動詞を名詞と読んでも(Financial institutions, including CDFIs, support housing through lending and investment の
|
|
167
|
+
* support)、動詞の無い主語のあとの句で、句の後ろの項目が前置詞を連れ、and / or の後ろが読点で閉じずに節の終わりまで続けば、
|
|
168
|
+
* and / or は述語の中で前置詞の目的語を結ぶ。句の中の並びなら、述語の前で句を閉じる読点がある。主語だけの断片の終わりの例の並び
|
|
169
|
+
* (Full details of the parameters, including meaning, data type and any other constraints.)は前置詞を連れないので並びのまま。
|
|
132
170
|
*/
|
|
133
|
-
const isAsideBeforePredicate = (view: View, phrase: Member, examples: TokenRange): boolean => {
|
|
171
|
+
const isAsideBeforePredicate = (view: View, phrase: Member, examples: TokenRange, afterItem: TokenRange): boolean => {
|
|
134
172
|
const { scope } = view.list;
|
|
135
173
|
const [subject, next] = [firstOf(view), firstOf(after(view, phrase))];
|
|
136
174
|
if (subject === undefined || next === undefined || subject.j !== phrase.j - 1) return false;
|
|
137
175
|
const opensPhrase = (scope.sentence.exampleEnds[phrase.item.start]?.length ?? 0) > 0;
|
|
138
|
-
|
|
176
|
+
const objectsInPredicate = !hasVerb(scope, subject.item) && hasAdposition(scope, next.item) && runsToClauseEnd(scope, afterItem);
|
|
177
|
+
const predicate = opensAsPredicate(scope, next.item) || objectsInPredicate;
|
|
178
|
+
return opensPhrase && opensAsNoun(scope, subject.item) && opensAsNoun(scope, examples) && predicate;
|
|
139
179
|
};
|
|
140
180
|
|
|
141
181
|
/**
|
|
@@ -144,14 +184,14 @@ const isAsideBeforePredicate = (view: View, phrase: Member, examples: TokenRange
|
|
|
144
184
|
* adopting ... / (e.g., by location, contract type, or contract preference))。句の中に and / or があれば句はもう閉じていて、
|
|
145
185
|
* 句ごと 1 つの項目(apples, oranges such as navels and mandarins, and pears)。
|
|
146
186
|
*/
|
|
147
|
-
const fromExample = (view: View): View => {
|
|
187
|
+
const fromExample = (view: View, afterItem: TokenRange): View => {
|
|
148
188
|
const phrase = findLast(view, "example");
|
|
149
189
|
if (phrase === undefined) return view;
|
|
150
190
|
const { scope } = view.list;
|
|
151
191
|
const examples = { start: exampleEnd(scope, phrase.item), end: phrase.item.end };
|
|
152
192
|
if (hasListConjunction(scope, examples)) return view;
|
|
153
193
|
const rest = after(view, phrase);
|
|
154
|
-
if (isAsideBeforePredicate(view, phrase, examples)) return rest;
|
|
194
|
+
if (isAsideBeforePredicate(view, phrase, examples, afterItem)) return rest;
|
|
155
195
|
const inPhrase = contentOnlyWith(rest, examples);
|
|
156
196
|
return sameShapes(inPhrase) ? inPhrase : view;
|
|
157
197
|
};
|
|
@@ -209,18 +249,6 @@ const isAppositive = (scope: ItemScope, at: number, view: View, afterItem: Token
|
|
|
209
249
|
return closed && APPOSITIVE_ANCHOR.has(lastContent(scope, anchor.item)?.pos ?? "") && !hasVerb(scope, head.item) && !hasVerb(scope, afterItem);
|
|
210
250
|
};
|
|
211
251
|
|
|
212
|
-
/**
|
|
213
|
-
* and の後ろの項目に読点と、同じ形の項目を連れた and / or が続くなら、この and は項目の中にある(searches and seizures, and
|
|
214
|
-
* the Eighth's ban)。頭の形か、節かどうかが違えば別の節をつなぐ and で、この and までが並び(apples, pears and plums, and went home / and figs fell)。
|
|
215
|
-
*/
|
|
216
|
-
const listContinues = (scope: ItemScope, afterItem: TokenRange): boolean => {
|
|
217
|
-
const next = afterItem.end;
|
|
218
|
-
if (scope.sentence.tokens[next]?.surface !== "," || !isListConjunction(scope.sentence.tokens[next + 1])) return false;
|
|
219
|
-
const following = itemAfter(scope, next + 1);
|
|
220
|
-
const shape = leadShape(scope, following);
|
|
221
|
-
return shape !== undefined && shape === leadShape(scope, afterItem) && isClause(scope, following) === isClause(scope, afterItem);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
252
|
/**
|
|
225
253
|
* 語のあとが複数形の名詞句なら、語は名詞にかかる語で、2 つはもう揃っている(the renderer in both modes and the exporter)。
|
|
226
254
|
* and の後ろも冠詞の無い複数形の名詞句なら、2 つを結ぶ語(both project goals and business goals)。
|
|
@@ -280,7 +308,11 @@ const joinsObjects = (scope: ItemScope, at: number, view: View, afterItem: Token
|
|
|
280
308
|
|
|
281
309
|
/** and / or が並びの最後の継ぎ目ではなく、最後の項目の中にある。 */
|
|
282
310
|
const insideLastItem = (scope: ItemScope, at: number, view: View, afterItem: TokenRange): boolean =>
|
|
283
|
-
pairsInLastItem(scope, at, view, afterItem) ||
|
|
311
|
+
pairsInLastItem(scope, at, view, afterItem) ||
|
|
312
|
+
sharesNoun(scope, at, view, afterItem) ||
|
|
313
|
+
joinsObjects(scope, at, view, afterItem) ||
|
|
314
|
+
joinsUnfinished(scope, at, view, afterItem) ||
|
|
315
|
+
repeatsConjunction(scope, at, view, afterItem);
|
|
284
316
|
|
|
285
317
|
/**
|
|
286
318
|
* 節を並べるなら、どの項目も節。Additionally, others can learn, and the mistake is rarer. の Additionally は項目ではなく、
|
|
@@ -309,12 +341,13 @@ const opensContrast = (scope: ItemScope, item: TokenRange): boolean => CONTRAST.
|
|
|
309
341
|
* (We tested it, and the team shipped it.)は、Oxford comma を打つかどうかの選択を見せない。
|
|
310
342
|
* 題名の読点は題名を付けた人のもの。書き手の流儀の票にしない。
|
|
311
343
|
*/
|
|
312
|
-
const listAt = (list: ItemList, at: number): boolean | undefined => {
|
|
344
|
+
const listAt = (list: ItemList, at: number, walk: Walk): boolean | undefined => {
|
|
313
345
|
const { scope } = list;
|
|
314
346
|
if (closesExampleAside(wholeList(list), at)) return undefined;
|
|
315
347
|
const afterItem = itemAfter(scope, at);
|
|
316
|
-
const
|
|
317
|
-
|
|
348
|
+
const opened = afterClosedList(withoutLead(afterClauseTurn(withoutCoordinateAdjective(wholeList(list)), afterItem)));
|
|
349
|
+
const items = fromParticiplePhrase(fromExample(opened, afterItem), afterItem);
|
|
350
|
+
if (listContinues(scope, afterItem, walk) || isAppositive(scope, at, items, afterItem) || insideLastItem(scope, at, items, afterItem)) return undefined;
|
|
318
351
|
if (namesDivision(items) || qualifiesPrevious(items)) return undefined;
|
|
319
352
|
const last = lastOf(items);
|
|
320
353
|
if (last !== undefined && opensContrast(scope, last.item)) return undefined;
|
|
@@ -334,12 +367,14 @@ export const listVerdicts = (tokens: readonly Token[], words: ListWords, source:
|
|
|
334
367
|
const sentence = listSentenceOf(tokens, words, source);
|
|
335
368
|
const readItems = listReader(sentence);
|
|
336
369
|
const breaks = dashBreaks(tokens, source);
|
|
370
|
+
const excerpt = inExcerpt(tokens, source, words.elision ?? []);
|
|
371
|
+
const walk = walker();
|
|
337
372
|
return tokens.flatMap((token, at) => {
|
|
338
373
|
if (!isJudgedConjunction(token, at)) return [];
|
|
339
374
|
// 郵便番号で終わる住所のあとの and / or は、住所の行を区切る読点のあと。並びの読点ではない。
|
|
340
375
|
// 最後の読点のあとに前後を空けたダッシュがあれば(Washington, DC – The …)、読点はダッシュの前で閉じた日付行や見出しのもの。
|
|
341
|
-
const notList = sentence.inCitedTitle(at) || followsPostcode(source, token.span.start) || breaks[at] === true;
|
|
342
|
-
return [notList ? undefined : listAt(readItems(at), at)];
|
|
376
|
+
const notList = sentence.inCitedTitle(at) || excerpt(at) || followsPostcode(source, token.span.start) || breaks[at] === true;
|
|
377
|
+
return [notList ? undefined : listAt(readItems(at), at, walk)];
|
|
343
378
|
});
|
|
344
379
|
};
|
|
345
380
|
|
|
@@ -363,6 +398,11 @@ export const oxfordComma: Detector = (doc, options): Finding[] => {
|
|
|
363
398
|
titleCue: (doc.lexicons["title-cue"] ?? []).map((entry) => entry.pattern),
|
|
364
399
|
sequence: patternsOf(doc.lexicons["sequence-opener"]),
|
|
365
400
|
unit: patternsOf(doc.lexicons["enclosing-unit"]),
|
|
401
|
+
connective: patternsOf(doc.lexicons["connective-opener"]),
|
|
402
|
+
clauseConjunction: patternsOf(doc.lexicons["clause-conjunction"]),
|
|
403
|
+
indefinite: patternsOf(doc.lexicons["indefinite-article"]),
|
|
404
|
+
elision: (doc.lexicons["elision-mark"] ?? []).map((entry) => entry.pattern),
|
|
405
|
+
openListEnd: patternsOf(doc.lexicons["open-list-end"]),
|
|
366
406
|
};
|
|
367
407
|
const judged = doc.sentences.flatMap((sentence) => {
|
|
368
408
|
const oxford = oxfordIn(sentence.tokens ?? [], words, doc.source);
|