chaffjs 0.38.0 → 0.40.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 +21 -4
- package/README.md +20 -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 +54 -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/alternative-words.d.ts +6 -0
- package/dist/alternative-words.d.ts.map +1 -1
- package/dist/alternative-words.js +10 -0
- package/dist/alternative-words.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/closing-code.d.ts +8 -0
- package/dist/closing-code.d.ts.map +1 -0
- package/dist/closing-code.js +18 -0
- package/dist/closing-code.js.map +1 -0
- 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/date-format.d.ts +19 -1
- package/dist/date-format.d.ts.map +1 -1
- package/dist/date-format.js +41 -5
- package/dist/date-format.js.map +1 -1
- package/dist/detectors/acronym-context.d.ts +5 -2
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +19 -4
- 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-mention.d.ts +5 -0
- package/dist/detectors/acronym-mention.d.ts.map +1 -1
- package/dist/detectors/acronym-mention.js +16 -0
- package/dist/detectors/acronym-mention.js.map +1 -1
- package/dist/detectors/acronym-name.d.ts +14 -2
- package/dist/detectors/acronym-name.d.ts.map +1 -1
- package/dist/detectors/acronym-name.js +28 -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/blank-runs.d.ts +12 -0
- package/dist/detectors/blank-runs.d.ts.map +1 -0
- package/dist/detectors/blank-runs.js +27 -0
- package/dist/detectors/blank-runs.js.map +1 -0
- 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/bold-label.d.ts +3 -1
- package/dist/detectors/bold-label.d.ts.map +1 -1
- package/dist/detectors/bold-label.js +16 -6
- package/dist/detectors/bold-label.js.map +1 -1
- package/dist/detectors/capitalised-term.d.ts.map +1 -1
- package/dist/detectors/capitalised-term.js +28 -9
- package/dist/detectors/capitalised-term.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 +9 -0
- package/dist/detectors/citation-string.d.ts.map +1 -0
- package/dist/detectors/citation-string.js +86 -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/contraction-emphasis.d.ts +3 -0
- package/dist/detectors/contraction-emphasis.d.ts.map +1 -0
- package/dist/detectors/contraction-emphasis.js +24 -0
- package/dist/detectors/contraction-emphasis.js.map +1 -0
- package/dist/detectors/contraction-mention.d.ts +12 -1
- package/dist/detectors/contraction-mention.d.ts.map +1 -1
- package/dist/detectors/contraction-mention.js +39 -6
- package/dist/detectors/contraction-mention.js.map +1 -1
- package/dist/detectors/contraction-mix.d.ts +3 -0
- package/dist/detectors/contraction-mix.d.ts.map +1 -0
- package/dist/detectors/contraction-mix.js +69 -0
- package/dist/detectors/contraction-mix.js.map +1 -0
- 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/date-format.d.ts.map +1 -1
- package/dist/detectors/date-format.js +13 -1
- package/dist/detectors/date-format.js.map +1 -1
- package/dist/detectors/duplicate-definition.d.ts +3 -0
- package/dist/detectors/duplicate-definition.d.ts.map +1 -0
- package/dist/detectors/duplicate-definition.js +16 -0
- package/dist/detectors/duplicate-definition.js.map +1 -0
- 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/final-period-captions.d.ts +15 -0
- package/dist/detectors/final-period-captions.d.ts.map +1 -0
- package/dist/detectors/final-period-captions.js +61 -0
- package/dist/detectors/final-period-captions.js.map +1 -0
- 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/heading-sentences.d.ts +10 -0
- package/dist/detectors/heading-sentences.d.ts.map +1 -0
- package/dist/detectors/heading-sentences.js +32 -0
- package/dist/detectors/heading-sentences.js.map +1 -0
- 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 +1 -2
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +16 -57
- 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 +7 -2
- package/dist/detectors/list-lead-in.d.ts.map +1 -1
- package/dist/detectors/list-lead-in.js +67 -6
- 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/missing-final-period.d.ts.map +1 -1
- package/dist/detectors/missing-final-period.js +3 -1
- package/dist/detectors/missing-final-period.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/numbering-readings.d.ts +2 -2
- package/dist/detectors/numbering-readings.d.ts.map +1 -1
- package/dist/detectors/numbering-readings.js +7 -0
- package/dist/detectors/numbering-readings.js.map +1 -1
- package/dist/detectors/open-end-anaphor.d.ts +8 -0
- package/dist/detectors/open-end-anaphor.d.ts.map +1 -0
- package/dist/detectors/open-end-anaphor.js +22 -0
- package/dist/detectors/open-end-anaphor.js.map +1 -0
- package/dist/detectors/open-end-lead.d.ts +4 -0
- package/dist/detectors/open-end-lead.d.ts.map +1 -0
- package/dist/detectors/open-end-lead.js +34 -0
- package/dist/detectors/open-end-lead.js.map +1 -0
- package/dist/detectors/open-end-scope.d.ts.map +1 -1
- package/dist/detectors/open-end-scope.js +7 -1
- package/dist/detectors/open-end-scope.js.map +1 -1
- package/dist/detectors/ordinal-run-gaps.d.ts +1 -0
- package/dist/detectors/ordinal-run-gaps.d.ts.map +1 -1
- package/dist/detectors/ordinal-run-gaps.js +1 -1
- package/dist/detectors/ordinal-run-gaps.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 +37 -0
- package/dist/detectors/orthographic-variant-open.d.ts.map +1 -0
- package/dist/detectors/orthographic-variant-open.js +81 -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/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +14 -5
- package/dist/detectors/orthography.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/placeholder-text.d.ts.map +1 -1
- package/dist/detectors/placeholder-text.js +14 -2
- package/dist/detectors/placeholder-text.js.map +1 -1
- 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/quote-without-source.d.ts +6 -2
- package/dist/detectors/quote-without-source.d.ts.map +1 -1
- package/dist/detectors/quote-without-source.js +33 -8
- package/dist/detectors/quote-without-source.js.map +1 -1
- 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-separate-part.d.ts +7 -0
- package/dist/detectors/register-separate-part.d.ts.map +1 -0
- package/dist/detectors/register-separate-part.js +32 -0
- package/dist/detectors/register-separate-part.js.map +1 -0
- 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/contraction-mix.js +1 -1
- package/dist/detectors/registry/contraction-mix.js.map +1 -1
- package/dist/detectors/registry/duplicate-definition.js +1 -1
- package/dist/detectors/registry/duplicate-definition.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/reproduced-text.d.ts +5 -0
- package/dist/detectors/reproduced-text.d.ts.map +1 -0
- package/dist/detectors/reproduced-text.js +19 -0
- package/dist/detectors/reproduced-text.js.map +1 -0
- package/dist/detectors/request-owner.d.ts +2 -1
- package/dist/detectors/request-owner.d.ts.map +1 -1
- package/dist/detectors/request-owner.js +31 -7
- package/dist/detectors/request-owner.js.map +1 -1
- package/dist/detectors/requirement-smell.d.ts.map +1 -1
- package/dist/detectors/requirement-smell.js +16 -5
- package/dist/detectors/requirement-smell.js.map +1 -1
- package/dist/detectors/sentence-counts.d.ts +2 -1
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +23 -7
- package/dist/detectors/sentence-counts.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts +7 -1
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +47 -11
- 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 +37 -12
- 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 +11 -0
- package/dist/detectors/sentence-parts.d.ts.map +1 -0
- package/dist/detectors/sentence-parts.js +64 -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 +18 -167
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/spelling-variety.d.ts.map +1 -1
- package/dist/detectors/spelling-variety.js +20 -2
- package/dist/detectors/spelling-variety.js.map +1 -1
- package/dist/detectors/structure-tree.d.ts +2 -1
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +3 -8
- 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 +43 -16
- 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 +33 -16
- 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/undefined-term.d.ts +5 -0
- package/dist/detectors/undefined-term.d.ts.map +1 -1
- package/dist/detectors/undefined-term.js +22 -1
- package/dist/detectors/undefined-term.js.map +1 -1
- package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
- package/dist/detectors/unfilled-placeholder.js +15 -1
- package/dist/detectors/unfilled-placeholder.js.map +1 -1
- package/dist/detectors/unknown-word-context.d.ts +35 -0
- package/dist/detectors/unknown-word-context.d.ts.map +1 -0
- package/dist/detectors/unknown-word-context.js +100 -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 +17 -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/latin-spacing-source.d.ts +12 -0
- package/dist/latin-spacing-source.d.ts.map +1 -0
- package/dist/latin-spacing-source.js +25 -0
- package/dist/latin-spacing-source.js.map +1 -0
- 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-separator.d.ts.map +1 -1
- package/dist/name-separator.js +4 -1
- package/dist/name-separator.js.map +1 -1
- 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/paragraph-length.d.ts +14 -0
- package/dist/paragraph-length.d.ts.map +1 -1
- package/dist/paragraph-length.js +25 -0
- package/dist/paragraph-length.js.map +1 -1
- package/dist/paragraph-runs.d.ts +2 -2
- package/dist/paragraph-runs.d.ts.map +1 -1
- package/dist/paragraph-runs.js +65 -14
- package/dist/paragraph-runs.js.map +1 -1
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/quote-echo.d.ts +6 -0
- package/dist/quote-echo.d.ts.map +1 -0
- package/dist/quote-echo.js +14 -0
- package/dist/quote-echo.js.map +1 -0
- 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 +15 -2
- 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/set-phrase-particles.d.ts +4 -0
- package/dist/set-phrase-particles.d.ts.map +1 -0
- package/dist/set-phrase-particles.js +26 -0
- package/dist/set-phrase-particles.js.map +1 -0
- 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/alternative-clause.d.ts +7 -0
- package/dist/structure/alternative-clause.d.ts.map +1 -1
- package/dist/structure/alternative-clause.js +23 -8
- package/dist/structure/alternative-clause.js.map +1 -1
- package/dist/structure/cited-document-section.d.ts +2 -0
- package/dist/structure/cited-document-section.d.ts.map +1 -1
- package/dist/structure/cited-document-section.js +23 -1
- package/dist/structure/cited-document-section.js.map +1 -1
- package/dist/structure/issues.d.ts +4 -2
- package/dist/structure/issues.d.ts.map +1 -1
- package/dist/structure/issues.js +17 -9
- package/dist/structure/issues.js.map +1 -1
- package/dist/structure/numbering.d.ts +10 -1
- package/dist/structure/numbering.d.ts.map +1 -1
- package/dist/structure/numbering.js +41 -4
- package/dist/structure/numbering.js.map +1 -1
- package/dist/structure/unread-label.d.ts +13 -0
- package/dist/structure/unread-label.d.ts.map +1 -0
- package/dist/structure/unread-label.js +70 -0
- package/dist/structure/unread-label.js.map +1 -0
- 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 +90 -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 +12 -3
- package/rules/ai-structure.yaml +7 -6
- package/rules/ai-tell.yaml +10 -6
- package/rules/all-caps-shouting.yaml +2 -2
- package/rules/bold-emphasis.yaml +5 -4
- package/rules/bold-label-list.yaml +6 -6
- 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/contraction-consistency.yaml +2 -2
- package/rules/contrast-framing.yaml +16 -13
- package/rules/dangling-reference.yaml +2 -2
- package/rules/date-format-consistency.yaml +2 -2
- package/rules/duplicate-definition.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/honesty-marker.yaml +84 -0
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/kutoten-consistency.yaml +4 -4
- package/rules/latin-spacing.yaml +6 -4
- package/rules/list-item-form-mix.yaml +2 -2
- package/rules/max-kanji-continuous.yaml +7 -3
- package/rules/max-paragraph-length.yaml +2 -2
- package/rules/max-sentence-length.yaml +6 -2
- package/rules/missing-final-period.yaml +2 -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/nominalization.yaml +1 -1
- package/rules/numbering-gap.yaml +2 -2
- package/rules/one-sentence-paragraph-run.yaml +2 -2
- 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/quote-without-source.yaml +2 -2
- package/rules/request-without-deadline.yaml +2 -2
- package/rules/requirement-smell.yaml +2 -2
- package/rules/rule-of-three.yaml +3 -3
- package/rules/section-length-uniformity.yaml +2 -2
- package/rules/spelling-consistency.yaml +4 -4
- package/rules/teki-overuse.yaml +2 -2
- package/rules/topic-predicate-distance.yaml +3 -2
- package/rules/undefined-acronym.yaml +9 -2
- package/rules/undefined-term.yaml +2 -2
- package/rules/unfilled-placeholder.yaml +2 -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 +39 -6
- package/src/acronym-expansion.ts +57 -0
- package/src/ai-score/human-shares.ts +54 -12
- package/src/ai-score/of-document.ts +5 -2
- package/src/alternative-words.ts +15 -0
- 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/closing-code.ts +21 -0
- package/src/commands/fix-plan.ts +72 -5
- package/src/commands/test.ts +18 -2
- package/src/date-format.ts +54 -7
- package/src/detectors/acronym-context.ts +23 -4
- package/src/detectors/acronym-expansion.ts +26 -0
- package/src/detectors/acronym-gloss.ts +123 -0
- package/src/detectors/acronym-mention.ts +17 -0
- package/src/detectors/acronym-name.ts +40 -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/blank-runs.ts +30 -0
- package/src/detectors/bold-emphasis-form.ts +58 -0
- package/src/detectors/bold-emphasis.ts +16 -17
- package/src/detectors/bold-label.ts +22 -6
- package/src/detectors/capitalised-term.ts +36 -9
- 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 +93 -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/contraction-emphasis.ts +46 -0
- package/src/detectors/contraction-mention.ts +52 -6
- package/src/detectors/contraction-mix.ts +94 -0
- package/src/detectors/contrast-frame.ts +65 -7
- package/src/detectors/coordinate-adjective.ts +4 -2
- package/src/detectors/date-format.ts +18 -2
- package/src/detectors/duplicate-definition.ts +21 -0
- 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/final-period-captions.ts +78 -0
- 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/heading-sentences.ts +36 -0
- 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 +20 -63
- 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 +88 -7
- 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/missing-final-period.ts +9 -1
- 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/numbering-readings.ts +10 -2
- package/src/detectors/open-end-anaphor.ts +31 -0
- package/src/detectors/open-end-lead.ts +46 -0
- package/src/detectors/open-end-scope.ts +8 -1
- package/src/detectors/ordinal-run-gaps.ts +1 -1
- package/src/detectors/organisation-run.ts +26 -2
- package/src/detectors/orthographic-variant-open.ts +124 -0
- package/src/detectors/orthographic-variant.ts +82 -82
- package/src/detectors/orthography.ts +20 -7
- 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/placeholder-text.ts +21 -4
- package/src/detectors/proper-noun-density.ts +109 -0
- package/src/detectors/quote-without-source.ts +52 -10
- 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-separate-part.ts +42 -0
- 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/contraction-mix.ts +1 -1
- package/src/detectors/registry/duplicate-definition.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/reproduced-text.ts +33 -0
- package/src/detectors/request-owner.ts +31 -8
- package/src/detectors/requirement-smell.ts +21 -5
- package/src/detectors/sentence-counts.ts +27 -7
- package/src/detectors/sentence-ending.ts +66 -14
- package/src/detectors/sentence-length.ts +43 -11
- package/src/detectors/sentence-load.ts +3 -6
- package/src/detectors/sentence-parts.ts +73 -0
- package/src/detectors/sentence-title.ts +14 -0
- package/src/detectors/signals.ts +20 -202
- package/src/detectors/spelling-variety.ts +26 -2
- package/src/detectors/structure-tree.ts +5 -9
- package/src/detectors/structure.ts +47 -19
- 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 +40 -18
- package/src/detectors/topic-predicate-distance.ts +25 -0
- package/src/detectors/undefined-term.ts +26 -1
- package/src/detectors/unfilled-placeholder.ts +20 -2
- package/src/detectors/unknown-word-context.ts +129 -0
- package/src/detectors/unknown-word.ts +29 -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/latin-spacing-source.ts +33 -0
- package/src/law-title.ts +38 -0
- package/src/name-ending-run.ts +49 -0
- package/src/name-separator.ts +4 -1
- 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/paragraph-length.ts +31 -0
- package/src/paragraph-runs.ts +71 -13
- package/src/plugin.ts +2 -0
- package/src/quote-echo.ts +18 -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 +16 -3
- package/src/sentence-load.ts +5 -3
- package/src/set-phrase-particles.ts +32 -0
- package/src/spelling.ts +37 -7
- package/src/structure/alternative-clause.ts +32 -7
- package/src/structure/cited-document-section.ts +24 -1
- package/src/structure/issues.ts +29 -10
- package/src/structure/numbering.ts +50 -3
- package/src/structure/unread-label.ts +74 -0
- package/src/structure-shape/template-outline.ts +34 -0
- package/src/title-case-name.ts +55 -0
- package/src/topic-clause.ts +110 -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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Lexicon, LexiconEntry, Sentence, Token } from "../plugin.ts";
|
|
2
|
+
import { entryEndsAt, entryRanges, type TokenRange } from "./lexicon-match.ts";
|
|
3
|
+
import { phraseEnd } from "./superlative-scope.ts";
|
|
4
|
+
|
|
5
|
+
/** 最上級の周りで、比べて言い切ってはいないことを示す語。どれも言語パッケージの語彙表が持つ。 */
|
|
6
|
+
export type Context = {
|
|
7
|
+
/** 求める・選ぶ動詞(achieve・decide・求める)。position は最上級のどちら側に立つか。 */
|
|
8
|
+
readonly goals: Lexicon;
|
|
9
|
+
/** 述語の後ろで、どれが最もなのかを指す語(the one・the second)。 */
|
|
10
|
+
readonly referents: Lexicon;
|
|
11
|
+
/** 誰にとっての最もなのかを言う語(にとって)。 */
|
|
12
|
+
readonly viewpoints: Lexicon;
|
|
13
|
+
/** 全体の部分を言う名詞(part・role・step)。 */
|
|
14
|
+
readonly parts: Lexicon;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** 語彙表の語が最上級まで届く語の数。これより離れた動詞は、間に別の目的語や節がある。 */
|
|
18
|
+
const GOAL_REACH = 4;
|
|
19
|
+
|
|
20
|
+
/** 文の終わりの記号の後ろに付く、閉じの記号と強調の印(?」・?**)。 */
|
|
21
|
+
const CLOSING = new Set(" \t\n*_\"'”’」』))]");
|
|
22
|
+
const QUESTION = new Set(["?", "?"]);
|
|
23
|
+
|
|
24
|
+
/** 問いの文(What takes the longest?・最も良い道は何か?)。問う文は何かが一番だと言い切っていない。 */
|
|
25
|
+
export const asked = (sentence: Sentence): boolean => {
|
|
26
|
+
const chars = [...sentence.text];
|
|
27
|
+
return QUESTION.has(chars[chars.findLastIndex((char) => !CLOSING.has(char))] ?? "");
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** 語彙表から、最上級の周りを読む語を集める。 */
|
|
31
|
+
export const contextOf = (lexicons: Readonly<Record<string, Lexicon>>): Context => ({
|
|
32
|
+
goals: lexicons["superlative-goal"] ?? [],
|
|
33
|
+
referents: lexicons["superlative-referent"] ?? [],
|
|
34
|
+
viewpoints: lexicons["superlative-viewpoint"] ?? [],
|
|
35
|
+
parts: lexicons["superlative-part"] ?? [],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const isPunct = (token: Token | undefined): boolean => token === undefined || token.pos === "PUNCT";
|
|
39
|
+
|
|
40
|
+
/** from 番目から to 番目の手前までに句読点が無いか。句読点を越えた語は別の節にかかる。 */
|
|
41
|
+
const sameClause = (tokens: readonly Token[], from: number, to: number): boolean => !tokens.slice(from, to).some((token) => isPunct(token));
|
|
42
|
+
|
|
43
|
+
/** 語彙の語が、最上級の手前 reach 語までのどこかで終わり、間に句読点が無いか。 */
|
|
44
|
+
const endsBefore = (tokens: readonly Token[], range: TokenRange, entry: LexiconEntry, reach: number): boolean => {
|
|
45
|
+
const ends = Array.from({ length: Math.min(reach, range.start) + 1 }, (_unused, back) => range.start - back);
|
|
46
|
+
return ends.some((end) => entryEndsAt(tokens, entry, end) && sameClause(tokens, end, range.start));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** 語彙の語が最上級より後ろにあるか。 */
|
|
50
|
+
const after = (sentence: Sentence, range: TokenRange, entry: LexiconEntry): boolean => entryRanges(sentence, entry).some((found) => found.start >= range.end);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 最上級が、求めるか選ぶものとして書かれているか(achieve the best results・decide the best way・最高の規律が求められる)。
|
|
54
|
+
* 目指す先や選ぶ基準を言っていて、何かが一番だという主張ではない。英語の動詞は最上級の前に、日本語の述語は後ろに来る。
|
|
55
|
+
*/
|
|
56
|
+
export const sought = (sentence: Sentence, range: TokenRange, goals: Lexicon): boolean => {
|
|
57
|
+
const tokens = sentence.tokens ?? [];
|
|
58
|
+
return goals.some((entry) => (entry.position === "after" ? after(sentence, range, entry) : endsBefore(tokens, range, entry, GOAL_REACH)));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const isWord = (token: Token | undefined, words: Lexicon): boolean =>
|
|
62
|
+
token !== undefined && words.some((entry) => entry.pattern.toLowerCase() === token.surface.toLowerCase());
|
|
63
|
+
|
|
64
|
+
const VERBAL = new Set(["VERB", "AUX"]);
|
|
65
|
+
|
|
66
|
+
const isVerbal = (token: Token | undefined): boolean => VERBAL.has(token?.pos ?? "");
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 名詞句の後ろの述語の動詞。数(the best one is)の後ろの動詞は修飾として句に読み込まれるので、句の最後の語も見る。
|
|
70
|
+
*/
|
|
71
|
+
const verbAt = (tokens: readonly Token[], range: TokenRange, end: number): number | undefined => {
|
|
72
|
+
if (isVerbal(tokens[end])) return end;
|
|
73
|
+
return end - 1 > range.end && isVerbal(tokens[end - 1]) ? end - 1 : undefined;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 最上級の名詞句が主語で、述語がどれかを指しているか(The best plan is the one you keep・The most important divergence is
|
|
78
|
+
* the second)。どれが一番なのかを決める言い方で、一番だという主張ではない。
|
|
79
|
+
*/
|
|
80
|
+
export const pointsAtReferent = (tokens: readonly Token[], range: TokenRange, referents: Lexicon): boolean => {
|
|
81
|
+
const end = phraseEnd(tokens, range.end);
|
|
82
|
+
const at = verbAt(tokens, range, end);
|
|
83
|
+
if (at === undefined) return false;
|
|
84
|
+
const next = tokens[at + 1]?.pos === "DET" ? at + 2 : at + 1;
|
|
85
|
+
return isWord(tokens[next], referents);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** 誰にとっての最もなのかが、同じ節の最上級より前にあるか(俺にとって今日は最高の日だ)。 */
|
|
89
|
+
export const viewpointBefore = (tokens: readonly Token[], range: TokenRange, viewpoints: Lexicon): boolean =>
|
|
90
|
+
viewpoints.some((entry) => endsBefore(tokens, range, entry, range.start));
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 最上級の名詞が全体の部分を言うか(the most important part・the most important role)。比べているのは、文章が述べている
|
|
94
|
+
* 全体の部分どうしで、世の中のものと比べた主張ではない。名詞は最上級の修飾の後ろに来る(英語)。
|
|
95
|
+
*/
|
|
96
|
+
export const ranksParts = (tokens: readonly Token[], range: TokenRange, parts: Lexicon): boolean => {
|
|
97
|
+
const at = phraseEnd(tokens, range.end);
|
|
98
|
+
return at > range.end && isWord(tokens[at - 1], parts);
|
|
99
|
+
};
|
|
@@ -8,14 +8,20 @@ import type { TokenRange } from "./lexicon-match.ts";
|
|
|
8
8
|
export type ScopeMarkers = {
|
|
9
9
|
/** 最上級の直前に置く語(で)。その前に固有名詞か地名が要る。 */
|
|
10
10
|
readonly before: Lexicon;
|
|
11
|
-
/** 最上級の名詞句の直後に置く語(in・of
|
|
11
|
+
/** 最上級の名詞句の直後に置く語(in・of)。その後ろに名詞句か動名詞が要る。 */
|
|
12
12
|
readonly after: Lexicon;
|
|
13
|
+
/** 名詞句の直後で、動名詞が続くときだけ範囲を言う語(the best tool for creating)。for + 名詞(the best opportunity for government)は受け手。 */
|
|
14
|
+
readonly purposes: Lexicon;
|
|
15
|
+
/** 名前でなくても、範囲の「で」の前で範囲になる名詞(世界で唯一の・業界で最も)。 */
|
|
16
|
+
readonly realms: Lexicon;
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
/** 語彙表の position で分ける。position の無い語は、どちら側の語か分からないので使わない。 */
|
|
16
|
-
export const scopeMarkersOf = (lexicon: Lexicon): ScopeMarkers => ({
|
|
20
|
+
export const scopeMarkersOf = (lexicon: Lexicon, purposes: Lexicon = [], realms: Lexicon = []): ScopeMarkers => ({
|
|
17
21
|
before: lexicon.filter((entry) => entry.position === "before"),
|
|
18
22
|
after: lexicon.filter((entry) => entry.position === "after"),
|
|
23
|
+
purposes,
|
|
24
|
+
realms,
|
|
19
25
|
});
|
|
20
26
|
|
|
21
27
|
const NOMINAL = new Set(["NOUN", "PROPN"]);
|
|
@@ -54,9 +60,12 @@ const clauseBefore = (tokens: readonly Token[], range: TokenRange): boolean => {
|
|
|
54
60
|
return before !== undefined && first !== undefined && CLAUSE_END.has(before.pos) && before.surface === before.lemma && before.span.end === first.span.start;
|
|
55
61
|
};
|
|
56
62
|
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
/**
|
|
64
|
+
* 名前 + 範囲の語 + 最上級(日本で最も・トヨタで最も・東京都で最大)。「費用で最大の効果」の「費用」は名前ではないので範囲にしない。
|
|
65
|
+
* 名前でなくても、場や分野を言う名詞(世界で唯一の)は範囲。その名詞は言語パッケージの語彙表 superlative-realm が持つ。
|
|
66
|
+
*/
|
|
67
|
+
const namedBefore = (tokens: readonly Token[], range: TokenRange, markers: ScopeMarkers): boolean =>
|
|
68
|
+
isMarker(tokens[range.start - 1], markers.before) && (isNamed(tokens[range.start - 2]) || isMarker(tokens[range.start - 2], markers.realms));
|
|
60
69
|
|
|
61
70
|
const HYPHENS = new Set(["-", "\u2010", "\u2011"]);
|
|
62
71
|
|
|
@@ -85,14 +94,23 @@ export const phraseEnd = (tokens: readonly Token[], at: number, nounSeen = false
|
|
|
85
94
|
}
|
|
86
95
|
};
|
|
87
96
|
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
const isGerund = (token: Token | undefined): boolean => token?.features?.["VerbForm"] === "Ger";
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 最上級 + 名詞句 + 範囲の語 + 名詞句か動名詞(the best pizza in Chicago・the most famous of the sculptures・the most common
|
|
101
|
+
* form of debunking)。目的の語(for)は動名詞が続くときだけ(the most important tool for creating the culture)。
|
|
102
|
+
* 動名詞は、最上級に名詞が付いているときだけ範囲を言う。名詞の無い the best in helping teams は何の中で一番なのかを言っていない。
|
|
103
|
+
*/
|
|
104
|
+
const phraseAfter = (tokens: readonly Token[], range: TokenRange, markers: ScopeMarkers): boolean => {
|
|
90
105
|
const at = phraseEnd(tokens, range.end);
|
|
91
106
|
const last = tokens[at - 1];
|
|
92
107
|
const endsPhrase = at === range.end || (last !== undefined && PHRASE_END.has(last.pos));
|
|
93
108
|
const opens = tokens[at + 1];
|
|
94
|
-
|
|
109
|
+
if (!endsPhrase || opens === undefined) return false;
|
|
110
|
+
const gerund = at > range.end && isGerund(opens);
|
|
111
|
+
const scope = isMarker(tokens[at], markers.after) && (PHRASE_START.has(opens.pos) || gerund);
|
|
112
|
+
return scope || (isMarker(tokens[at], markers.purposes) && gerund);
|
|
95
113
|
};
|
|
96
114
|
|
|
97
115
|
export const scoped = (tokens: readonly Token[], range: TokenRange, markers: ScopeMarkers): boolean =>
|
|
98
|
-
compound(tokens, range) || clauseBefore(tokens, range) || namedBefore(tokens, range, markers
|
|
116
|
+
compound(tokens, range) || clauseBefore(tokens, range) || namedBefore(tokens, range, markers) || phraseAfter(tokens, range, markers);
|
package/src/detectors/team.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { proseText } from "../measure.ts";
|
|
2
1
|
import { joinWords } from "./word-list.ts";
|
|
3
|
-
import { wordsOf } from "./structure.ts";
|
|
4
|
-
import { nameSpans } from "../team-names.ts";
|
|
5
2
|
import { conjugatedSpans } from "./conjugated-entry.ts";
|
|
6
|
-
import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence
|
|
3
|
+
import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence } from "../plugin.ts";
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* チームの言葉。社内でしか通じない語を、チームが chaff.yaml に自分で並べる。
|
|
@@ -77,49 +74,3 @@ export const requiredSections: Detector = (doc, options): Finding[] => {
|
|
|
77
74
|
},
|
|
78
75
|
];
|
|
79
76
|
};
|
|
80
|
-
|
|
81
|
-
const PER = 1000;
|
|
82
|
-
|
|
83
|
-
/** 密度を見る rule は短い文書を測らない。単位は言語で違うので床も分ける。 */
|
|
84
|
-
const FLOOR = { word: 200, char: 500 };
|
|
85
|
-
|
|
86
|
-
const isProperNoun = (token: Token): boolean => token.pos === "PROPN";
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 固有名詞の密度。製品名・社名・人名が続くと、知らない読者は文の骨組みを見失う。
|
|
90
|
-
*
|
|
91
|
-
* spec は未知語率としていたが、**品詞解析があれば PROPN を数えるだけで足りる**。
|
|
92
|
-
* 辞書を別に持つ必要はない。
|
|
93
|
-
*/
|
|
94
|
-
const within = (spans: readonly Span[], token: Token): Span | undefined => spans.find((span) => token.span.start >= span.start && token.span.end <= span.end);
|
|
95
|
-
|
|
96
|
-
/** 並べた名前は、何語に割れても 1 つの固有名詞(Bank of England は 2 つでなく 1 つ)。名前の中の 2 語目からを落とす。 */
|
|
97
|
-
const properNounsOf = (sentence: Sentence, names: readonly string[]): Token[] => {
|
|
98
|
-
const named = nameSpans(sentence.text, names).map((span) => ({ start: sentence.span.start + span.start, end: sentence.span.start + span.end }));
|
|
99
|
-
const counted = new Set<Span>();
|
|
100
|
-
return (sentence.tokens ?? []).filter(isProperNoun).filter((token) => {
|
|
101
|
-
const name = within(named, token);
|
|
102
|
-
if (name === undefined) return true;
|
|
103
|
-
if (counted.has(name)) return false;
|
|
104
|
-
counted.add(name);
|
|
105
|
-
return true;
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const properNounDensity: Detector = (doc, options): Finding[] => {
|
|
110
|
-
const hits = doc.sentences.flatMap((sentence) => properNounsOf(sentence, doc.names ?? []).map((token) => ({ sentence, token })));
|
|
111
|
-
const length = wordsOf(doc);
|
|
112
|
-
const rate = length === 0 ? 0 : Math.round((hits.length / length) * PER);
|
|
113
|
-
const first = hits[0];
|
|
114
|
-
if (length < FLOOR[doc.lengthUnit] || first === undefined || rate <= options.limit) return [];
|
|
115
|
-
return [
|
|
116
|
-
{
|
|
117
|
-
rule: "proper-noun-density",
|
|
118
|
-
severity: "info",
|
|
119
|
-
line: 0,
|
|
120
|
-
column: 0,
|
|
121
|
-
quote: proseText(first.sentence),
|
|
122
|
-
values: { count: hits.length, density: rate, limit: options.limit, offset: first.token.span.start },
|
|
123
|
-
},
|
|
124
|
-
];
|
|
125
|
-
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { oneOf } from "./acronym-name.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 巻の番号と区分で引く法令集の名前(21 CFR subpart J、21 CFR chapter I、40 CFR subchapter C)。巻の番号の後ろの名前に、
|
|
5
|
+
* 区分の語と、その番号(数字、ローマ数字、1 文字の大文字)が続く形だけ。語は語彙表 citation-series から読む。区分の番号が続かない所
|
|
6
|
+
* (The 2 CFR export was generated)は法令集そのものを言うので、略語のまま数える。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type Span = { readonly start: number; readonly end: number };
|
|
10
|
+
|
|
11
|
+
const TITLE_NUMBER = String.raw`(?<![\p{L}\p{N}_.,])\d{1,3}[ \t]+`;
|
|
12
|
+
const DIVISION = String.raw`[ \t]+\p{L}+\.?[ \t]+`;
|
|
13
|
+
const DESIGNATOR = String.raw`(?:\d|[IVXLC]+(?![\p{L}\p{N}])|\p{Lu}(?![\p{L}\p{N}]))`;
|
|
14
|
+
|
|
15
|
+
export const titledCodeSpans = (text: string, series: readonly string[]): Span[] => {
|
|
16
|
+
if (series.length === 0) return [];
|
|
17
|
+
const pattern = new RegExp(String.raw`(?<=${TITLE_NUMBER})${oneOf(series)}(?=${DIVISION}${DESIGNATOR})`, "gu");
|
|
18
|
+
return [...text.matchAll(pattern)].map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
19
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Token } from "../plugin.ts";
|
|
1
|
+
import type { Span, Token } from "../plugin.ts";
|
|
2
2
|
import { quotedSpans } from "../quoted-span.ts";
|
|
3
3
|
|
|
4
4
|
/** 題の付いたものの名前を閉じる語(語彙表 title-ending: 〜要綱、〜試験、〜事業、〜法)。 */
|
|
@@ -22,11 +22,16 @@ const surfaceOf = (tokens: readonly Token[]): string => tokens.map((token) => to
|
|
|
22
22
|
* 連なりの語(run: 隙間なく並ぶ語)が、題の名前を閉じる語で終わるか。閉じる語は語の切れ目で始まる
|
|
23
23
|
* (地方自治法の「法」は語、解決方法の「法」は方法の一部)。閉じる語の前に 2 字以上の語が要る。
|
|
24
24
|
*/
|
|
25
|
-
export const endsInTitle = (run: readonly Token[], words: TitleWords): boolean =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
export const endsInTitle = (run: readonly Token[], words: TitleWords): boolean => titleBody(run, words) !== undefined;
|
|
26
|
+
|
|
27
|
+
/** endsInTitle のときの、閉じる語の前の字(愛玩動物看護師法の「愛玩動物看護師」)。閉じなければ undefined。 */
|
|
28
|
+
export const titleBody = (run: readonly Token[], words: TitleWords): string | undefined => {
|
|
29
|
+
const at = run.findIndex((_, index) => {
|
|
30
|
+
const tail = surfaceOf(run.slice(index));
|
|
31
|
+
return words.endings.includes(tail) && [...surfaceOf(run.slice(0, index))].length >= MIN_BODY_LENGTH;
|
|
29
32
|
});
|
|
33
|
+
return at < 0 ? undefined : surfaceOf(run.slice(0, at));
|
|
34
|
+
};
|
|
30
35
|
|
|
31
36
|
/**
|
|
32
37
|
* 文(text)の start から end までの連なりが、題の名前の置き方をしているか。
|
|
@@ -55,3 +60,15 @@ export const repeatedRuns = (runs: readonly string[]): Set<string> => {
|
|
|
55
60
|
const counts = runs.reduce((seen, run) => seen.set(run, (seen.get(run) ?? 0) + 1), new Map<string, number>());
|
|
56
61
|
return new Set([...counts].flatMap(([run, count]) => (count >= MIN_REPEATS ? [run] : [])));
|
|
57
62
|
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 連なりを含む括弧(brackets: 中身の範囲、文書全体の座標)のどれかが、法令の題(「〜に関する法律」、(〜法))か。
|
|
66
|
+
* 中身の語(tokens のうち括弧の中のもの)が法令の名前を閉じる語(fixedName)で終われば題。題は、中の語ごと変えられない名前。
|
|
67
|
+
*/
|
|
68
|
+
export const inStatuteTitle = (tokens: readonly Token[], brackets: readonly Span[], fixedName: TitleWords): boolean =>
|
|
69
|
+
brackets.some((bracket) =>
|
|
70
|
+
endsInTitle(
|
|
71
|
+
tokens.filter((token) => bracket.start <= token.span.start && token.span.end <= bracket.end),
|
|
72
|
+
fixedName,
|
|
73
|
+
),
|
|
74
|
+
);
|
|
@@ -5,7 +5,9 @@ import { externalLinkTitleSpans } from "../link-title.ts";
|
|
|
5
5
|
import type { Detector, Finding, Span, Token } from "../plugin.ts";
|
|
6
6
|
import { countedTokens, uncountedWordsOf, type UncountedWords } from "../uncounted-particles.ts";
|
|
7
7
|
import { honorificGroupParticles } from "../honorific-group.ts";
|
|
8
|
+
import { setPhraseParticles } from "../set-phrase-particles.ts";
|
|
8
9
|
import { noteSentences } from "../note-paragraphs.ts";
|
|
10
|
+
import { documentNameSpans } from "./particle-run-names.ts";
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* 文末が名詞で終わる(体言止め)。箇条書きでは普通だが、本文では文が途中で切れて読める。
|
|
@@ -64,6 +66,12 @@ const PARTICLE = new Set(["ADP", "SCONJ", "PART", "CCONJ"]);
|
|
|
64
66
|
|
|
65
67
|
const BREAK: Run = { surface: "", tokens: [] };
|
|
66
68
|
|
|
69
|
+
/** 括弧だけの語。解析器が括弧の続き(「分析】(1)経営成績」の「】(」)を名詞と読んでも、句読点と同じく句を閉じる。%や半角の・は句を閉じない。 */
|
|
70
|
+
const BRACKETS_ONLY = /^[\p{Ps}\p{Pe}]+$/u;
|
|
71
|
+
|
|
72
|
+
const breaksRun = (token: Token, breaks: readonly string[]): boolean =>
|
|
73
|
+
token.pos === "PUNCT" || PARTICLE.has(token.pos) || breaks.includes(token.surface) || BRACKETS_ONLY.test(token.surface);
|
|
74
|
+
|
|
67
75
|
/**
|
|
68
76
|
* 名詞は連なりの中身なので飛ばす。読点と、語彙表に無い助詞は連なりを切る。
|
|
69
77
|
* 「弊社のAはBの」を 2 回続いたと数えないため。「は」でいちど句が閉じている。
|
|
@@ -76,7 +84,7 @@ const runsOf = (tokens: readonly Token[], nesting: readonly string[], breaks: re
|
|
|
76
84
|
tokens.reduce<Run[]>((acc, token) => {
|
|
77
85
|
if (isWithinAny(quoted, token.span)) return acc;
|
|
78
86
|
if (nesting.includes(token.surface)) return extend(acc, token);
|
|
79
|
-
if (
|
|
87
|
+
if (breaksRun(token, breaks)) acc.push(BREAK);
|
|
80
88
|
return acc;
|
|
81
89
|
}, []);
|
|
82
90
|
|
|
@@ -86,11 +94,17 @@ const RUN_BREAK_LEXICON = "particle-run-break";
|
|
|
86
94
|
/** 人の集まりを敬って呼ぶ語(国民の皆様の「皆様」)。直前の助詞は呼び方の一部で、入れ子の輪に数えない。 */
|
|
87
95
|
const HONORIFIC_GROUP_LEXICON = "honorific-group";
|
|
88
96
|
|
|
89
|
-
/**
|
|
90
|
-
const
|
|
91
|
-
|
|
97
|
+
/** 助詞を挟んで一語のように読む決まった言い回し(おそれのある)。中の助詞は入れ子の輪に数えない。 */
|
|
98
|
+
const SET_PHRASE_LEXICON = "particle-run-set-phrase";
|
|
99
|
+
|
|
100
|
+
/** 敬って呼ぶ語(皆様)と決まった言い回し(おそれのある)。 */
|
|
101
|
+
type Phrases = { readonly groups: readonly string[]; readonly setPhrases: readonly string[] };
|
|
102
|
+
|
|
103
|
+
/** 数えない助詞(番号をつなぐ「の」、敬って呼ぶ語の前の「の」、決まった言い回しの中の「の」)を除いた語。 */
|
|
104
|
+
const chainTokens = (tokens: readonly Token[], numbering: UncountedWords, { groups, setPhrases }: Phrases): readonly Token[] => {
|
|
105
|
+
const uncounted = new Set([...honorificGroupParticles(tokens, numbering.particles, groups), ...setPhraseParticles(tokens, numbering.particles, setPhrases)]);
|
|
92
106
|
const counted = countedTokens(tokens, numbering);
|
|
93
|
-
return
|
|
107
|
+
return uncounted.size === 0 ? counted : counted.filter((token) => !uncounted.has(token));
|
|
94
108
|
};
|
|
95
109
|
|
|
96
110
|
export const doubledParticle: Detector = (doc, options): Finding[] => {
|
|
@@ -98,17 +112,25 @@ export const doubledParticle: Detector = (doc, options): Finding[] => {
|
|
|
98
112
|
const titles = externalLinkTitleSpans(doc.source, doc.links);
|
|
99
113
|
const breaks = (doc.lexicons[RUN_BREAK_LEXICON] ?? []).map((entry) => entry.pattern);
|
|
100
114
|
const numbering = uncountedWordsOf(doc.lexicons, nesting);
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
const phrases: Phrases = {
|
|
116
|
+
groups: (doc.lexicons[HONORIFIC_GROUP_LEXICON] ?? []).map((entry) => entry.pattern),
|
|
117
|
+
setPhrases: (doc.lexicons[SET_PHRASE_LEXICON] ?? []).map((entry) => entry.pattern),
|
|
118
|
+
};
|
|
119
|
+
const prose = doc.prose ?? doc.source;
|
|
120
|
+
return doc.sentences.flatMap((sentence) => {
|
|
121
|
+
const tokens = chainTokens(sentence.tokens ?? [], numbering, phrases);
|
|
122
|
+
const quoted = [...quotedIn(sentence), ...titles];
|
|
123
|
+
const longRuns = (skipped: readonly Span[]): Run[] => runsOf(tokens, nesting, breaks, skipped).filter((run) => run.tokens.length > options.limit);
|
|
124
|
+
const found = longRuns(quoted);
|
|
125
|
+
// 文書の名前を読むのは長い連なりのある文だけ。名前は位置ごとに読むので、全部の文で読むと遅い。
|
|
126
|
+
const runs = found.length === 0 ? found : longRuns([...quoted, ...documentNameSpans(prose, sentence.span, doc.namedDocument)]);
|
|
127
|
+
return runs.map((run) => ({
|
|
128
|
+
rule: "no-doubled-joshi",
|
|
129
|
+
severity: "warning" as const,
|
|
130
|
+
line: 0,
|
|
131
|
+
column: 0,
|
|
132
|
+
quote: sentence.text.trim(),
|
|
133
|
+
values: { word: run.surface, count: run.tokens.length, limit: options.limit, offset: run.tokens[0]?.span.start ?? sentence.span.start },
|
|
134
|
+
}));
|
|
135
|
+
});
|
|
114
136
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Detector, ProseDocument, Sentence } from "../plugin.ts";
|
|
2
|
+
import { topicDistance } from "../sentence-load.ts";
|
|
3
|
+
import type { TopicClauseWords } from "../topic-clause.ts";
|
|
4
|
+
import { isIn } from "../lexicon-genres.ts";
|
|
5
|
+
import { overLimit, ownTokens } from "./sentence-load.ts";
|
|
6
|
+
|
|
7
|
+
const CLOSER_LEXICON = "topic-clause-close";
|
|
8
|
+
const ARTICLE_LEXICON = "statute-article-opener";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether the sentence is an article of a statute quoted in another kind of document (第7条 … in a manual): the law's wording,
|
|
12
|
+
* which the writer cannot change. In a statute or a contract (its genre, or a profile chaff reads it by) the articles are its own.
|
|
13
|
+
*/
|
|
14
|
+
const quotesArticle = (doc: ProseDocument, genre: string | undefined): ((sentence: Sentence) => boolean) => {
|
|
15
|
+
if (doc.profile !== undefined || genre === undefined || isIn(genre, "legal")) return () => false;
|
|
16
|
+
const openers = (doc.lexicons[ARTICLE_LEXICON] ?? []).map((entry) => new RegExp(entry.pattern, "u"));
|
|
17
|
+
return (sentence) => openers.some((opener) => opener.test(sentence.text.trimStart()));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** The distance from the sentence's topic (〜は) to the end, where its predicate is. Needs the language's tokens. */
|
|
21
|
+
export const topicPredicateDistance: Detector = (doc, options) => {
|
|
22
|
+
const words: TopicClauseWords = { closers: (doc.lexicons[CLOSER_LEXICON] ?? []).map((entry) => entry.pattern) };
|
|
23
|
+
const quoted = quotesArticle(doc, options.genre);
|
|
24
|
+
return overLimit((sentence) => (sentence.tokens === undefined || quoted(sentence) ? undefined : topicDistance(ownTokens(sentence), words)))(doc, options);
|
|
25
|
+
};
|
|
@@ -49,6 +49,8 @@ export type TermWords = {
|
|
|
49
49
|
readonly named: readonly string[];
|
|
50
50
|
/** What turns a term into another one (本報告書等 after 本報告書): a group the document has to define on its own. */
|
|
51
51
|
readonly groupSuffixes: readonly string[];
|
|
52
|
+
/** The document takes the definitions of another one (本共同研究開発契約において定義した用語…同契約内の定義に従う). */
|
|
53
|
+
readonly inheritsDefinitions?: boolean;
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
const QUOTED = /[「『“"](?<term>[^「」『』“”"\n]{1,40})[」』”"]/gu;
|
|
@@ -84,17 +86,37 @@ const knownForms = (defined: readonly string[], groups: TermWords["prefixGroups"
|
|
|
84
86
|
...defined.flatMap((term) => prefixVariants(term, groups)),
|
|
85
87
|
];
|
|
86
88
|
|
|
89
|
+
/** Every character of the shorter one, in order, in the longer one (本学習モデル in 本学習済みモデル). */
|
|
90
|
+
const isSubsequence = (shorter: string, longer: string): boolean => {
|
|
91
|
+
const chars = Array.from(longer);
|
|
92
|
+
let at = 0;
|
|
93
|
+
return Array.from(shorter).every((char) => {
|
|
94
|
+
const found = chars.indexOf(char, at);
|
|
95
|
+
at = found + 1;
|
|
96
|
+
return found !== -1;
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** A slip for another term: the same prefix, its characters a part of the other's, and not the other's start (本学習モデル for 本学習済みモデル). */
|
|
101
|
+
const isSlipOf = (term: string, other: string, prefix: string): boolean =>
|
|
102
|
+
other.startsWith(prefix) && other.length > term.length && !other.startsWith(term) && isSubsequence(term, other);
|
|
103
|
+
|
|
87
104
|
/**
|
|
88
105
|
* The first use of each term written with the document's prefix and defined nowhere, when the document defines at
|
|
89
106
|
* least one term with that prefix (else the prefix is not its way of naming terms). A use that starts with a known
|
|
90
107
|
* form (本サービス上 where 本サービス is defined) is that term, unless the rest is a group's mark (本サービス等).
|
|
108
|
+
* A name of a document (本共同開発契約) is left like the document's name for itself, unless it is a slip for a defined term
|
|
109
|
+
* (本共同研究開発契約). A document that takes the definitions of another one has terms defined there: only a slip for
|
|
110
|
+
* another of its terms (本学習モデル beside 本学習済みモデル) is reported then.
|
|
91
111
|
*/
|
|
92
112
|
export const undefinedTerms = (source: string, sentences: readonly (readonly Token[])[], defined: readonly string[], words: TermWords): UndefinedTerm[] => {
|
|
93
113
|
const prefixes = words.prefixes.filter((prefix) => prefix !== "");
|
|
94
114
|
if (!defined.some((term) => hasPrefix(term, prefixes))) return [];
|
|
115
|
+
const selfNouns = words.selfNouns.filter((noun) => noun !== "");
|
|
95
116
|
const isSelf = (term: string, prefix: string): boolean => {
|
|
96
117
|
const rest = term.slice(prefix.length);
|
|
97
|
-
|
|
118
|
+
if (!selfNouns.some((noun) => rest.startsWith(noun) || rest.endsWith(noun))) return false;
|
|
119
|
+
return selfNouns.includes(rest) || !defined.some((other) => isSlipOf(term, other, prefix));
|
|
98
120
|
};
|
|
99
121
|
const runs = sentences.flatMap((tokens) =>
|
|
100
122
|
tokens.flatMap((token, index) => {
|
|
@@ -106,8 +128,10 @@ export const undefinedTerms = (source: string, sentences: readonly (readonly Tok
|
|
|
106
128
|
// A name that does not start a run of nouns (② 本研究の具体的な遂行方法) is an item of a list, not a term.
|
|
107
129
|
const named = words.named.filter((term) => runs.some((run) => run.term.startsWith(term)));
|
|
108
130
|
const known = knownForms([...defined, ...named], words.prefixGroups);
|
|
131
|
+
const terms = [...defined, ...runs.map((run) => run.term)];
|
|
109
132
|
const uses = runs
|
|
110
133
|
.filter((run) => !isSelf(run.term, run.prefix) && !words.isQuoted(run.term) && !isKnownUse(run.term, known, words.groupSuffixes))
|
|
134
|
+
.filter((run) => words.inheritsDefinitions !== true || terms.some((other) => isSlipOf(run.term, other, run.prefix)))
|
|
111
135
|
.map((run) => ({ offset: run.offset, term: run.term }));
|
|
112
136
|
return uses.filter((use, index) => uses.findIndex((other) => other.term === use.term) === index);
|
|
113
137
|
};
|
|
@@ -167,6 +191,7 @@ export const undefinedTerm: Detector = (doc): Finding[] => {
|
|
|
167
191
|
isQuoted: (term) => QUOTE_PAIRS.some(([open, close]) => doc.source.includes(`${open}${term}${close}`)),
|
|
168
192
|
named: namedTerms(doc.source, prefixes),
|
|
169
193
|
groupSuffixes: patternsOf(doc, "defined-term-group-suffix"),
|
|
194
|
+
inheritsDefinitions: patternsOf(doc, "definitions-inherited").some((phrase) => phrase !== "" && doc.source.includes(phrase)),
|
|
170
195
|
});
|
|
171
196
|
return [...prefixed, ...capitalisedUses(doc, sentences, definitions)].map((use) => findingOf(doc, use));
|
|
172
197
|
};
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import type { Detector } from "../plugin.ts";
|
|
1
|
+
import type { Detector, Finding, Lexicon, ProseDocument } from "../plugin.ts";
|
|
2
2
|
import { entriesForGenre } from "../lexicon-genres.ts";
|
|
3
3
|
import { unfilledPlaceholder } from "./ai-phrasing.ts";
|
|
4
|
+
import { placeholderSpans } from "./placeholder-text.ts";
|
|
4
5
|
import { TEMPLATE, isInside, templateSections } from "./template-sections.ts";
|
|
6
|
+
import { tableBodyCells } from "../facts/table-facts.ts";
|
|
7
|
+
import { proseAndTablesOf } from "../table-text.ts";
|
|
8
|
+
|
|
9
|
+
/** The prose covers tables, so a blank left in a cell (| Owner | [Name] |) is read from the cells themselves. */
|
|
10
|
+
const cellBlanks = (doc: ProseDocument, lexicon: Lexicon): Finding[] =>
|
|
11
|
+
tableBodyCells(proseAndTablesOf(doc)).flatMap((cell) =>
|
|
12
|
+
placeholderSpans(cell.text, lexicon).map((span) => ({
|
|
13
|
+
rule: "",
|
|
14
|
+
severity: "info" as const,
|
|
15
|
+
line: 0,
|
|
16
|
+
column: 0,
|
|
17
|
+
quote: cell.text.trim(),
|
|
18
|
+
values: { matched: cell.text.slice(span.start, span.end), offset: cell.start + span.start },
|
|
19
|
+
})),
|
|
20
|
+
);
|
|
5
21
|
|
|
6
22
|
/**
|
|
7
23
|
* A blank under a heading that names a template (Template, 雛形) is what the template is for, so it is not reported.
|
|
@@ -11,5 +27,7 @@ export const unfilledPlaceholderOutsideTemplates: Detector = (doc, options) => {
|
|
|
11
27
|
const lexicon = entriesForGenre(options.lexicon ?? [], options.genre);
|
|
12
28
|
const words = lexicon.filter((word) => word.group === TEMPLATE);
|
|
13
29
|
const templates = templateSections(doc.markup?.headings ?? [], doc.source.length, words);
|
|
14
|
-
return unfilledPlaceholder(doc, { ...options, lexicon })
|
|
30
|
+
return [...unfilledPlaceholder(doc, { ...options, lexicon }), ...cellBlanks(doc, lexicon)]
|
|
31
|
+
.filter((finding) => !isInside(templates, Number(finding.values["offset"])))
|
|
32
|
+
.toSorted((left, right) => Number(left.values["offset"]) - Number(right.values["offset"]));
|
|
15
33
|
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// Where a word stands, for unknown-word: places in a document where a word not in the dictionary is a name or a term the
|
|
2
|
+
// writer means as written, not a slip. Pure functions over the Markdown source and an offset into it.
|
|
3
|
+
import { isAddress, isKnownWord, stemsOf, type CheckedWord, type Speller } from "../spelling.ts";
|
|
4
|
+
|
|
5
|
+
/** Each half of a closed compound keeps this many letters: a shorter half (open + end, pip + line) is more often a slip at the joint. */
|
|
6
|
+
const MIN_COMPOUND_PART = 4;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Two dictionary words of four letters or more written as one (crowdwork, crowdworkers): a closed compound, not a slip. The
|
|
10
|
+
* head is a word as listed and the tail takes only an inflection: a prefix or a derived ending on a half (misre + presenation)
|
|
11
|
+
* reads too many slips as words.
|
|
12
|
+
*/
|
|
13
|
+
export const isClosedCompound = (word: string, speller: Speller): boolean => {
|
|
14
|
+
const listed: Speller = { ...speller, suffixes: [], prefixes: [] };
|
|
15
|
+
const inflected: Speller = { ...listed, suffixes: speller.suffixes.filter(({ inflection }) => inflection === true) };
|
|
16
|
+
return [...Array(Math.max(0, word.length - 2 * MIN_COMPOUND_PART + 1)).keys()]
|
|
17
|
+
.map((index) => index + MIN_COMPOUND_PART)
|
|
18
|
+
.some((split) => isKnownWord(word.slice(0, split), listed) && isKnownWord(word.slice(split), inflected));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Letters a name keeps before its drug stem: fewer, and the word is too short to be read as a drug by its ending alone. */
|
|
22
|
+
const MIN_DRUG_HEAD = 3;
|
|
23
|
+
|
|
24
|
+
/** A drug's international name, read by its stem (paroxetine by -oxetine, as fluoxetine): stems from the drug-stem lexicon. */
|
|
25
|
+
export const hasDrugStem = (word: string, stems: readonly string[]): boolean =>
|
|
26
|
+
stems.some((stem) => word.endsWith(stem) && word.length >= stem.length + MIN_DRUG_HEAD);
|
|
27
|
+
|
|
28
|
+
/** How far back or ahead to look for a neighbouring word or a search stem. */
|
|
29
|
+
const NEIGHBOUR_REACH = 40;
|
|
30
|
+
|
|
31
|
+
const CLOSER: Readonly<Record<string, string>> = { '"': '"', "“": "”", "(": ")" };
|
|
32
|
+
|
|
33
|
+
/** The word alone between quotes or brackets ("mailto", (jchaplin)): a word the writer names as such, or an account handle. */
|
|
34
|
+
export const isMention = (source: string, offset: number, word: string): boolean => {
|
|
35
|
+
const closer = CLOSER[source.charAt(offset - 1)];
|
|
36
|
+
return closer !== undefined && source.charAt(offset + word.length) === closer;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A search stem with a wildcard in a list of terms (ukrain*, vaccin*): the word ends in a * that closes no emphasis
|
|
41
|
+
* (nothing opens one before the word), and a separator or the line's end follows it, not a word as after a footnote's *.
|
|
42
|
+
*/
|
|
43
|
+
export const isSearchStem = (source: string, offset: number, word: string): boolean => {
|
|
44
|
+
const end = offset + word.length;
|
|
45
|
+
return source[end] === "*" && source[offset - 1] !== "*" && /^[ \t]*(?:[,;|)\]]|\r?\n|$)/u.test(source.slice(end + 1));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const LETTER = /\p{L}/u;
|
|
49
|
+
|
|
50
|
+
/** The stem a * at index of source closes: the letters right before it, or "" when none come before. */
|
|
51
|
+
const stemBefore = (source: string, index: number): string => {
|
|
52
|
+
const head = Array.from(source.slice(Math.max(0, index - NEIGHBOUR_REACH), index));
|
|
53
|
+
return head.slice(head.findLastIndex((character) => !LETTER.test(character)) + 1).join("");
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** The word stands in a line with a search stem (president, maga, biden, democrat*): every item of that list is a term. */
|
|
57
|
+
export const inSearchTermList = (source: string, offset: number): boolean => {
|
|
58
|
+
const start = source.lastIndexOf("\n", offset - 1) + 1;
|
|
59
|
+
const end = source.indexOf("\n", offset);
|
|
60
|
+
const line = source.slice(start, end === -1 ? source.length : end);
|
|
61
|
+
return [...line.matchAll(/\*/gu)].some((star) => {
|
|
62
|
+
const stem = stemBefore(source, start + star.index);
|
|
63
|
+
return stem !== "" && isSearchStem(source, start + star.index - stem.length, stem);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** A Latin letter outside English's a–z (ê, é, ñ, ß): a word of another language. */
|
|
68
|
+
const isForeignWord = (token: string): boolean => [...token].some((letter) => letter > "\u007f" && /\p{Script=Latin}/u.test(letter));
|
|
69
|
+
|
|
70
|
+
const SPACE = /\s/u;
|
|
71
|
+
|
|
72
|
+
/** The last space-separated token of text when a space ends it ("old bête " gives "bête"), or "". */
|
|
73
|
+
const lastToken = (text: string): string => (SPACE.test(text.at(-1) ?? "") ? (text.trimEnd().split(SPACE).at(-1) ?? "") : "");
|
|
74
|
+
|
|
75
|
+
/** The first space-separated token of text when a space starts it (" noire for" gives "noire"), or "". */
|
|
76
|
+
const firstToken = (text: string): string => (SPACE.test(text.charAt(0)) ? (text.trimStart().split(SPACE)[0] ?? "") : "");
|
|
77
|
+
|
|
78
|
+
/** The word stands beside a word of another language written in Latin letters (bête noire): it belongs to that phrase. */
|
|
79
|
+
export const besideForeignWord = (source: string, offset: number, word: string): boolean => {
|
|
80
|
+
const end = offset + word.length;
|
|
81
|
+
return (
|
|
82
|
+
isForeignWord(lastToken(source.slice(Math.max(0, offset - NEIGHBOUR_REACH), offset))) || isForeignWord(firstToken(source.slice(end, end + NEIGHBOUR_REACH)))
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** The letters of every URL and email address in the source, lower-cased: a word also in an address names what it points at. */
|
|
87
|
+
export const addressWordsOf = (source: string): Set<string> =>
|
|
88
|
+
new Set((source.match(/\S+/gu) ?? []).filter(isAddress).flatMap((chunk) => chunk.toLowerCase().match(/\p{L}+/gu) ?? []));
|
|
89
|
+
|
|
90
|
+
const countsOf = (keys: readonly string[]): Map<string, number> => {
|
|
91
|
+
const counts = new Map<string, number>();
|
|
92
|
+
keys.forEach((key) => counts.set(key, (counts.get(key) ?? 0) + 1));
|
|
93
|
+
return counts;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The word and its stems, the forms another word of its family shares (rightsized and rightsizing share rightsize), for a
|
|
98
|
+
* word the dictionary does not know. A known word is in no such family: "refactored" does not make "refactore" a form of
|
|
99
|
+
* it, nor "tools" "toolss".
|
|
100
|
+
*/
|
|
101
|
+
const familyOf = (word: string, speller: Speller): string[] => (isKnownWord(word, speller) ? [] : [...new Set([word, ...stemsOf(word, speller)])]);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Words the document uses once, counting a word's other forms as uses (rightsize, rightsized, rightsizing): a word used
|
|
105
|
+
* twice or more, in any form, is more often the document's own term than a slip.
|
|
106
|
+
*/
|
|
107
|
+
export const usedOnce = (words: readonly CheckedWord[], speller: Speller): CheckedWord[] => {
|
|
108
|
+
const uses = countsOf(words.map(({ word }) => word));
|
|
109
|
+
const families = new Map([...uses.keys()].map((word) => [word, familyOf(word, speller)]));
|
|
110
|
+
const shared = countsOf([...families.values()].flat());
|
|
111
|
+
return words.filter(({ word }) => uses.get(word) === 1 && (families.get(word) ?? []).every((key) => shared.get(key) === 1));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** A release number of three parts or more (1.21.5, v2.0.1), after spaces. */
|
|
115
|
+
const VERSION_AFTER = /^[ \t]+v?\d+\.\d+\.\d+/u;
|
|
116
|
+
|
|
117
|
+
/** The word names what a release number follows (golang 1.21.5): a product or a tool, written as its makers write it. */
|
|
118
|
+
export const beforeVersion = (source: string, offset: number, word: string): boolean => VERSION_AFTER.test(source.slice(offset + word.length));
|
|
119
|
+
|
|
120
|
+
/** Two words of one length that differ in one letter only. */
|
|
121
|
+
const oneLetterApart = (left: string, right: string): boolean =>
|
|
122
|
+
left.length === right.length && [...left].filter((letter, index) => letter !== right.charAt(index)).length === 1;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Another word of the document, itself not in the dictionary, one letter from this one (pthread and bthread): a family of
|
|
126
|
+
* names built on one scheme. A slip is one letter from a word the dictionary knows, and two slips seldom make such a pair.
|
|
127
|
+
*/
|
|
128
|
+
export const hasSiblingName = (word: string, unknownWords: ReadonlySet<string>): boolean =>
|
|
129
|
+
[...unknownWords].some((other) => other !== word && oneLetterApart(word, other));
|