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
package/src/spelling.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// 辞書に無い語と、一字違いの言い直し。純粋な関数だけを置く。辞書と、語尾・接頭辞の知識は言語パッケージが渡す。
|
|
2
2
|
|
|
3
3
|
/** 語尾の置き換え 1 つ。suffix を外して replacement を足すと辞書の語(carried → carry)。 */
|
|
4
|
-
export type Suffix = { readonly suffix: string; readonly replacement: string };
|
|
4
|
+
export type Suffix = { readonly suffix: string; readonly replacement: string; readonly inflection?: boolean };
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 語を辞書で引くのに要るもの。words は語の集まりの並び(辞書と、語彙表やチームの足した語)で、どれかにあれば載っている語。
|
|
8
8
|
* 大きい辞書を文書ごとに写さないよう、集まりは足し合わせずに並べる。suffixes は語尾、prefixes は接頭辞。
|
|
9
9
|
*/
|
|
10
|
-
export type Speller = {
|
|
10
|
+
export type Speller = {
|
|
11
|
+
readonly words: ReadonlyArray<ReadonlySet<string>>;
|
|
12
|
+
readonly suffixes: readonly Suffix[];
|
|
13
|
+
readonly prefixes: readonly string[];
|
|
14
|
+
/** 語尾を取らない語(those、which)。thoses を those + s と読まない。 */
|
|
15
|
+
readonly uninflected?: ReadonlySet<string>;
|
|
16
|
+
};
|
|
11
17
|
|
|
12
18
|
const inLists = (word: string, speller: Speller): boolean => speller.words.some((list) => list.has(word));
|
|
13
19
|
|
|
@@ -15,7 +21,7 @@ const inLists = (word: string, speller: Speller): boolean => speller.words.some(
|
|
|
15
21
|
const MIN_STEM = 2;
|
|
16
22
|
|
|
17
23
|
/** 語尾を外した語幹。外した後ろに同じ子音が二つ並べば一つ減らした形も(stopped → stopp → stop)。 */
|
|
18
|
-
const
|
|
24
|
+
const endingStemsOf = (word: string, suffixes: readonly Suffix[]): string[] =>
|
|
19
25
|
suffixes.flatMap(({ suffix, replacement }) => {
|
|
20
26
|
if (!word.endsWith(suffix) || word.length - suffix.length < MIN_STEM) return [];
|
|
21
27
|
const stem = word.slice(0, word.length - suffix.length);
|
|
@@ -23,7 +29,11 @@ const stemsOf = (word: string, suffixes: readonly Suffix[]): string[] =>
|
|
|
23
29
|
return [`${stem}${replacement}`, ...doubled];
|
|
24
30
|
});
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
/** 語尾を外した語幹のうち、語尾を取らない語(those)でないもの。 */
|
|
33
|
+
export const stemsOf = (word: string, speller: Speller): string[] =>
|
|
34
|
+
endingStemsOf(word, speller.suffixes).filter((stem) => speller.uninflected?.has(stem) !== true);
|
|
35
|
+
|
|
36
|
+
const isListed = (word: string, speller: Speller): boolean => inLists(word, speller) || stemsOf(word, speller).some((stem) => inLists(stem, speller));
|
|
27
37
|
|
|
28
38
|
const isPrefixed = (word: string, speller: Speller): boolean =>
|
|
29
39
|
speller.prefixes.some((prefix) => word.startsWith(prefix) && word.length - prefix.length >= MIN_STEM && isListed(word.slice(prefix.length), speller));
|
|
@@ -31,6 +41,25 @@ const isPrefixed = (word: string, speller: Speller): boolean =>
|
|
|
31
41
|
/** 辞書の語か。そのままか、語尾を外すか、接頭辞を一つ外して(語尾も外して)辞書にあれば知っている語。 */
|
|
32
42
|
export const isKnownWord = (word: string, speller: Speller): boolean => isListed(word, speller) || isPrefixed(word, speller);
|
|
33
43
|
|
|
44
|
+
/** 内側の語尾を外した後に残す字の数。短い語幹は辞書の略語に当たりやすい(thier を thy + er、その thy を th + y と読まない)。 */
|
|
45
|
+
const MIN_INNER_STEM = 4;
|
|
46
|
+
|
|
47
|
+
/** 派生の語尾(-ise、-ness)を外した語幹。重ねた子音は戻さない(visuallize を visual + ize と読まない)。 */
|
|
48
|
+
const derivedStemsOf = (word: string, speller: Speller): string[] =>
|
|
49
|
+
speller.suffixes
|
|
50
|
+
.filter(({ suffix, inflection }) => inflection !== true && word.endsWith(suffix) && word.length - suffix.length >= MIN_INNER_STEM)
|
|
51
|
+
.map(({ suffix, replacement }) => `${word.slice(0, word.length - suffix.length)}${replacement}`);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 派生した語に活用の語尾を付けた語(operationalises は operationalise + s、その operationalise は operational + ise)。
|
|
55
|
+
* 外側は活用の語尾(-s、-ed)、内側は派生の語尾だけで、活用の語尾の上に語尾は重ならない(oversers は overs + ers でない)。
|
|
56
|
+
*/
|
|
57
|
+
export const hasTwoEndings = (word: string, speller: Speller): boolean =>
|
|
58
|
+
endingStemsOf(
|
|
59
|
+
word,
|
|
60
|
+
speller.suffixes.filter(({ inflection }) => inflection === true),
|
|
61
|
+
).some((stem) => derivedStemsOf(stem, speller).some((inner) => inLists(inner, speller)));
|
|
62
|
+
|
|
34
63
|
const LETTERS = [..."abcdefghijklmnopqrstuvwxyz"];
|
|
35
64
|
|
|
36
65
|
/** 一字違いの形。入れ替え(recieve → receive)、置き換え、抜け、余分の順。同じ形は一度だけ。 */
|
|
@@ -61,12 +90,13 @@ export type CheckedWord = { readonly offset: number; readonly word: string };
|
|
|
61
90
|
/**
|
|
62
91
|
* 確かめる語。小文字だけで書いた英字の語で、ほかの語・番号・記号に続かないもの。大文字を含む語(固有名詞、略語、文頭の語)、
|
|
63
92
|
* 数字や下線を含む語、アポストロフィとハイフンの前後(don't、co-operate)、文字参照(—)、ファイル名やドメインの一部(index.html の index)、
|
|
64
|
-
* URL とメールの中、maxLength
|
|
93
|
+
* URL とメールの中、maxLength より長い字の並び(符号化したデータ)は見ない。角括弧の字を続けた語(引用を変えた handl[e])、
|
|
94
|
+
* 括弧の字を挟んで続く語(neuro(a)typicality)、= が続く語(式を地の文に書いた nboot=2,000 の変数の名)も語の一部なので見ない。
|
|
65
95
|
*/
|
|
66
|
-
const WORD = /(?<![\p{L}\p{N}_./@#&'’\\-])[a-z]+(?![\p{L}\p{N}_/@'
|
|
96
|
+
const WORD = /(?<![\p{L}\p{N}_./@#&'’\\-])[a-z]+(?![\p{L}\p{N}_/@'’=-]|\.[\p{L}\p{N}]|\[\p{L}|\(\p{L}+\)\p{L})/gu;
|
|
67
97
|
/** 空白で区切った一続きの字。URL(://)、www. で始まるもの、メール(@)は丸ごと語として読まない。 */
|
|
68
98
|
const CHUNK = /\S+/gu;
|
|
69
|
-
const isAddress = (chunk: string): boolean => chunk.includes("://") || chunk.includes("@") || chunk.startsWith("www.");
|
|
99
|
+
export const isAddress = (chunk: string): boolean => chunk.includes("://") || chunk.includes("@") || chunk.startsWith("www.");
|
|
70
100
|
|
|
71
101
|
const addressSpans = (text: string): Array<readonly [number, number]> =>
|
|
72
102
|
[...text.matchAll(CHUNK)].filter((match) => isAddress(match[0])).map((match) => [match.index, match.index + match[0].length]);
|
|
@@ -5,9 +5,24 @@ import type { StructureNode } from "../plugin.ts";
|
|
|
5
5
|
/** heading: いちばん近い見出しの節の言葉。inArticle: 条の中か。 */
|
|
6
6
|
type Visit = { readonly node: StructureNode; readonly heading: string | undefined; readonly inArticle: boolean };
|
|
7
7
|
|
|
8
|
+
/** 見出しが名前の後ろに添えた略称や注記(「…特例に関する法律(特例法)」「…手数料令(手数料令)<抜粋>」)の括弧。名前ではない。 */
|
|
9
|
+
const GLOSS_OPENERS: Readonly<Record<string, string>> = { ")": "(", ")": "(", ">": "<", ">": "<" };
|
|
10
|
+
const MAX_GLOSS_LENGTH = 30;
|
|
11
|
+
|
|
12
|
+
/** 末尾の括弧書きを外から一つずつ外す。中に同じ括弧を含むものは外さない。 */
|
|
13
|
+
const withoutGlosses = (heading: string): string => {
|
|
14
|
+
let name = heading.trim();
|
|
15
|
+
for (;;) {
|
|
16
|
+
const opener = GLOSS_OPENERS[name.at(-1) ?? ""];
|
|
17
|
+
const at = opener === undefined ? -1 : name.lastIndexOf(opener);
|
|
18
|
+
if (at <= 0 || name.length - at > MAX_GLOSS_LENGTH) return name;
|
|
19
|
+
name = name.slice(0, at).trimEnd();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
/** 見出しの言葉。文書の最初の見出しは文書自身の題(「# 就業規則」)なので、他の文書の名前として読まない。 */
|
|
9
24
|
const headingOf = (node: StructureNode, title: StructureNode | undefined): string | undefined =>
|
|
10
|
-
node === title ? undefined : String(node.attrs["heading"] ?? "")
|
|
25
|
+
node === title ? undefined : withoutGlosses(String(node.attrs["heading"] ?? ""));
|
|
11
26
|
|
|
12
27
|
const documentsCited = (nodes: readonly StructureNode[]): ReadonlySet<string> =>
|
|
13
28
|
new Set(nodes.flatMap((node) => (node.kind === "reference" && typeof node.attrs["document"] === "string" ? [node.attrs["document"]] : [])));
|
package/src/structure/issues.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { namesAbsentUnit, withinAbsentUnit } from "./unit-word.ts";
|
|
|
8
8
|
import { isListedParagraph, listedParagraphsByArticle } from "./listed-paragraph.ts";
|
|
9
9
|
import { referencesInCitedDocuments } from "./cited-document-section.ts";
|
|
10
10
|
import { citedElsewhereReader } from "./cited-elsewhere.ts";
|
|
11
|
+
import { referenceListSpans } from "../reference-lists.ts";
|
|
11
12
|
|
|
12
13
|
// 木だけで決まる誤り。参照先が無い、番号が飛ぶ・重なる、同じ語を二度定義する。
|
|
13
14
|
// 意味の食い違いは判定しない。書いてあることから機械で決まるものだけを出す。
|
|
@@ -137,7 +138,12 @@ const ownNumberings = (nodes: readonly StructureNode[], resolvesHere: (node: Str
|
|
|
137
138
|
* 参照の番地が木に無い。他の文書の名前が付いた参照(民法第709条、Section 9 of the Master Agreement)は引かない。
|
|
138
139
|
* 条を 1 つも持たない文書も見ない。他の文書を指しているだけかもしれない。
|
|
139
140
|
*/
|
|
140
|
-
export const danglingReferences = (
|
|
141
|
+
export const danglingReferences = (
|
|
142
|
+
tree: StructureNode,
|
|
143
|
+
source: string,
|
|
144
|
+
nameNouns: readonly string[] = [],
|
|
145
|
+
referenceListHeadings: readonly string[] = [],
|
|
146
|
+
): StructureIssue[] => {
|
|
141
147
|
const nodes = inDocumentOrder(tree);
|
|
142
148
|
// 参照は条を指す。条を一つも持たない文書(契約書に付ける承諾書のひな形など)の「契約書第6条」は、別の文書の条。
|
|
143
149
|
if (!nodes.some((node) => node.kind === "article")) return [];
|
|
@@ -167,7 +173,10 @@ export const danglingReferences = (tree: StructureNode, source: string, nameNoun
|
|
|
167
173
|
// 平文の契約は見出しを「9. Indemnification.」と本文の形で書き、木はそれを番地にしない。残った参照があるときだけ読む。
|
|
168
174
|
const written = unresolved.length === 0 ? undefined : writtenReading(nodes, source);
|
|
169
175
|
const writtenAddresses = new Set(written?.addresses);
|
|
176
|
+
// 文献一覧の項目は他の著作を引く。そこの "pp. Article 81" は雑誌の論文番号で、この文書の条ではない。
|
|
177
|
+
const lists = unresolved.length === 0 ? [] : referenceListSpans(source, referenceListHeadings);
|
|
170
178
|
return unresolved
|
|
179
|
+
.filter((node) => !lists.some((span) => span.start <= node.span.start && node.span.start < span.end))
|
|
171
180
|
.filter((node) => !isListedParagraph(textOf(node, "target"), listed))
|
|
172
181
|
.filter((node) => !writtenAddresses.has(textOf(node, "target")) && written?.subdivision(node) !== true)
|
|
173
182
|
.map((node) => ({ offset: node.span.start, values: { label: textOf(node, "label"), target: textOf(node, "target") } }));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Lexicon, LexiconEntry } from "../plugin.ts";
|
|
2
|
+
import { startsWithWord } from "./heading-words.ts";
|
|
3
|
+
|
|
4
|
+
/** How many of the template's sections an outline needs before it reads as the template: a real proposal has one or two. */
|
|
5
|
+
export const TEMPLATE_SECTIONS = 4;
|
|
6
|
+
|
|
7
|
+
/** Kanji or katakana: a compound goes on through them, so 効果 does not open 効果測定 and 提案 does not open 提案者. */
|
|
8
|
+
const COMPOUND = /[\p{Script=Han}\p{Script=Katakana}ー]/u;
|
|
9
|
+
|
|
10
|
+
const characterAt = (text: string, index: number): string => {
|
|
11
|
+
const code = text.codePointAt(index);
|
|
12
|
+
return code === undefined ? "" : String.fromCodePoint(code);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const continuesCompound = (words: string, phrase: string): boolean => COMPOUND.test(phrase.at(-1) ?? "") && COMPOUND.test(characterAt(words, phrase.length));
|
|
16
|
+
|
|
17
|
+
const opensWith = (words: string, phrase: string): boolean => startsWithWord(words, phrase) && !continuesCompound(words, phrase);
|
|
18
|
+
|
|
19
|
+
/** The longest entry the heading opens with, so 提案の背景 is the background and not the proposal. */
|
|
20
|
+
const sectionOf = (words: string, lexicon: Lexicon): LexiconEntry | undefined =>
|
|
21
|
+
lexicon
|
|
22
|
+
.filter((entry) => entry.group !== undefined && opensWith(words, entry.pattern.toLowerCase()))
|
|
23
|
+
.toSorted((left, right) => right.pattern.length - left.pattern.length)[0];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The template sections (the lexicon's groups: summary, background, proposal, benefits…) that the headings stand for,
|
|
27
|
+
* each once, in heading order. `headings` are heading words as headingWords gives them (lower case, numbers dropped).
|
|
28
|
+
*/
|
|
29
|
+
export const templateSectionsOf = (headings: readonly string[], lexicon: Lexicon): string[] => [
|
|
30
|
+
...new Set(headings.flatMap((words) => sectionOf(words, lexicon)?.group ?? [])),
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/** Whether the outline is the template: enough of its sections stand as headings. */
|
|
34
|
+
export const isTemplateOutline = (sections: readonly string[]): boolean => sections.length >= TEMPLATE_SECTIONS;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// A name written as a run of capitalised words inside a sentence (the Interagency Group, the Twenty-Nine Palms Band of Mission
|
|
2
|
+
// Indians, Radical Uncertainty: Decision-Making Beyond the Numbers). Pure.
|
|
3
|
+
|
|
4
|
+
import type { Span } from "./plugin.ts";
|
|
5
|
+
|
|
6
|
+
const LATIN_WORD = /\p{Script=Latin}[\p{Script=Latin}\d'’]*(?:-[\p{Script=Latin}\d]+)*/gu;
|
|
7
|
+
/** A capitalised word, with small letters after its capital, its hyphenated parts too (Twenty-Nine, Co-working, Interagency). */
|
|
8
|
+
const CAPITALISED = /^\p{Lu}[\p{Ll}\d'’]*(?:-[\p{L}\d][\p{Ll}\d]*)*$/u;
|
|
9
|
+
const SPACE_ONLY = /^ $/u;
|
|
10
|
+
const MIN_NAME_WORDS = 2;
|
|
11
|
+
|
|
12
|
+
type Word = { readonly text: string; readonly start: number; readonly end: number };
|
|
13
|
+
|
|
14
|
+
const isCapitalised = (word: Word): boolean => CAPITALISED.test(word.text);
|
|
15
|
+
|
|
16
|
+
/** Whether `word` carries on the run that ended at `last`: one space between, and capitalised or a joiner (of, and). */
|
|
17
|
+
const continues = (text: string, last: Word | undefined, word: Word, joiners: ReadonlySet<string>): boolean =>
|
|
18
|
+
last !== undefined && SPACE_ONLY.test(text.slice(last.end, word.start)) && (isCapitalised(word) || joiners.has(word.text));
|
|
19
|
+
|
|
20
|
+
/** A run without the joiners it ends on (the Office of): a name ends on a capitalised word. */
|
|
21
|
+
const trimmed = (run: readonly Word[]): Word[] => run.slice(0, run.findLastIndex(isCapitalised) + 1);
|
|
22
|
+
|
|
23
|
+
const runsOf = (text: string, words: readonly Word[], joiners: ReadonlySet<string>): Word[][] =>
|
|
24
|
+
words.reduce<Word[][]>((runs, word) => {
|
|
25
|
+
const current = runs.at(-1);
|
|
26
|
+
if (current !== undefined && continues(text, current.at(-1), word, joiners)) return [...runs.slice(0, -1), [...current, word]];
|
|
27
|
+
return isCapitalised(word) ? [...runs, [word]] : runs;
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
const isName = (run: readonly Word[]): boolean => run.filter(isCapitalised).length >= MIN_NAME_WORDS;
|
|
31
|
+
|
|
32
|
+
const spanOf = (run: readonly Word[]): Span | undefined => {
|
|
33
|
+
const [head, last] = [run[0], run.at(-1)];
|
|
34
|
+
return head === undefined || last === undefined ? undefined : { start: head.start, end: last.end };
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A capitalised run: the whole run (Co-working Space), and the part of it that is surely a name (quoted), if any. The first
|
|
39
|
+
* word of the sentence is left out of the quoted part, since a sentence and a title capitalise their first word whatever it is.
|
|
40
|
+
*/
|
|
41
|
+
export type NameRun = { readonly name: Span; readonly quoted: Span | undefined };
|
|
42
|
+
|
|
43
|
+
/** The capitalised runs of two words or more in a sentence, joined by the language's small words (of, and): names. */
|
|
44
|
+
export const titleCaseNameRuns = (text: string, joiners: readonly string[]): NameRun[] => {
|
|
45
|
+
const words = [...text.matchAll(LATIN_WORD)].map((match) => ({ text: match[0], start: match.index, end: match.index + match[0].length }));
|
|
46
|
+
const first = words[0];
|
|
47
|
+
return runsOf(text, words, new Set(joiners))
|
|
48
|
+
.map(trimmed)
|
|
49
|
+
.filter(isName)
|
|
50
|
+
.flatMap((run) => {
|
|
51
|
+
const name = spanOf(run);
|
|
52
|
+
const named = trimmed(run[0] === first ? run.slice(1) : run);
|
|
53
|
+
return name === undefined ? [] : [{ name, quoted: isName(named) ? spanOf(named) : undefined }];
|
|
54
|
+
});
|
|
55
|
+
};
|
package/src/topic-clause.ts
CHANGED
|
@@ -38,6 +38,19 @@ const isOwnNoun = (token: Token | undefined): boolean => NOMINAL.has(token?.pos
|
|
|
38
38
|
|
|
39
39
|
const isParticle = (token: Token, surface: string): boolean => token.surface === surface && token.pos === "ADP";
|
|
40
40
|
|
|
41
|
+
/** A word that stands as a noun only after の: ほとんど and 多く in これらの処理のほとんどは are a part of what the の phrase names. */
|
|
42
|
+
const isNarrowedPart = (tokens: readonly Token[], at: number): boolean =>
|
|
43
|
+
(tokens[at]?.pos === "ADV" || tokens[at]?.features?.["Adverbial"] === "Yes") && tokens[at - 1]?.surface === "の" && tokens[at - 1]?.pos === "ADP";
|
|
44
|
+
|
|
45
|
+
/** The word before at heads a subject of its own: a noun (法律は), or a part a の phrase narrows (処理のほとんどは). */
|
|
46
|
+
const headsSubject = (tokens: readonly Token[], at: number): boolean => isOwnNoun(tokens[at - 1]) || isNarrowedPart(tokens, at - 1);
|
|
47
|
+
|
|
48
|
+
/** A subject of its own at at: は on its head anywhere, or が on its head when lastComma is before it (-1 to take every が). */
|
|
49
|
+
const isOwnSubjectAt = (tokens: readonly Token[], at: number, lastComma: number): boolean => {
|
|
50
|
+
const token = tokens[at];
|
|
51
|
+
return token !== undefined && headsSubject(tokens, at) && (isParticle(token, "は") || (isParticle(token, "が") && at > lastComma));
|
|
52
|
+
};
|
|
53
|
+
|
|
41
54
|
/**
|
|
42
55
|
* The last place a subject of its own stands before the sentence's last word: a new topic (法律はありませんが) anywhere, or a
|
|
43
56
|
* noun with が that the final predicate takes (no comma after it: 動きが見られ始めている). A noun with が inside a condition
|
|
@@ -45,9 +58,7 @@ const isParticle = (token: Token, surface: string): boolean => token.surface ===
|
|
|
45
58
|
*/
|
|
46
59
|
const lastOwnSubject = (tokens: readonly Token[], last: number): number => {
|
|
47
60
|
const lastComma = tokens.findLastIndex((token, at) => at < last && isComma(token));
|
|
48
|
-
return tokens.findLastIndex(
|
|
49
|
-
(token, at) => at < last && isOwnNoun(tokens[at - 1]) && (isParticle(token, "は") || (isParticle(token, "が") && at > lastComma)),
|
|
50
|
-
);
|
|
61
|
+
return tokens.findLastIndex((_, at) => at < last && isOwnSubjectAt(tokens, at, lastComma));
|
|
51
62
|
};
|
|
52
63
|
|
|
53
64
|
/** The words of the clause after a comma at from, up to the next clause stopped by a comma, or the sentence's last word. */
|
|
@@ -115,14 +126,94 @@ const closesIfNewSubject = (tokens: readonly Token[], at: number): boolean => {
|
|
|
115
126
|
return token?.pos === "VERB" && token.lemma === "おる" && token.features?.["Bound"] === "Yes";
|
|
116
127
|
};
|
|
117
128
|
|
|
129
|
+
/** The words a document's language gives for the shapes below (lang-ja's lexicons). Without them, only the shapes that need none. */
|
|
130
|
+
export type TopicClauseWords = {
|
|
131
|
+
/** Words that end a clause right after its predicate (ことから, つつ, としても): the topic-clause-close lexicon. */
|
|
132
|
+
readonly closers: readonly string[];
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const NO_WORDS: TopicClauseWords = { closers: [] };
|
|
136
|
+
|
|
137
|
+
/** The first of the words that spell text when they end at at (こと + から for ことから), or -1 when no run of words does. */
|
|
138
|
+
const wordsStart = (tokens: readonly Token[], at: number, text: string, spelled = ""): number => {
|
|
139
|
+
const token = tokens[at];
|
|
140
|
+
if (token === undefined) return -1;
|
|
141
|
+
const joined = token.surface + spelled;
|
|
142
|
+
if (joined === text) return at;
|
|
143
|
+
return joined.length < text.length && text.endsWith(joined) ? wordsStart(tokens, at - 1, text, joined) : -1;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** Whether another subject (が or は on a noun, or on a clause made a noun: 行うことは) stands between from and to. */
|
|
147
|
+
const subjectBetween = (tokens: readonly Token[], from: number, to: number): boolean =>
|
|
148
|
+
tokens.some(
|
|
149
|
+
(token, at) =>
|
|
150
|
+
at > from && at < to && (isParticle(token, "は") || isParticle(token, "が")) && (NOMINAL.has(tokens[at - 1]?.pos ?? "") || headsSubject(tokens, at)),
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const isPoliteMasu = (token: Token | undefined): boolean => token?.pos === "AUX" && token.lemma === "ます";
|
|
154
|
+
|
|
155
|
+
/** 〜ておりますが / 〜しましたが: a polite predicate and the contrastive が. */
|
|
156
|
+
const isPoliteGa = (tokens: readonly Token[], at: number): boolean => {
|
|
157
|
+
if (tokens[at]?.surface !== "が" || tokens[at]?.pos !== "SCONJ") return false;
|
|
158
|
+
const before = tokens[at - 1];
|
|
159
|
+
return isPoliteMasu(before) || (before?.pos === "AUX" && before.surface === "た" && isPoliteMasu(tokens[at - 2]));
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const ownGaSubjectBetween = (tokens: readonly Token[], from: number, to: number): boolean =>
|
|
163
|
+
tokens.some((token, at) => at > from && at < to && isParticle(token, "が") && headsSubject(tokens, at));
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 当社は…を営んでおりますが、…の重要性が乏しいため、…の記載は行っておりません: after 〜ますが、 the words up to the next comma
|
|
167
|
+
* say something of a subject of their own (が) and a new topic takes what comes after, so the predicate before が was the
|
|
168
|
+
* topic's, when no other subject stands between the topic and it (需要の停滞がありましたが is not). A topic straight after the
|
|
169
|
+
* comma (〜ましたが、Bは…) or no subject of its own there is read to the end.
|
|
170
|
+
*/
|
|
171
|
+
const closesWithPoliteGa = (tokens: readonly Token[], topic: number, at: number, last: number): boolean => {
|
|
172
|
+
if (!isPoliteGa(tokens, at) || !isComma(tokens[at + 1]) || subjectBetween(tokens, topic, at)) return false;
|
|
173
|
+
const comma = tokens.findIndex((token, index) => index > at + 1 && index < last && isComma(token));
|
|
174
|
+
const clauseEnd = comma === -1 ? last : comma;
|
|
175
|
+
return ownGaSubjectBetween(tokens, at + 1, clauseEnd) && newTopicAfter(tokens, clauseEnd, last);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 学校は地域の核となることから、…: a closer after a predicate, then a comma, with no subject of its own
|
|
180
|
+
* between the topic and it. That predicate is the topic's; what follows is said of something else, or by the writer. A topic set
|
|
181
|
+
* off by a comma (AISIは、…連携しつつ、…行っていく) usually runs to the end, so then only a copula's closer counts (〜であることから、).
|
|
182
|
+
*/
|
|
183
|
+
const closesAfterPredicate = (tokens: readonly Token[], topic: number, at: number, words: TopicClauseWords): boolean => {
|
|
184
|
+
if (!isComma(tokens[at + 1])) return false;
|
|
185
|
+
return words.closers.some((connective) => {
|
|
186
|
+
const start = wordsStart(tokens, at, connective);
|
|
187
|
+
if (start <= topic + 1 || !PREDICATE.has(tokens[start - 1]?.pos ?? "") || subjectBetween(tokens, topic, start)) return false;
|
|
188
|
+
return copulaBefore(tokens, start) || !tokens.slice(topic + 1, start).some(isComma);
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/** A mark that opens with a circled number (③): an item of a list the source ran into one line. */
|
|
193
|
+
const CIRCLED = /^[①-⒇❶-❿]/u;
|
|
194
|
+
|
|
195
|
+
const isBlank = (token: Token): boolean => token.surface.trim() === "";
|
|
196
|
+
|
|
197
|
+
/** 〜を向上させる ③ 次の項目: an item mark right after a predicate (spaces between are not read) ends the item before it. */
|
|
198
|
+
const closesWithItemMark = (tokens: readonly Token[], at: number): boolean => {
|
|
199
|
+
if (!PREDICATE.has(tokens[at]?.pos ?? "")) return false;
|
|
200
|
+
const next = tokens.findIndex((token, index) => index > at && !isBlank(token));
|
|
201
|
+
return next !== -1 && CIRCLED.test(tokens[next]?.surface ?? "");
|
|
202
|
+
};
|
|
203
|
+
|
|
118
204
|
/**
|
|
119
205
|
* The index of the word that ends the topic's own clause, between the topic and the sentence's last word, or undefined when the
|
|
120
206
|
* topic's predicate is the one the sentence ends on.
|
|
121
207
|
*/
|
|
122
|
-
export const topicClauseEnd = (tokens: readonly Token[], topic: number, last: number): number | undefined => {
|
|
208
|
+
export const topicClauseEnd = (tokens: readonly Token[], topic: number, last: number, words: TopicClauseWords = NO_WORDS): number | undefined => {
|
|
123
209
|
const subject = lastOwnSubject(tokens, last);
|
|
124
210
|
const closes = (at: number): boolean =>
|
|
125
|
-
closesSurely(tokens, at, last) ||
|
|
211
|
+
closesSurely(tokens, at, last) ||
|
|
212
|
+
(closesIfNewSubject(tokens, at) && subject > at) ||
|
|
213
|
+
closesFirstClauseWithNoun(tokens, topic, at, last) ||
|
|
214
|
+
closesWithPoliteGa(tokens, topic, at, last) ||
|
|
215
|
+
closesAfterPredicate(tokens, topic, at, words) ||
|
|
216
|
+
closesWithItemMark(tokens, at);
|
|
126
217
|
const end = tokens.findIndex((_, at) => at > topic && at < last && closes(at));
|
|
127
218
|
return end === -1 ? undefined : end;
|
|
128
219
|
};
|
package/src/word-use.ts
CHANGED
|
@@ -94,15 +94,41 @@ const isObserved = (previous: Token | undefined, following: readonly Token[] | u
|
|
|
94
94
|
const isJudgingUse = ({ token, previous, before, following }: InContext, judging: ReadonlySet<string>): boolean =>
|
|
95
95
|
token.pos === "VERB" && judging.has(token.lemma ?? "") && (followsQuotative(previous, before) || isObserved(previous, following));
|
|
96
96
|
|
|
97
|
+
/** The particle 以て follows where 持つ never does: 〜でもって. */
|
|
98
|
+
const MEANS_PARTICLE = "で";
|
|
99
|
+
const VERB_LIKE = new Set(["VERB", "AUX"]);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A listed verb's て-form after で with no verb after it (電子でもって申請する): 以て, "by means of", which 持つ never is after
|
|
103
|
+
* で (手で持って運ぶ has its verb after it). After を the two read alike (決意をもって, 信念を持って), and are compared as one word.
|
|
104
|
+
*/
|
|
105
|
+
const isMeansUse = ({ token, previous, following }: InContext, means: ReadonlySet<string>): boolean =>
|
|
106
|
+
token.pos === "VERB" &&
|
|
107
|
+
means.has(token.lemma ?? "") &&
|
|
108
|
+
previous?.pos === "ADP" &&
|
|
109
|
+
previous.surface === MEANS_PARTICLE &&
|
|
110
|
+
TE.has(following?.[0]?.surface ?? "") &&
|
|
111
|
+
following?.[1] !== undefined &&
|
|
112
|
+
!VERB_LIKE.has(following[1].pos);
|
|
113
|
+
|
|
97
114
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
115
|
+
* A listed light verb after the quotative と (議題といたします): the humble する, as it is written onto a noun (開会いたします),
|
|
116
|
+
* where the tokenizer marks it bound. The full verb takes を (思いを致す).
|
|
117
|
+
*/
|
|
118
|
+
const isLightVerbAfterQuotative = ({ token, previous }: InContext, lightVerbs: ReadonlySet<string>): boolean =>
|
|
119
|
+
token.pos === "VERB" && lightVerbs.has(token.lemma ?? "") && previous?.pos === "ADP" && previous.surface === QUOTATIVE;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The lexicons that set a word's use apart: idioms (気をつける), conjunctions (あわせて、), judging (〜とみられる), katakana
|
|
123
|
+
* spellings that name a sense of their own (モノ for goods), 以て (〜でもって) and light verbs (〜といたします).
|
|
100
124
|
*/
|
|
101
125
|
export type Uses = {
|
|
102
126
|
readonly idioms: ReadonlySet<string>;
|
|
103
127
|
readonly conjunctions: ReadonlySet<string>;
|
|
104
128
|
readonly judging: ReadonlySet<string>;
|
|
105
129
|
readonly senses: ReadonlySet<string>;
|
|
130
|
+
readonly means: ReadonlySet<string>;
|
|
131
|
+
readonly lightVerbs: ReadonlySet<string>;
|
|
106
132
|
};
|
|
107
133
|
|
|
108
134
|
/** A verb written straight onto the verb after it (出来上る, 書き込む): the head of a compound verb, which keeps the compound's spelling. */
|
|
@@ -111,22 +137,33 @@ const isCompoundVerbHead = ({ token, following }: InContext): boolean => {
|
|
|
111
137
|
return token.pos === "VERB" && next?.pos === "VERB" && isTouching(token, next);
|
|
112
138
|
};
|
|
113
139
|
|
|
140
|
+
/** A verb written straight onto the verb before it (貼り付ける, 書き込む): the tail of a compound verb, not the verb alone (番号をつける). */
|
|
141
|
+
const isCompoundVerbTail = ({ token, previous }: InContext): boolean => token.pos === "VERB" && previous?.pos === "VERB" && isTouching(previous, token);
|
|
142
|
+
|
|
143
|
+
/** A word used freely, or as a helper: a bound noun after a word is a suffix, and anything else bound a helper. */
|
|
144
|
+
const helperUseOf = (word: InContext, lightVerbs: ReadonlySet<string>): string => {
|
|
145
|
+
if (!isHelper(word) && !isLightVerbAfterQuotative(word, lightVerbs)) return "free";
|
|
146
|
+
return word.token.pos === "NOUN" && word.token.features?.["NounType"] !== "Dependent" ? "suffix" : "bound";
|
|
147
|
+
};
|
|
148
|
+
|
|
114
149
|
/**
|
|
115
150
|
* A helper verb or a dependent noun (見て下さい, その事) is written kana by many guides while the full word keeps its kanji (資料を下さい).
|
|
116
151
|
* The two uses are compared apart, so a document that follows that convention is consistent. A suffix (業務用, 全員ぶん) is a third use:
|
|
117
152
|
* it is not the dependent noun of the same reading (このように). The verb of an idiom (気をつける) is a fourth, and a
|
|
118
153
|
* conjunction (あわせて、, さらに、) a fifth, a verb of judging (〜とみられる) a sixth, a katakana spelling with a sense of its own (モノ)
|
|
119
|
-
* a seventh
|
|
154
|
+
* a seventh, the head of a compound verb (出来上る) an eighth, its tail (貼り付ける) a ninth and 以て (〜でもって) a tenth. A light verb
|
|
155
|
+
* after と (議題といたします) is a helper.
|
|
120
156
|
*/
|
|
121
|
-
export const useOf = (word: InContext, { idioms, conjunctions, judging, senses }: Uses): string => {
|
|
157
|
+
export const useOf = (word: InContext, { idioms, conjunctions, judging, senses, means, lightVerbs }: Uses): string => {
|
|
122
158
|
if (isIdiomVerb(word, idioms)) return "idiom";
|
|
159
|
+
if (isMeansUse(word, means)) return "means";
|
|
123
160
|
if (isConjunctionUse(word, conjunctions)) return "conjunction";
|
|
124
161
|
if (isJudgingUse(word, judging)) return "judging";
|
|
125
162
|
if (senses.has(word.token.surface)) return "sense";
|
|
126
163
|
if (isCompoundVerbHead(word)) return "compound-verb";
|
|
164
|
+
if (isCompoundVerbTail(word)) return "compound-tail";
|
|
127
165
|
if (isKanaSuffix(word)) return "suffix";
|
|
128
|
-
|
|
129
|
-
return word.token.pos === "NOUN" && word.token.features?.["NounType"] !== "Dependent" ? "suffix" : "bound";
|
|
166
|
+
return helperUseOf(word, lightVerbs);
|
|
130
167
|
};
|
|
131
168
|
|
|
132
169
|
/** One katakana and then kana that is not katakana (スる): no verb stem is one katakana long, as サボる and ググる are two. */
|
|
@@ -137,6 +174,20 @@ const KATAKANA_END = /\p{Script=Katakana}$/u;
|
|
|
137
174
|
export const isCutFromKatakana = ({ token, previous }: InContext): boolean =>
|
|
138
175
|
ONE_KATAKANA_HEAD.test(token.surface) && token.surface.length > 1 && isTouching(previous, token) && KATAKANA_END.test(previous?.surface ?? "");
|
|
139
176
|
|
|
177
|
+
const KATAKANA_ONLY = /^[\p{Script=Katakana}ー]+$/u;
|
|
178
|
+
|
|
179
|
+
const isKatakanaToken = (token: Token | undefined): boolean => token !== undefined && KATAKANA_ONLY.test(token.surface);
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A katakana word the tokenizer cut out of a longer katakana run (カイ of ラオカイ): a piece of a foreign name, whose sound
|
|
183
|
+
* meets a kanji word of the same reading (峡) by chance.
|
|
184
|
+
*/
|
|
185
|
+
export const isPieceOfKatakanaRun = ({ token, previous, following }: InContext): boolean => {
|
|
186
|
+
const next = following?.[0];
|
|
187
|
+
if (!isKatakanaToken(token)) return false;
|
|
188
|
+
return (isKatakanaToken(previous) && isTouching(previous, token)) || (next !== undefined && isKatakanaToken(next) && isTouching(token, next));
|
|
189
|
+
};
|
|
190
|
+
|
|
140
191
|
/**
|
|
141
192
|
* で read as the verb 出る right after a word with no particle between (JSON でない): the copula's で, which the tokenizer
|
|
142
193
|
* misreads after a space or a name. 出る after a particle (結果がでない) or at the head of a sentence (でない音) is the verb.
|
package/dist/legal-address.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legal-address.d.ts","sourceRoot":"","sources":["../src/legal-address.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,MAAsF,CAAC"}
|
package/dist/legal-address.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 「第二十二条第二項」は法令の番地の書き方で、漢数字で書く決まりだから割りようがない。「第」と「条」「項」「号」が
|
|
3
|
-
* 語の切れ目を示しているので、読み手が区切りを探すこともない。番地は漢字の連なりに数えず、前後を切る区切りとして扱う。
|
|
4
|
-
*/
|
|
5
|
-
const KANJI_NUMERAL = "[〇一二三四五六七八九十百千]+";
|
|
6
|
-
const ADDRESS_UNIT = "[条項号章節款目編]";
|
|
7
|
-
const ADDRESS = `第${KANJI_NUMERAL}${ADDRESS_UNIT}(?:の${KANJI_NUMERAL})*`;
|
|
8
|
-
/**
|
|
9
|
-
* 番地は、法令が番地に付ける語(各号・及び・本文・後段 …)を挟んで続き、全体が漢字以外で終わる。
|
|
10
|
-
* 「第一条件」「第五条中央銀行」「第五条第五項中央銀行」は番地の後ろに普通の語が続くので、番地として扱わない。
|
|
11
|
-
*/
|
|
12
|
-
const CONNECTIVE = `(?:各号|各項|及|又|若|並|中|本文|前段|後段|但書|同条|乃至)*`;
|
|
13
|
-
const ADDRESS_CHAIN = new RegExp(`${ADDRESS}(?:${CONNECTIVE}${ADDRESS})*${CONNECTIVE}(?=[^\\p{Script=Han}]|$)`, "gu");
|
|
14
|
-
const ADDRESS_IN_CHAIN = new RegExp(ADDRESS, "gu");
|
|
15
|
-
export const maskLegalAddresses = (text) => text.replace(ADDRESS_CHAIN, (chain) => chain.replace(ADDRESS_IN_CHAIN, " "));
|
|
16
|
-
//# sourceMappingURL=legal-address.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legal-address.js","sourceRoot":"","sources":["../src/legal-address.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,aAAa,GAAG,kBAAkB,CAAC;AACzC,MAAM,YAAY,GAAG,YAAY,CAAC;AAElC,MAAM,OAAO,GAAG,IAAI,aAAa,GAAG,YAAY,OAAO,aAAa,IAAI,CAAC;AAEzE;;;GAGG;AACH,MAAM,UAAU,GAAG,wCAAwC,CAAC;AAC5D,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,GAAG,OAAO,MAAM,UAAU,GAAG,OAAO,KAAK,UAAU,0BAA0B,EAAE,IAAI,CAAC,CAAC;AACtH,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,CAAC"}
|