chaffjs 0.50.0 → 0.52.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 +30 -3
- package/README.md +30 -2
- package/dist/allow.d.ts +49 -0
- package/dist/allow.d.ts.map +1 -0
- package/dist/allow.js +111 -0
- package/dist/allow.js.map +1 -0
- package/dist/check-source.d.ts +13 -3
- package/dist/check-source.d.ts.map +1 -1
- package/dist/check-source.js +23 -6
- package/dist/check-source.js.map +1 -1
- package/dist/clause-particles.d.ts +10 -2
- package/dist/clause-particles.d.ts.map +1 -1
- package/dist/clause-particles.js +15 -3
- package/dist/clause-particles.js.map +1 -1
- package/dist/cli-text.d.ts +7 -1
- package/dist/cli-text.d.ts.map +1 -1
- package/dist/cli-text.js +8 -2
- package/dist/cli-text.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -11
- package/dist/cli.js.map +1 -1
- package/dist/commands/eval.js +1 -1
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/suppressions.d.ts +4 -1
- package/dist/commands/suppressions.d.ts.map +1 -1
- package/dist/commands/suppressions.js +2 -2
- package/dist/commands/suppressions.js.map +1 -1
- package/dist/commands/test.js +1 -1
- package/dist/commands/test.js.map +1 -1
- package/dist/compound-head.d.ts +5 -2
- package/dist/compound-head.d.ts.map +1 -1
- package/dist/compound-head.js +17 -8
- package/dist/compound-head.js.map +1 -1
- package/dist/config/allow-problems.d.ts +8 -0
- package/dist/config/allow-problems.d.ts.map +1 -0
- package/dist/config/allow-problems.js +61 -0
- package/dist/config/allow-problems.js.map +1 -0
- package/dist/config/by-path-problems.d.ts +3 -0
- package/dist/config/by-path-problems.d.ts.map +1 -1
- package/dist/config/by-path-problems.js +21 -2
- package/dist/config/by-path-problems.js.map +1 -1
- package/dist/config/by-path-rules.d.ts +34 -0
- package/dist/config/by-path-rules.d.ts.map +1 -0
- package/dist/config/by-path-rules.js +53 -0
- package/dist/config/by-path-rules.js.map +1 -0
- package/dist/config/by-path.d.ts +15 -0
- package/dist/config/by-path.d.ts.map +1 -1
- package/dist/config/by-path.js.map +1 -1
- package/dist/config/consistent-problems.d.ts +5 -0
- package/dist/config/consistent-problems.d.ts.map +1 -0
- package/dist/config/consistent-problems.js +24 -0
- package/dist/config/consistent-problems.js.map +1 -0
- package/dist/config/load.d.ts +23 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +63 -10
- package/dist/config/load.js.map +1 -1
- package/dist/config/option-problems.d.ts +6 -4
- package/dist/config/option-problems.d.ts.map +1 -1
- package/dist/config/option-problems.js +5 -2
- package/dist/config/option-problems.js.map +1 -1
- package/dist/config/prefer-problems.d.ts +5 -0
- package/dist/config/prefer-problems.d.ts.map +1 -0
- package/dist/config/prefer-problems.js +15 -0
- package/dist/config/prefer-problems.js.map +1 -0
- package/dist/config/prefer.d.ts +21 -0
- package/dist/config/prefer.d.ts.map +1 -0
- package/dist/config/prefer.js +35 -0
- package/dist/config/prefer.js.map +1 -0
- package/dist/config/term-problems.d.ts +5 -0
- package/dist/config/term-problems.d.ts.map +1 -0
- package/dist/config/term-problems.js +25 -0
- package/dist/config/term-problems.js.map +1 -0
- package/dist/config/warnings.d.ts +1 -1
- package/dist/config/warnings.d.ts.map +1 -1
- package/dist/config/warnings.js +9 -2
- package/dist/config/warnings.js.map +1 -1
- package/dist/cross-variants.d.ts +1 -1
- package/dist/cross-variants.d.ts.map +1 -1
- package/dist/cross-variants.js +4 -8
- package/dist/cross-variants.js.map +1 -1
- package/dist/cross-votes.d.ts +13 -0
- package/dist/cross-votes.d.ts.map +1 -1
- package/dist/cross-votes.js +25 -2
- package/dist/cross-votes.js.map +1 -1
- package/dist/custom/parse.d.ts +9 -0
- package/dist/custom/parse.d.ts.map +1 -1
- package/dist/custom/parse.js +11 -2
- package/dist/custom/parse.js.map +1 -1
- package/dist/custom/problems.d.ts.map +1 -1
- package/dist/custom/problems.js +9 -3
- package/dist/custom/problems.js.map +1 -1
- package/dist/custom/scope-field.d.ts +7 -0
- package/dist/custom/scope-field.d.ts.map +1 -0
- package/dist/custom/scope-field.js +14 -0
- package/dist/custom/scope-field.js.map +1 -0
- package/dist/date-format.d.ts +5 -3
- package/dist/date-format.d.ts.map +1 -1
- package/dist/date-format.js +30 -5
- package/dist/date-format.js.map +1 -1
- package/dist/derived/elapsed.d.ts +4 -1
- package/dist/derived/elapsed.d.ts.map +1 -1
- package/dist/derived/elapsed.js +11 -1
- package/dist/derived/elapsed.js.map +1 -1
- package/dist/detectors/acronym-context.d.ts +3 -1
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +7 -1
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/acronym-gloss.d.ts +20 -7
- package/dist/detectors/acronym-gloss.d.ts.map +1 -1
- package/dist/detectors/acronym-gloss.js +50 -13
- package/dist/detectors/acronym-gloss.js.map +1 -1
- package/dist/detectors/address-blank.d.ts +14 -0
- package/dist/detectors/address-blank.d.ts.map +1 -0
- package/dist/detectors/address-blank.js +41 -0
- package/dist/detectors/address-blank.js.map +1 -0
- package/dist/detectors/bare-comparative.d.ts +4 -0
- package/dist/detectors/bare-comparative.d.ts.map +1 -1
- package/dist/detectors/bare-comparative.js +27 -3
- package/dist/detectors/bare-comparative.js.map +1 -1
- package/dist/detectors/blank-structure.d.ts +5 -1
- package/dist/detectors/blank-structure.d.ts.map +1 -1
- package/dist/detectors/blank-structure.js +13 -7
- package/dist/detectors/blank-structure.js.map +1 -1
- package/dist/detectors/bold-emphasis-form.d.ts +1 -0
- package/dist/detectors/bold-emphasis-form.d.ts.map +1 -1
- package/dist/detectors/bold-emphasis-form.js +7 -1
- package/dist/detectors/bold-emphasis-form.js.map +1 -1
- package/dist/detectors/bold-label.d.ts.map +1 -1
- package/dist/detectors/bold-label.js +12 -6
- package/dist/detectors/bold-label.js.map +1 -1
- package/dist/detectors/bracket-title-date.d.ts +6 -0
- package/dist/detectors/bracket-title-date.d.ts.map +1 -0
- package/dist/detectors/bracket-title-date.js +29 -0
- package/dist/detectors/bracket-title-date.js.map +1 -0
- package/dist/detectors/broken-link.d.ts.map +1 -1
- package/dist/detectors/broken-link.js +12 -1
- package/dist/detectors/broken-link.js.map +1 -1
- package/dist/detectors/capitalised-term.d.ts.map +1 -1
- package/dist/detectors/capitalised-term.js +24 -11
- package/dist/detectors/capitalised-term.js.map +1 -1
- package/dist/detectors/change-rate.d.ts.map +1 -1
- package/dist/detectors/change-rate.js +27 -4
- package/dist/detectors/change-rate.js.map +1 -1
- package/dist/detectors/char-shape.d.ts.map +1 -1
- package/dist/detectors/char-shape.js +15 -21
- package/dist/detectors/char-shape.js.map +1 -1
- package/dist/detectors/clause-shape.d.ts +4 -2
- package/dist/detectors/clause-shape.d.ts.map +1 -1
- package/dist/detectors/clause-shape.js +8 -4
- package/dist/detectors/clause-shape.js.map +1 -1
- package/dist/detectors/closing-cliche.d.ts +1 -1
- package/dist/detectors/closing-cliche.d.ts.map +1 -1
- package/dist/detectors/closing-cliche.js +16 -3
- package/dist/detectors/closing-cliche.js.map +1 -1
- package/dist/detectors/contraction-mix.d.ts.map +1 -1
- package/dist/detectors/contraction-mix.js +6 -3
- package/dist/detectors/contraction-mix.js.map +1 -1
- package/dist/detectors/contraction-set-apart.d.ts +7 -1
- package/dist/detectors/contraction-set-apart.d.ts.map +1 -1
- package/dist/detectors/contraction-set-apart.js +14 -1
- package/dist/detectors/contraction-set-apart.js.map +1 -1
- package/dist/detectors/coordinate-adjective.d.ts +5 -3
- package/dist/detectors/coordinate-adjective.d.ts.map +1 -1
- package/dist/detectors/coordinate-adjective.js +49 -1
- package/dist/detectors/coordinate-adjective.js.map +1 -1
- package/dist/detectors/count-per-section.d.ts.map +1 -1
- package/dist/detectors/count-per-section.js +29 -23
- package/dist/detectors/count-per-section.js.map +1 -1
- package/dist/detectors/counter-edge.d.ts +11 -0
- package/dist/detectors/counter-edge.d.ts.map +1 -1
- package/dist/detectors/counter-edge.js +17 -0
- package/dist/detectors/counter-edge.js.map +1 -1
- package/dist/detectors/cross-variant.d.ts.map +1 -1
- package/dist/detectors/cross-variant.js +14 -2
- package/dist/detectors/cross-variant.js.map +1 -1
- package/dist/detectors/currency-notation.d.ts.map +1 -1
- package/dist/detectors/currency-notation.js +9 -1
- package/dist/detectors/currency-notation.js.map +1 -1
- package/dist/detectors/custom.d.ts.map +1 -1
- package/dist/detectors/custom.js +6 -4
- package/dist/detectors/custom.js.map +1 -1
- package/dist/detectors/date-format.js +1 -1
- package/dist/detectors/date-format.js.map +1 -1
- package/dist/detectors/date-repeated-day.d.ts +11 -0
- package/dist/detectors/date-repeated-day.d.ts.map +1 -0
- package/dist/detectors/date-repeated-day.js +15 -0
- package/dist/detectors/date-repeated-day.js.map +1 -0
- package/dist/detectors/date-year.d.ts.map +1 -1
- package/dist/detectors/date-year.js +8 -1
- package/dist/detectors/date-year.js.map +1 -1
- package/dist/detectors/defined-term-form.d.ts.map +1 -1
- package/dist/detectors/defined-term-form.js +6 -3
- package/dist/detectors/defined-term-form.js.map +1 -1
- package/dist/detectors/definition-use.d.ts.map +1 -1
- package/dist/detectors/definition-use.js +8 -1
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/derived-numbers.d.ts.map +1 -1
- package/dist/detectors/derived-numbers.js +1 -0
- package/dist/detectors/derived-numbers.js.map +1 -1
- package/dist/detectors/document-shape.d.ts +1 -1
- package/dist/detectors/document-shape.d.ts.map +1 -1
- package/dist/detectors/document-shape.js +4 -1
- package/dist/detectors/document-shape.js.map +1 -1
- package/dist/detectors/email-letter.d.ts +3 -1
- package/dist/detectors/email-letter.d.ts.map +1 -1
- package/dist/detectors/email-letter.js +4 -2
- package/dist/detectors/email-letter.js.map +1 -1
- package/dist/detectors/empty-section.d.ts +1 -0
- package/dist/detectors/empty-section.d.ts.map +1 -1
- package/dist/detectors/empty-section.js +10 -1
- package/dist/detectors/empty-section.js.map +1 -1
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +27 -2
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/enumeration-marker.d.ts +7 -0
- package/dist/detectors/enumeration-marker.d.ts.map +1 -0
- package/dist/detectors/enumeration-marker.js +8 -0
- package/dist/detectors/enumeration-marker.js.map +1 -0
- package/dist/detectors/event-title-item.d.ts +8 -0
- package/dist/detectors/event-title-item.d.ts.map +1 -0
- package/dist/detectors/event-title-item.js +45 -0
- package/dist/detectors/event-title-item.js.map +1 -0
- package/dist/detectors/example-baseline.d.ts +5 -0
- package/dist/detectors/example-baseline.d.ts.map +1 -1
- package/dist/detectors/example-baseline.js +15 -1
- package/dist/detectors/example-baseline.js.map +1 -1
- package/dist/detectors/filler-word.d.ts +11 -0
- package/dist/detectors/filler-word.d.ts.map +1 -0
- package/dist/detectors/filler-word.js +73 -0
- package/dist/detectors/filler-word.js.map +1 -0
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
- package/dist/detectors/fullwidth-alnum.js +19 -0
- package/dist/detectors/fullwidth-alnum.js.map +1 -1
- package/dist/detectors/gram-ending.d.ts +12 -0
- package/dist/detectors/gram-ending.d.ts.map +1 -0
- package/dist/detectors/gram-ending.js +27 -0
- package/dist/detectors/gram-ending.js.map +1 -0
- package/dist/detectors/gram-repetition.d.ts.map +1 -1
- package/dist/detectors/gram-repetition.js +19 -3
- package/dist/detectors/gram-repetition.js.map +1 -1
- package/dist/detectors/heading-case.d.ts.map +1 -1
- package/dist/detectors/heading-case.js +6 -1
- package/dist/detectors/heading-case.js.map +1 -1
- package/dist/detectors/heading-marker-no-space.d.ts +3 -0
- package/dist/detectors/heading-marker-no-space.d.ts.map +1 -0
- package/dist/detectors/heading-marker-no-space.js +49 -0
- package/dist/detectors/heading-marker-no-space.js.map +1 -0
- package/dist/detectors/hyphen-name-suffix.d.ts.map +1 -1
- package/dist/detectors/hyphen-name-suffix.js +3 -2
- package/dist/detectors/hyphen-name-suffix.js.map +1 -1
- package/dist/detectors/inline-item-label.d.ts +6 -0
- package/dist/detectors/inline-item-label.d.ts.map +1 -0
- package/dist/detectors/inline-item-label.js +79 -0
- package/dist/detectors/inline-item-label.js.map +1 -0
- package/dist/detectors/kanji-name-edge.d.ts +5 -0
- package/dist/detectors/kanji-name-edge.d.ts.map +1 -1
- package/dist/detectors/kanji-name-edge.js +9 -0
- package/dist/detectors/kanji-name-edge.js.map +1 -1
- package/dist/detectors/kanji-run-pieces.d.ts +21 -6
- package/dist/detectors/kanji-run-pieces.d.ts.map +1 -1
- package/dist/detectors/kanji-run-pieces.js +23 -8
- package/dist/detectors/kanji-run-pieces.js.map +1 -1
- package/dist/detectors/known-correction.d.ts.map +1 -1
- package/dist/detectors/known-correction.js +13 -1
- package/dist/detectors/known-correction.js.map +1 -1
- package/dist/detectors/link-definition.d.ts +3 -0
- package/dist/detectors/link-definition.d.ts.map +1 -0
- package/dist/detectors/link-definition.js +78 -0
- package/dist/detectors/link-definition.js.map +1 -0
- package/dist/detectors/list-item-asides.d.ts +7 -0
- package/dist/detectors/list-item-asides.d.ts.map +1 -0
- package/dist/detectors/list-item-asides.js +25 -0
- package/dist/detectors/list-item-asides.js.map +1 -0
- package/dist/detectors/list-item-own.d.ts +11 -0
- package/dist/detectors/list-item-own.d.ts.map +1 -0
- package/dist/detectors/list-item-own.js +31 -0
- package/dist/detectors/list-item-own.js.map +1 -0
- package/dist/detectors/list-item-phrase.d.ts +1 -1
- package/dist/detectors/list-item-phrase.d.ts.map +1 -1
- package/dist/detectors/list-item-phrase.js +18 -7
- package/dist/detectors/list-item-phrase.js.map +1 -1
- package/dist/detectors/list-item.d.ts +2 -0
- package/dist/detectors/list-item.d.ts.map +1 -1
- package/dist/detectors/list-item.js +6 -0
- package/dist/detectors/list-item.js.map +1 -1
- package/dist/detectors/list-items.d.ts.map +1 -1
- package/dist/detectors/list-items.js +12 -3
- package/dist/detectors/list-items.js.map +1 -1
- package/dist/detectors/list-joint.d.ts +6 -0
- package/dist/detectors/list-joint.d.ts.map +1 -1
- package/dist/detectors/list-joint.js +18 -2
- package/dist/detectors/list-joint.js.map +1 -1
- package/dist/detectors/list-opening-conjunction.d.ts +7 -0
- package/dist/detectors/list-opening-conjunction.d.ts.map +1 -0
- package/dist/detectors/list-opening-conjunction.js +22 -0
- package/dist/detectors/list-opening-conjunction.js.map +1 -0
- package/dist/detectors/list-parallel.d.ts +3 -8
- package/dist/detectors/list-parallel.d.ts.map +1 -1
- package/dist/detectors/list-parallel.js +29 -46
- package/dist/detectors/list-parallel.js.map +1 -1
- package/dist/detectors/list-run.d.ts.map +1 -1
- package/dist/detectors/list-run.js +15 -3
- package/dist/detectors/list-run.js.map +1 -1
- package/dist/detectors/list-verb-series.d.ts +6 -0
- package/dist/detectors/list-verb-series.d.ts.map +1 -0
- package/dist/detectors/list-verb-series.js +20 -0
- package/dist/detectors/list-verb-series.js.map +1 -0
- package/dist/detectors/mark-shape.d.ts +5 -2
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +12 -15
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/markdown-slip.d.ts +5 -0
- package/dist/detectors/markdown-slip.d.ts.map +1 -1
- package/dist/detectors/markdown-slip.js +23 -0
- package/dist/detectors/markdown-slip.js.map +1 -1
- package/dist/detectors/marked-word.d.ts +10 -0
- package/dist/detectors/marked-word.d.ts.map +1 -0
- package/dist/detectors/marked-word.js +30 -0
- package/dist/detectors/marked-word.js.map +1 -0
- package/dist/detectors/middle-dot.d.ts +1 -1
- package/dist/detectors/middle-dot.d.ts.map +1 -1
- package/dist/detectors/middle-dot.js +21 -2
- package/dist/detectors/middle-dot.js.map +1 -1
- package/dist/detectors/missing-final-period.d.ts.map +1 -1
- package/dist/detectors/missing-final-period.js +8 -1
- package/dist/detectors/missing-final-period.js.map +1 -1
- package/dist/detectors/name-variant-two-things.d.ts +2 -1
- package/dist/detectors/name-variant-two-things.d.ts.map +1 -1
- package/dist/detectors/name-variant-two-things.js +30 -2
- package/dist/detectors/name-variant-two-things.js.map +1 -1
- package/dist/detectors/net-amount-mismatch.d.ts.map +1 -1
- package/dist/detectors/net-amount-mismatch.js +26 -4
- package/dist/detectors/net-amount-mismatch.js.map +1 -1
- package/dist/detectors/nominalization.d.ts.map +1 -1
- package/dist/detectors/nominalization.js +6 -1
- package/dist/detectors/nominalization.js.map +1 -1
- package/dist/detectors/number-style.d.ts +2 -0
- package/dist/detectors/number-style.d.ts.map +1 -1
- package/dist/detectors/number-style.js +5 -0
- package/dist/detectors/number-style.js.map +1 -1
- package/dist/detectors/open-end-scope.d.ts.map +1 -1
- package/dist/detectors/open-end-scope.js +2 -2
- package/dist/detectors/open-end-scope.js.map +1 -1
- package/dist/detectors/ordinary-phrase.d.ts +5 -0
- package/dist/detectors/ordinary-phrase.d.ts.map +1 -1
- package/dist/detectors/ordinary-phrase.js +12 -0
- package/dist/detectors/ordinary-phrase.js.map +1 -1
- package/dist/detectors/organisation-run.d.ts +2 -0
- package/dist/detectors/organisation-run.d.ts.map +1 -1
- package/dist/detectors/organisation-run.js +7 -0
- package/dist/detectors/organisation-run.js.map +1 -1
- package/dist/detectors/orthographic-variant-kanji-word.d.ts +22 -0
- package/dist/detectors/orthographic-variant-kanji-word.d.ts.map +1 -0
- package/dist/detectors/orthographic-variant-kanji-word.js +27 -0
- package/dist/detectors/orthographic-variant-kanji-word.js.map +1 -0
- package/dist/detectors/orthographic-variant-open.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant-open.js +2 -1
- package/dist/detectors/orthographic-variant-open.js.map +1 -1
- package/dist/detectors/orthographic-variant-text.d.ts +7 -0
- package/dist/detectors/orthographic-variant-text.d.ts.map +1 -0
- package/dist/detectors/orthographic-variant-text.js +14 -0
- package/dist/detectors/orthographic-variant-text.js.map +1 -0
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +22 -23
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +12 -2
- package/dist/detectors/orthography.js.map +1 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +16 -4
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/paragraph-run.d.ts +1 -1
- package/dist/detectors/paragraph-run.d.ts.map +1 -1
- package/dist/detectors/paragraph-run.js +4 -2
- package/dist/detectors/paragraph-run.js.map +1 -1
- package/dist/detectors/placeholder-text.d.ts.map +1 -1
- package/dist/detectors/placeholder-text.js +12 -4
- package/dist/detectors/placeholder-text.js.map +1 -1
- package/dist/detectors/placeholder.d.ts +1 -0
- package/dist/detectors/placeholder.d.ts.map +1 -1
- package/dist/detectors/placeholder.js +8 -0
- package/dist/detectors/placeholder.js.map +1 -1
- package/dist/detectors/pseudo-heading.d.ts +11 -0
- package/dist/detectors/pseudo-heading.d.ts.map +1 -0
- package/dist/detectors/pseudo-heading.js +115 -0
- package/dist/detectors/pseudo-heading.js.map +1 -0
- package/dist/detectors/quote-around.d.ts +1 -1
- package/dist/detectors/quote-around.d.ts.map +1 -1
- package/dist/detectors/quote-around.js +26 -5
- package/dist/detectors/quote-around.js.map +1 -1
- package/dist/detectors/quoted-label.d.ts +8 -0
- package/dist/detectors/quoted-label.d.ts.map +1 -0
- package/dist/detectors/quoted-label.js +18 -0
- package/dist/detectors/quoted-label.js.map +1 -0
- package/dist/detectors/ra-nuki.d.ts +1 -7
- package/dist/detectors/ra-nuki.d.ts.map +1 -1
- package/dist/detectors/ra-nuki.js +2 -27
- package/dist/detectors/ra-nuki.js.map +1 -1
- package/dist/detectors/register-label-note.d.ts +8 -0
- package/dist/detectors/register-label-note.d.ts.map +1 -0
- package/dist/detectors/register-label-note.js +31 -0
- package/dist/detectors/register-label-note.js.map +1 -0
- package/dist/detectors/register-required.d.ts +27 -0
- package/dist/detectors/register-required.d.ts.map +1 -0
- package/dist/detectors/register-required.js +33 -0
- package/dist/detectors/register-required.js.map +1 -0
- package/dist/detectors/register-voice.d.ts +13 -1
- package/dist/detectors/register-voice.d.ts.map +1 -1
- package/dist/detectors/register-voice.js +27 -0
- package/dist/detectors/register-voice.js.map +1 -1
- package/dist/detectors/registry/enumeration-marker.d.ts +3 -0
- package/dist/detectors/registry/enumeration-marker.d.ts.map +1 -0
- package/dist/detectors/registry/enumeration-marker.js +3 -0
- package/dist/detectors/registry/enumeration-marker.js.map +1 -0
- package/dist/detectors/registry/filler-word.d.ts +3 -0
- package/dist/detectors/registry/filler-word.d.ts.map +1 -0
- package/dist/detectors/registry/filler-word.js +3 -0
- package/dist/detectors/registry/filler-word.js.map +1 -0
- package/dist/detectors/registry/heading-marker-no-space.d.ts +3 -0
- package/dist/detectors/registry/heading-marker-no-space.d.ts.map +1 -0
- package/dist/detectors/registry/heading-marker-no-space.js +3 -0
- package/dist/detectors/registry/heading-marker-no-space.js.map +1 -0
- package/dist/detectors/registry/link-definition-unused.d.ts +3 -0
- package/dist/detectors/registry/link-definition-unused.d.ts.map +1 -0
- package/dist/detectors/registry/link-definition-unused.js +3 -0
- package/dist/detectors/registry/link-definition-unused.js.map +1 -0
- package/dist/detectors/registry/pseudo-heading.d.ts +3 -0
- package/dist/detectors/registry/pseudo-heading.d.ts.map +1 -0
- package/dist/detectors/registry/pseudo-heading.js +3 -0
- package/dist/detectors/registry/pseudo-heading.js.map +1 -0
- package/dist/detectors/registry/reversed-link.d.ts +3 -0
- package/dist/detectors/registry/reversed-link.d.ts.map +1 -0
- package/dist/detectors/registry/reversed-link.js +3 -0
- package/dist/detectors/registry/reversed-link.js.map +1 -0
- package/dist/detectors/registry/sa-ire.d.ts +3 -0
- package/dist/detectors/registry/sa-ire.d.ts.map +1 -0
- package/dist/detectors/registry/sa-ire.js +3 -0
- package/dist/detectors/registry/sa-ire.js.map +1 -0
- package/dist/detectors/registry/table-absorbed-line.d.ts +3 -0
- package/dist/detectors/registry/table-absorbed-line.d.ts.map +1 -0
- package/dist/detectors/registry/table-absorbed-line.js +3 -0
- package/dist/detectors/registry/table-absorbed-line.js.map +1 -0
- package/dist/detectors/registry/term-consistency.d.ts +3 -0
- package/dist/detectors/registry/term-consistency.d.ts.map +1 -0
- package/dist/detectors/registry/term-consistency.js +3 -0
- package/dist/detectors/registry/term-consistency.js.map +1 -0
- package/dist/detectors/registry/term-form.d.ts +3 -0
- package/dist/detectors/registry/term-form.d.ts.map +1 -0
- package/dist/detectors/registry/term-form.js +3 -0
- package/dist/detectors/registry/term-form.js.map +1 -0
- package/dist/detectors/relative-pronoun-mix.d.ts +1 -1
- package/dist/detectors/relative-pronoun-mix.d.ts.map +1 -1
- package/dist/detectors/relative-pronoun-mix.js +14 -3
- package/dist/detectors/relative-pronoun-mix.js.map +1 -1
- package/dist/detectors/release-notes.d.ts +7 -0
- package/dist/detectors/release-notes.d.ts.map +1 -0
- package/dist/detectors/release-notes.js +12 -0
- package/dist/detectors/release-notes.js.map +1 -0
- package/dist/detectors/request-owner.d.ts +5 -1
- package/dist/detectors/request-owner.d.ts.map +1 -1
- package/dist/detectors/request-owner.js +53 -1
- package/dist/detectors/request-owner.js.map +1 -1
- package/dist/detectors/reversed-link.d.ts +3 -0
- package/dist/detectors/reversed-link.d.ts.map +1 -0
- package/dist/detectors/reversed-link.js +31 -0
- package/dist/detectors/reversed-link.js.map +1 -0
- package/dist/detectors/run-in-title.d.ts +6 -0
- package/dist/detectors/run-in-title.d.ts.map +1 -0
- package/dist/detectors/run-in-title.js +32 -0
- package/dist/detectors/run-in-title.js.map +1 -0
- package/dist/detectors/sa-ire.d.ts +3 -0
- package/dist/detectors/sa-ire.d.ts.map +1 -0
- package/dist/detectors/sa-ire.js +5 -0
- package/dist/detectors/sa-ire.js.map +1 -0
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +19 -6
- package/dist/detectors/sentence-counts.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +40 -12
- 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 +23 -4
- package/dist/detectors/sentence-length.js.map +1 -1
- package/dist/detectors/sentence-rhythm.d.ts.map +1 -1
- package/dist/detectors/sentence-rhythm.js +6 -2
- package/dist/detectors/sentence-rhythm.js.map +1 -1
- package/dist/detectors/signals.js +2 -2
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/structure.d.ts +1 -0
- package/dist/detectors/structure.d.ts.map +1 -1
- package/dist/detectors/structure.js +5 -0
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/technical-docs.d.ts +8 -1
- package/dist/detectors/technical-docs.d.ts.map +1 -1
- package/dist/detectors/technical-docs.js +41 -9
- package/dist/detectors/technical-docs.js.map +1 -1
- package/dist/detectors/term-consistency.d.ts +4 -0
- package/dist/detectors/term-consistency.d.ts.map +1 -0
- package/dist/detectors/term-consistency.js +35 -0
- package/dist/detectors/term-consistency.js.map +1 -0
- package/dist/detectors/term-form.d.ts +4 -0
- package/dist/detectors/term-form.d.ts.map +1 -0
- package/dist/detectors/term-form.js +17 -0
- package/dist/detectors/term-form.js.map +1 -0
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +8 -4
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/unbalanced-bracket.d.ts +1 -1
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
- package/dist/detectors/unbalanced-bracket.js +4 -2
- package/dist/detectors/unbalanced-bracket.js.map +1 -1
- package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
- package/dist/detectors/unfilled-placeholder.js +11 -1
- package/dist/detectors/unfilled-placeholder.js.map +1 -1
- package/dist/detectors/unknown-word-context.d.ts +2 -0
- package/dist/detectors/unknown-word-context.d.ts.map +1 -1
- package/dist/detectors/unknown-word-context.js +3 -0
- package/dist/detectors/unknown-word-context.js.map +1 -1
- package/dist/detectors/unknown-word.d.ts.map +1 -1
- package/dist/detectors/unknown-word.js +7 -2
- package/dist/detectors/unknown-word.js.map +1 -1
- package/dist/detectors/vague-density.d.ts.map +1 -1
- package/dist/detectors/vague-density.js +10 -2
- package/dist/detectors/vague-density.js.map +1 -1
- package/dist/detectors/version-mismatch.d.ts.map +1 -1
- package/dist/detectors/version-mismatch.js +5 -1
- package/dist/detectors/version-mismatch.js.map +1 -1
- package/dist/detectors/weasel-word.d.ts.map +1 -1
- package/dist/detectors/weasel-word.js +11 -2
- package/dist/detectors/weasel-word.js.map +1 -1
- package/dist/document-prose.d.ts +17 -0
- package/dist/document-prose.d.ts.map +1 -0
- package/dist/document-prose.js +35 -0
- package/dist/document-prose.js.map +1 -0
- package/dist/document-scope.d.ts +16 -0
- package/dist/document-scope.d.ts.map +1 -0
- package/dist/document-scope.js +51 -0
- package/dist/document-scope.js.map +1 -0
- package/dist/document.d.ts +10 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +26 -37
- package/dist/document.js.map +1 -1
- package/dist/enumeration-marks.d.ts +23 -0
- package/dist/enumeration-marks.d.ts.map +1 -0
- package/dist/enumeration-marks.js +184 -0
- package/dist/enumeration-marks.js.map +1 -0
- package/dist/facts/cross-facts.d.ts +1 -1
- package/dist/facts/cross-facts.d.ts.map +1 -1
- package/dist/facts/cross-facts.js +8 -3
- package/dist/facts/cross-facts.js.map +1 -1
- package/dist/facts/labelled-facts.d.ts.map +1 -1
- package/dist/facts/labelled-facts.js +7 -4
- package/dist/facts/labelled-facts.js.map +1 -1
- package/dist/file-header.d.ts +2 -6
- package/dist/file-header.d.ts.map +1 -1
- package/dist/file-header.js +1 -1
- package/dist/file-header.js.map +1 -1
- package/dist/files.d.ts +18 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +58 -8
- package/dist/files.js.map +1 -1
- package/dist/gitignore.d.ts +30 -0
- package/dist/gitignore.d.ts.map +1 -0
- package/dist/gitignore.js +68 -0
- package/dist/gitignore.js.map +1 -0
- package/dist/grade/stamp.d.ts.map +1 -1
- package/dist/grade/stamp.js +5 -0
- package/dist/grade/stamp.js.map +1 -1
- package/dist/latin-word-boundary.d.ts +5 -0
- package/dist/latin-word-boundary.d.ts.map +1 -1
- package/dist/latin-word-boundary.js +11 -0
- package/dist/latin-word-boundary.js.map +1 -1
- package/dist/markdown-node.d.ts +1 -0
- package/dist/markdown-node.d.ts.map +1 -1
- package/dist/markdown-node.js.map +1 -1
- package/dist/name-separator.d.ts.map +1 -1
- package/dist/name-separator.js +27 -5
- package/dist/name-separator.js.map +1 -1
- package/dist/news-dateline.d.ts +7 -0
- package/dist/news-dateline.d.ts.map +1 -0
- package/dist/news-dateline.js +24 -0
- package/dist/news-dateline.js.map +1 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/reasons.d.ts +4 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +4 -0
- package/dist/reasons.js.map +1 -1
- package/dist/render/explain.d.ts +3 -0
- package/dist/render/explain.d.ts.map +1 -1
- package/dist/render/explain.js +19 -1
- package/dist/render/explain.js.map +1 -1
- package/dist/render/rules-json.d.ts.map +1 -1
- package/dist/render/rules-json.js +12 -2
- package/dist/render/rules-json.js.map +1 -1
- package/dist/render/summary.d.ts +5 -2
- package/dist/render/summary.d.ts.map +1 -1
- package/dist/render/summary.js +25 -4
- package/dist/render/summary.js.map +1 -1
- package/dist/render/suppressions.d.ts +6 -1
- package/dist/render/suppressions.d.ts.map +1 -1
- package/dist/render/suppressions.js +76 -3
- package/dist/render/suppressions.js.map +1 -1
- package/dist/rule-load.d.ts.map +1 -1
- package/dist/rule-load.js +2 -1
- package/dist/rule-load.js.map +1 -1
- package/dist/run-in-title.d.ts +4 -0
- package/dist/run-in-title.d.ts.map +1 -0
- package/dist/run-in-title.js +82 -0
- package/dist/run-in-title.js.map +1 -0
- package/dist/run.d.ts +2 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +20 -8
- package/dist/run.js.map +1 -1
- package/dist/scope-markers.d.ts +9 -0
- package/dist/scope-markers.d.ts.map +1 -0
- package/dist/scope-markers.js +19 -0
- package/dist/scope-markers.js.map +1 -0
- package/dist/scope-problem-text.d.ts +4 -0
- package/dist/scope-problem-text.d.ts.map +1 -0
- package/dist/scope-problem-text.js +17 -0
- package/dist/scope-problem-text.js.map +1 -0
- package/dist/scoped-sentences.d.ts +21 -0
- package/dist/scoped-sentences.d.ts.map +1 -0
- package/dist/scoped-sentences.js +21 -0
- package/dist/scoped-sentences.js.map +1 -0
- package/dist/setting-problems.d.ts.map +1 -1
- package/dist/setting-problems.js +4 -0
- package/dist/setting-problems.js.map +1 -1
- package/dist/spelling.js +4 -4
- package/dist/spelling.js.map +1 -1
- package/dist/stet-body.d.ts +13 -0
- package/dist/stet-body.d.ts.map +1 -0
- package/dist/stet-body.js +49 -0
- package/dist/stet-body.js.map +1 -0
- package/dist/stet.d.ts +30 -4
- package/dist/stet.d.ts.map +1 -1
- package/dist/stet.js +78 -28
- package/dist/stet.js.map +1 -1
- package/dist/structure/alert-lines.d.ts +4 -0
- package/dist/structure/alert-lines.d.ts.map +1 -0
- package/dist/structure/alert-lines.js +19 -0
- package/dist/structure/alert-lines.js.map +1 -0
- package/dist/structure/catch-all-row-blank.d.ts +9 -0
- package/dist/structure/catch-all-row-blank.d.ts.map +1 -0
- package/dist/structure/catch-all-row-blank.js +19 -0
- package/dist/structure/catch-all-row-blank.js.map +1 -0
- package/dist/structure/change-rate-tied.d.ts +22 -0
- package/dist/structure/change-rate-tied.d.ts.map +1 -0
- package/dist/structure/change-rate-tied.js +85 -0
- package/dist/structure/change-rate-tied.js.map +1 -0
- package/dist/structure/cross-definitions.d.ts +1 -1
- package/dist/structure/cross-definitions.d.ts.map +1 -1
- package/dist/structure/cross-definitions.js +3 -9
- package/dist/structure/cross-definitions.js.map +1 -1
- package/dist/structure/defining-names.d.ts +1 -1
- package/dist/structure/defining-names.d.ts.map +1 -1
- package/dist/structure/defining-names.js +12 -1
- package/dist/structure/defining-names.js.map +1 -1
- package/dist/structure/definition-use.d.ts +5 -3
- package/dist/structure/definition-use.d.ts.map +1 -1
- package/dist/structure/definition-use.js +10 -2
- package/dist/structure/definition-use.js.map +1 -1
- package/dist/structure/forward-reference.d.ts +8 -0
- package/dist/structure/forward-reference.d.ts.map +1 -0
- package/dist/structure/forward-reference.js +18 -0
- package/dist/structure/forward-reference.js.map +1 -0
- package/dist/structure/net-amount.d.ts +16 -0
- package/dist/structure/net-amount.d.ts.map +1 -1
- package/dist/structure/net-amount.js +28 -1
- package/dist/structure/net-amount.js.map +1 -1
- package/dist/structure/period-label-conflict.d.ts +2 -2
- package/dist/structure/period-label-conflict.d.ts.map +1 -1
- package/dist/structure/period-label-conflict.js +17 -3
- package/dist/structure/period-label-conflict.js.map +1 -1
- package/dist/structure/serial-range.d.ts.map +1 -1
- package/dist/structure/serial-range.js +14 -6
- package/dist/structure/serial-range.js.map +1 -1
- package/dist/structure/version-mismatch.d.ts +6 -1
- package/dist/structure/version-mismatch.d.ts.map +1 -1
- package/dist/structure/version-mismatch.js +28 -6
- package/dist/structure/version-mismatch.js.map +1 -1
- package/dist/structure/weekday.d.ts.map +1 -1
- package/dist/structure/weekday.js +14 -1
- package/dist/structure/weekday.js.map +1 -1
- package/dist/table-cells.d.ts +1 -1
- package/dist/table-cells.d.ts.map +1 -1
- package/dist/table-cells.js.map +1 -1
- package/dist/term-form.d.ts +15 -0
- package/dist/term-form.d.ts.map +1 -0
- package/dist/term-form.js +72 -0
- package/dist/term-form.js.map +1 -0
- package/dist/term-groups.d.ts +33 -0
- package/dist/term-groups.d.ts.map +1 -0
- package/dist/term-groups.js +46 -0
- package/dist/term-groups.js.map +1 -0
- package/dist/text-scope.d.ts +35 -0
- package/dist/text-scope.d.ts.map +1 -0
- package/dist/text-scope.js +55 -0
- package/dist/text-scope.js.map +1 -0
- package/dist/topic-clause.d.ts.map +1 -1
- package/dist/topic-clause.js +103 -21
- package/dist/topic-clause.js.map +1 -1
- package/dist/unclosed-code-quote.d.ts +7 -0
- package/dist/unclosed-code-quote.d.ts.map +1 -0
- package/dist/unclosed-code-quote.js +37 -0
- package/dist/unclosed-code-quote.js.map +1 -0
- package/package.json +4 -3
- package/rules/adverb-overuse.yaml +2 -2
- package/rules/bold-density.yaml +2 -2
- package/rules/bold-emphasis.yaml +2 -2
- package/rules/bold-label-list.yaml +2 -2
- package/rules/bracket-width-consistency.yaml +2 -2
- package/rules/broken-link.yaml +2 -2
- package/rules/change-rate-mismatch.yaml +2 -2
- package/rules/closing-cliche.yaml +2 -2
- package/rules/code-fence-language-mix.yaml +2 -2
- package/rules/comparative-without-baseline.yaml +2 -2
- package/rules/contraction-consistency.yaml +3 -3
- package/rules/cross-doc-duplicate-definition.yaml +2 -2
- package/rules/cross-doc-fact-conflict.yaml +2 -2
- package/rules/cross-doc-term-variant.yaml +4 -4
- package/rules/date-format-consistency.yaml +2 -2
- package/rules/date-weekday-mismatch.yaml +2 -2
- package/rules/date-without-year.yaml +2 -2
- package/rules/defined-term-form.yaml +2 -2
- package/rules/elapsed-years-mismatch.yaml +2 -2
- package/rules/empty-section.yaml +2 -2
- package/rules/empty-table-cell.yaml +2 -2
- package/rules/enumeration-marker-mix.yaml +102 -0
- package/rules/expletive-construction.yaml +2 -2
- package/rules/filler-word.yaml +74 -0
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/heading-marker-no-space.yaml +79 -0
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/internal-jargon.yaml +1 -0
- package/rules/known-misspelling.yaml +2 -2
- package/rules/latin-spacing.yaml +4 -4
- package/rules/link-definition-unused.yaml +107 -0
- package/rules/list-item-form-mix.yaml +2 -2
- package/rules/max-kanji-continuous.yaml +8 -2
- package/rules/max-sentence-length.yaml +2 -2
- package/rules/missing-final-period.yaml +2 -2
- package/rules/name-variant.yaml +2 -2
- package/rules/net-amount-mismatch.yaml +5 -5
- package/rules/ngram-repetition.yaml +2 -2
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/no-mixed-desumasu.yaml +62 -2
- package/rules/no-nakaguro-parallel.yaml +2 -2
- package/rules/nominalization.yaml +2 -2
- package/rules/number-style-consistency.yaml +2 -2
- package/rules/obligation-without-deadline.yaml +2 -2
- package/rules/one-sentence-paragraph-run.yaml +2 -2
- package/rules/orthographic-variant.yaml +2 -2
- package/rules/oxford-comma-consistency.yaml +2 -2
- package/rules/period-label-conflict.yaml +2 -2
- package/rules/preamble-length.yaml +2 -2
- package/rules/preferred-term.yaml +1 -0
- package/rules/pseudo-heading.yaml +79 -0
- package/rules/quote-without-source.yaml +2 -2
- package/rules/repeated-sentence-ending.yaml +2 -2
- package/rules/request-without-deadline.yaml +2 -2
- package/rules/reversed-link.yaml +78 -0
- package/rules/sa-ire.yaml +43 -0
- package/rules/sentence-rhythm.yaml +2 -2
- package/rules/serial-range-reversed.yaml +4 -4
- package/rules/shell-prompt-mix.yaml +2 -2
- package/rules/step-statement-mix.yaml +2 -2
- package/rules/table-absorbed-line.yaml +88 -0
- package/rules/teki-overuse.yaml +2 -2
- package/rules/term-consistency.yaml +56 -0
- package/rules/term-form.yaml +56 -0
- package/rules/title-case-consistency.yaml +4 -4
- package/rules/title-length.yaml +2 -2
- package/rules/topic-predicate-distance.yaml +2 -2
- package/rules/unbalanced-bracket.yaml +2 -2
- package/rules/undefined-acronym.yaml +4 -2
- package/rules/undefined-term.yaml +2 -2
- package/rules/unfilled-placeholder.yaml +2 -2
- package/rules/unknown-word.yaml +2 -2
- package/rules/use-before-definition.yaml +2 -2
- package/rules/vague-word-density.yaml +2 -2
- package/rules/version-mismatch.yaml +2 -2
- package/rules/weasel-word.yaml +3 -3
- package/rules/which-that-consistency.yaml +2 -2
- package/skills/chaff/SKILL.md +51 -7
- package/src/allow.ts +146 -0
- package/src/check-source.ts +33 -9
- package/src/clause-particles.ts +19 -3
- package/src/cli-text.ts +13 -4
- package/src/cli.ts +16 -15
- package/src/commands/eval.ts +1 -1
- package/src/commands/suppressions.ts +3 -3
- package/src/commands/test.ts +1 -1
- package/src/compound-head.ts +17 -8
- package/src/config/allow-problems.ts +75 -0
- package/src/config/by-path-problems.ts +29 -3
- package/src/config/by-path-rules.ts +78 -0
- package/src/config/by-path.ts +9 -0
- package/src/config/consistent-problems.ts +36 -0
- package/src/config/load.ts +87 -15
- package/src/config/option-problems.ts +8 -5
- package/src/config/prefer-problems.ts +22 -0
- package/src/config/prefer.ts +52 -0
- package/src/config/term-problems.ts +38 -0
- package/src/config/warnings.ts +9 -2
- package/src/cross-variants.ts +4 -7
- package/src/cross-votes.ts +35 -4
- package/src/custom/parse.ts +16 -3
- package/src/custom/problems.ts +9 -3
- package/src/custom/scope-field.ts +16 -0
- package/src/date-format.ts +43 -8
- package/src/derived/elapsed.ts +17 -2
- package/src/detectors/acronym-context.ts +7 -1
- package/src/detectors/acronym-gloss.ts +59 -11
- package/src/detectors/address-blank.ts +49 -0
- package/src/detectors/bare-comparative.ts +35 -3
- package/src/detectors/blank-structure.ts +18 -9
- package/src/detectors/bold-emphasis-form.ts +10 -1
- package/src/detectors/bold-label.ts +7 -2
- package/src/detectors/bracket-title-date.ts +36 -0
- package/src/detectors/broken-link.ts +14 -1
- package/src/detectors/capitalised-term.ts +18 -4
- package/src/detectors/change-rate.ts +29 -4
- package/src/detectors/char-shape.ts +19 -24
- package/src/detectors/clause-shape.ts +8 -4
- package/src/detectors/closing-cliche.ts +19 -2
- package/src/detectors/contraction-mix.ts +11 -3
- package/src/detectors/contraction-set-apart.ts +22 -2
- package/src/detectors/coordinate-adjective.ts +54 -1
- package/src/detectors/count-per-section.ts +13 -8
- package/src/detectors/counter-edge.ts +20 -0
- package/src/detectors/cross-variant.ts +16 -2
- package/src/detectors/currency-notation.ts +17 -6
- package/src/detectors/custom.ts +6 -4
- package/src/detectors/date-format.ts +1 -1
- package/src/detectors/date-repeated-day.ts +20 -0
- package/src/detectors/date-year.ts +8 -1
- package/src/detectors/defined-term-form.ts +6 -3
- package/src/detectors/definition-use.ts +8 -1
- package/src/detectors/derived-numbers.ts +1 -0
- package/src/detectors/document-shape.ts +4 -1
- package/src/detectors/email-letter.ts +6 -2
- package/src/detectors/empty-section.ts +10 -2
- package/src/detectors/en-shape.ts +31 -2
- package/src/detectors/enumeration-marker.ts +14 -0
- package/src/detectors/event-title-item.ts +57 -0
- package/src/detectors/example-baseline.ts +16 -1
- package/src/detectors/filler-word.ts +96 -0
- package/src/detectors/fullwidth-alnum.ts +24 -0
- package/src/detectors/gram-ending.ts +40 -0
- package/src/detectors/gram-repetition.ts +28 -4
- package/src/detectors/heading-case.ts +7 -1
- package/src/detectors/heading-marker-no-space.ts +62 -0
- package/src/detectors/hyphen-name-suffix.ts +3 -2
- package/src/detectors/inline-item-label.ts +113 -0
- package/src/detectors/kanji-name-edge.ts +11 -0
- package/src/detectors/kanji-run-pieces.ts +35 -8
- package/src/detectors/known-correction.ts +17 -1
- package/src/detectors/link-definition.ts +91 -0
- package/src/detectors/list-item-asides.ts +29 -0
- package/src/detectors/list-item-own.ts +38 -0
- package/src/detectors/list-item-phrase.ts +20 -8
- package/src/detectors/list-item.ts +7 -0
- package/src/detectors/list-items.ts +13 -2
- package/src/detectors/list-joint.ts +31 -2
- package/src/detectors/list-opening-conjunction.ts +22 -0
- package/src/detectors/list-parallel.ts +36 -53
- package/src/detectors/list-run.ts +16 -3
- package/src/detectors/list-verb-series.ts +24 -0
- package/src/detectors/mark-shape.ts +15 -19
- package/src/detectors/markdown-slip.ts +25 -1
- package/src/detectors/marked-word.ts +40 -0
- package/src/detectors/middle-dot.ts +27 -2
- package/src/detectors/missing-final-period.ts +9 -1
- package/src/detectors/name-variant-two-things.ts +37 -2
- package/src/detectors/net-amount-mismatch.ts +41 -4
- package/src/detectors/nominalization.ts +8 -1
- package/src/detectors/number-style.ts +8 -0
- package/src/detectors/open-end-scope.ts +3 -2
- package/src/detectors/ordinary-phrase.ts +13 -0
- package/src/detectors/organisation-run.ts +9 -0
- package/src/detectors/orthographic-variant-kanji-word.ts +33 -0
- package/src/detectors/orthographic-variant-open.ts +2 -1
- package/src/detectors/orthographic-variant-text.ts +20 -0
- package/src/detectors/orthographic-variant.ts +25 -32
- package/src/detectors/orthography.ts +18 -2
- package/src/detectors/oxford-comma.ts +16 -3
- package/src/detectors/paragraph-run.ts +7 -10
- package/src/detectors/placeholder-text.ts +22 -5
- package/src/detectors/placeholder.ts +10 -0
- package/src/detectors/pseudo-heading.ts +131 -0
- package/src/detectors/quote-around.ts +31 -6
- package/src/detectors/quoted-label.ts +22 -0
- package/src/detectors/ra-nuki.ts +3 -34
- package/src/detectors/register-label-note.ts +37 -0
- package/src/detectors/register-required.ts +56 -0
- package/src/detectors/register-voice.ts +36 -1
- package/src/detectors/registry/enumeration-marker.ts +4 -0
- package/src/detectors/registry/filler-word.ts +4 -0
- package/src/detectors/registry/heading-marker-no-space.ts +4 -0
- package/src/detectors/registry/link-definition-unused.ts +4 -0
- package/src/detectors/registry/pseudo-heading.ts +4 -0
- package/src/detectors/registry/reversed-link.ts +4 -0
- package/src/detectors/registry/sa-ire.ts +4 -0
- package/src/detectors/registry/table-absorbed-line.ts +4 -0
- package/src/detectors/registry/term-consistency.ts +4 -0
- package/src/detectors/registry/term-form.ts +4 -0
- package/src/detectors/relative-pronoun-mix.ts +18 -3
- package/src/detectors/release-notes.ts +19 -0
- package/src/detectors/request-owner.ts +62 -2
- package/src/detectors/reversed-link.ts +39 -0
- package/src/detectors/run-in-title.ts +35 -0
- package/src/detectors/sa-ire.ts +7 -0
- package/src/detectors/sentence-counts.ts +28 -9
- package/src/detectors/sentence-ending.ts +58 -13
- package/src/detectors/sentence-length.ts +34 -7
- package/src/detectors/sentence-rhythm.ts +6 -2
- package/src/detectors/signals.ts +2 -2
- package/src/detectors/structure.ts +4 -0
- package/src/detectors/technical-docs.ts +58 -9
- package/src/detectors/term-consistency.ts +41 -0
- package/src/detectors/term-form.ts +17 -0
- package/src/detectors/token-shape.ts +8 -4
- package/src/detectors/unbalanced-bracket.ts +4 -2
- package/src/detectors/unfilled-placeholder.ts +13 -1
- package/src/detectors/unknown-word-context.ts +6 -0
- package/src/detectors/unknown-word.ts +7 -1
- package/src/detectors/vague-density.ts +10 -2
- package/src/detectors/version-mismatch.ts +7 -1
- package/src/detectors/weasel-word.ts +13 -2
- package/src/document-prose.ts +43 -0
- package/src/document-scope.ts +66 -0
- package/src/document.ts +43 -50
- package/src/enumeration-marks.ts +233 -0
- package/src/facts/cross-facts.ts +10 -4
- package/src/facts/labelled-facts.ts +7 -4
- package/src/file-header.ts +3 -5
- package/src/files.ts +87 -8
- package/src/gitignore.ts +83 -0
- package/src/grade/stamp.ts +5 -0
- package/src/latin-word-boundary.ts +12 -0
- package/src/markdown-node.ts +1 -0
- package/src/name-separator.ts +29 -7
- package/src/news-dateline.ts +29 -0
- package/src/plugin.ts +21 -3
- package/src/reasons.ts +8 -0
- package/src/render/explain.ts +26 -1
- package/src/render/rules-json.ts +16 -2
- package/src/render/summary.ts +33 -4
- package/src/render/suppressions.ts +101 -4
- package/src/rule-load.ts +3 -2
- package/src/run-in-title.ts +91 -0
- package/src/run.ts +21 -8
- package/src/scope-markers.ts +25 -0
- package/src/scope-problem-text.ts +21 -0
- package/src/scoped-sentences.ts +41 -0
- package/src/setting-problems.ts +4 -0
- package/src/spelling.ts +4 -4
- package/src/stet-body.ts +74 -0
- package/src/stet.ts +113 -32
- package/src/structure/alert-lines.ts +19 -0
- package/src/structure/catch-all-row-blank.ts +22 -0
- package/src/structure/change-rate-tied.ts +113 -0
- package/src/structure/cross-definitions.ts +6 -9
- package/src/structure/defining-names.ts +14 -1
- package/src/structure/definition-use.ts +13 -3
- package/src/structure/forward-reference.ts +21 -0
- package/src/structure/net-amount.ts +44 -5
- package/src/structure/period-label-conflict.ts +22 -7
- package/src/structure/serial-range.ts +14 -6
- package/src/structure/version-mismatch.ts +41 -8
- package/src/structure/weekday.ts +14 -1
- package/src/table-cells.ts +2 -2
- package/src/term-form.ts +99 -0
- package/src/term-groups.ts +68 -0
- package/src/text-scope.ts +79 -0
- package/src/topic-clause.ts +120 -22
- package/src/unclosed-code-quote.ts +42 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { votesOutOfStep, type Vote } from "../cross-votes.ts";
|
|
2
2
|
|
|
3
3
|
// One term defined in two files of one run, in different words. Pure: the definitions come in already read from each file.
|
|
4
4
|
|
|
@@ -45,16 +45,13 @@ const voteOf = (file: FileDefinitions, term: string): Vote<WrittenDefinition>[]
|
|
|
45
45
|
|
|
46
46
|
const sameWording = (left: WrittenDefinition, right: WrittenDefinition): boolean => definitionKey(left.body) === definitionKey(right.body);
|
|
47
47
|
|
|
48
|
-
/** The files that define a term in other words than most files of the run that define it. */
|
|
48
|
+
/** The files that define a term in other words than most files of the run that define it; on an even split, every side. */
|
|
49
49
|
export const definitionsOutOfStep = (files: readonly FileDefinitions[]): DefinitionOutOfStep[] => {
|
|
50
50
|
const terms = [...new Set(files.flatMap((file) => file.definitions.map((definition) => definition.term)))];
|
|
51
|
-
return terms.flatMap((term) =>
|
|
52
|
-
|
|
51
|
+
return terms.flatMap((term) =>
|
|
52
|
+
votesOutOfStep(
|
|
53
53
|
files.flatMap((file) => voteOf(file, term)),
|
|
54
54
|
sameWording,
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
if (tally === undefined || usual === undefined) return [];
|
|
58
|
-
return tally.odd.map((vote) => ({ path: vote.path, definition: vote.value, usual, files: tally.usual.length }));
|
|
59
|
-
});
|
|
55
|
+
).map(({ vote, against }) => ({ path: vote.path, definition: vote.value, usual: against[0], files: against.length })),
|
|
56
|
+
);
|
|
60
57
|
};
|
|
@@ -126,10 +126,23 @@ const endsWithSelfPrefix = (text: string, prefixes: readonly string[]): boolean
|
|
|
126
126
|
LATIN_LETTER.test(prefix) ? new RegExp(String.raw`(?<![\p{L}\p{N}])${escapeRegExp(prefix)}\s+$`, "iu").test(text) : endsWithWordPrefix(text, prefix),
|
|
127
127
|
);
|
|
128
128
|
|
|
129
|
-
/**
|
|
129
|
+
/** 括弧の前の、一つか二つの小文字の語(this document の document、this sales agreement の sales agreement)。 */
|
|
130
|
+
const TRAILING_COMMON_NOUNS = [/(?<![\p{L}\p{N}])\p{Ll}[\p{L}-]*\s*$/u, /(?<![\p{L}\p{N}])\p{Ll}[\p{L}-]*\s+\p{Ll}[\p{L}-]*\s*$/u];
|
|
131
|
+
|
|
132
|
+
/** 括弧の前が、文書自身を指す頭と普通の名詞か(in this document (the "Terms of Service"))。 */
|
|
133
|
+
const followsSelfNoun = (before: string, prefixes: readonly string[]): boolean => {
|
|
134
|
+
const latin = prefixes.filter((prefix) => LATIN_LETTER.test(prefix));
|
|
135
|
+
return TRAILING_COMMON_NOUNS.some((noun) => {
|
|
136
|
+
const found = noun.exec(before);
|
|
137
|
+
return found !== null && endsWithSelfPrefix(before.slice(0, found.index), latin);
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/** 定義が文書自身の名前か(この就業規則(以下「規則」)、本規程(以下「規程」)、This Agreement … (this "Agreement")、this document (the "Terms"))。 */
|
|
130
142
|
export const namesItself = (defining: DefiningName, prefixes: readonly string[]): boolean =>
|
|
131
143
|
endsWithSelfPrefix(defining.head, prefixes) ||
|
|
132
144
|
endsWithSelfPrefix(defining.before, prefixes) ||
|
|
145
|
+
(defining.name === "" && followsSelfNoun(defining.before, prefixes)) ||
|
|
133
146
|
prefixes.some((prefix) => !LATIN_LETTER.test(prefix) && defining.name.startsWith(prefix));
|
|
134
147
|
|
|
135
148
|
/** 文の at の語の前が、文書自身を指す頭か(この規則、this Agreement)。 */
|
|
@@ -3,6 +3,7 @@ import { escapeRegExp } from "../orthography.ts";
|
|
|
3
3
|
import { inDocumentOrder } from "./issues.ts";
|
|
4
4
|
import { isTitleWords } from "./contents-lines.ts";
|
|
5
5
|
import { verbFormsOf } from "./gerund-phrase.ts";
|
|
6
|
+
import { pointsAhead, type ForwardReference } from "./forward-reference.ts";
|
|
6
7
|
import {
|
|
7
8
|
definingNameOf,
|
|
8
9
|
echoesName,
|
|
@@ -395,13 +396,20 @@ const citesSource = (texts: readonly BodyText[], markers: readonly string[], off
|
|
|
395
396
|
return markers.some((marker) => before.endsWith(marker) && SOURCE_END.test(before.slice(0, -marker.length)));
|
|
396
397
|
};
|
|
397
398
|
|
|
399
|
+
/** 語に、後ろで定義することを先に断る言葉(下記パブリック・ライセンス)が付いているか。 */
|
|
400
|
+
const pointsAheadAt = (texts: readonly BodyText[], words: readonly ForwardReference[], term: string, offset: number): boolean => {
|
|
401
|
+
const sentence = sentenceAt(texts, offset);
|
|
402
|
+
return sentence !== undefined && pointsAhead(sentence.text, offset - sentence.start, term, words);
|
|
403
|
+
};
|
|
404
|
+
|
|
398
405
|
/**
|
|
399
406
|
* 言語の語の一覧。selfPrefixes は文書自身の名前の頭(この、本、this)、sourceMarkers は語の意味の出どころを言う言葉(所定の)、
|
|
400
|
-
* singleKanjiNames は前の使用を探す一字の漢字の語(当事者の呼び名の甲・乙)。
|
|
407
|
+
* forwardReferences は読み手を後ろの本文へ向ける言葉(下記、below)、singleKanjiNames は前の使用を探す一字の漢字の語(当事者の呼び名の甲・乙)。
|
|
401
408
|
*/
|
|
402
409
|
export type EarlyUseWords = {
|
|
403
410
|
readonly selfPrefixes?: readonly string[];
|
|
404
411
|
readonly sourceMarkers?: readonly string[];
|
|
412
|
+
readonly forwardReferences?: readonly ForwardReference[];
|
|
405
413
|
readonly singleKanjiNames?: ReadonlySet<string>;
|
|
406
414
|
};
|
|
407
415
|
|
|
@@ -409,7 +417,7 @@ export type EarlyUseWords = {
|
|
|
409
417
|
* 文の途中で括弧に入れて定義した語((the "Seller")、以下「甲」という)を、その定義の文より前で使っている所。最初の一つだけ。
|
|
410
418
|
* 定義の文の中の現れ(株式会社GovTech東京(以下「GovTech東京」という。))は、定義する名前そのものなので数えない。札の文も、
|
|
411
419
|
* isTitle が言う題・見出し・目次の行も、漢字で終わる語にさらに漢字が続く長い語の一部も、定義の括弧の前の長い名前を写した所も、
|
|
412
|
-
* 語を含むもっと長い名前の中も、語の前に意味の出どころを書いた所(69条の3
|
|
420
|
+
* 語を含むもっと長い名前の中も、語の前に意味の出どころを書いた所(69条の3所定の小規模宅地等)も、後ろで定義することを先に断った所(下記パブリック・ライセンス)とそれより後ろも数えない。
|
|
413
421
|
* 英語の語を長い名前の終わりに書いた所(The National Security Act of 1947)より後ろの現れ(the Act)は、その名前を指すので数えない。文書自身の名前を定義した語は、selfPrefixes(この、本、this)を付けて前で書いても数えない。
|
|
414
422
|
* 定義の条("Seller" means、「甲」とは)は条の並びの頭にも終わりにも置く書き方があるので、前で使っても言わない。
|
|
415
423
|
* 定義の語の無い括弧の引用(("The key point is"))は例の引用と同じ形なので、その語を引用符で挙げただけの現れ
|
|
@@ -421,7 +429,7 @@ export const usesBeforeDefinition = (
|
|
|
421
429
|
texts: readonly BodyText[],
|
|
422
430
|
mentioned: Mentioned = NEVER_MENTIONED,
|
|
423
431
|
isTitle: IsTitle = NEVER_TITLE,
|
|
424
|
-
{ selfPrefixes = [], sourceMarkers = [], singleKanjiNames = new Set() }: EarlyUseWords = {},
|
|
432
|
+
{ selfPrefixes = [], sourceMarkers = [], forwardReferences = [], singleKanjiNames = new Set() }: EarlyUseWords = {},
|
|
425
433
|
): TermUse[] => {
|
|
426
434
|
const inline = terms.filter((term) => term.inline);
|
|
427
435
|
const names = definingNames(terms, texts);
|
|
@@ -432,9 +440,11 @@ export const usesBeforeDefinition = (
|
|
|
432
440
|
const defining = sentenceAt(texts, defined.span.start)?.start ?? defined.span.start;
|
|
433
441
|
const uses = usesOf(defined.term, texts, spans, "exact", defined.bare === true ? mentioned : NEVER_MENTIONED).filter((offset) => offset < defining);
|
|
434
442
|
const namedFirst = uses.find((offset) => endsNameAt(texts, defined.term, offset));
|
|
443
|
+
const announced = uses.find((offset) => pointsAheadAt(texts, forwardReferences, defined.term, offset));
|
|
435
444
|
const first = uses.find(
|
|
436
445
|
(offset) =>
|
|
437
446
|
!(namedFirst !== undefined && namedFirst < offset) &&
|
|
447
|
+
!(announced !== undefined && announced <= offset) &&
|
|
438
448
|
!isLabel(sentenceAt(texts, offset), defined.term) &&
|
|
439
449
|
!headsDefiningSentence(sentenceAt(texts, offset), defining) &&
|
|
440
450
|
!insideCaption(sentenceAt(texts, offset), offset) &&
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** 読み手を後ろの本文へ向ける言葉と、それが語のどちら側に立つか(下記、the following は前、below は後ろ)。 */
|
|
2
|
+
export type ForwardReference = { readonly pattern: string; readonly position?: "before" | "after" | undefined };
|
|
3
|
+
|
|
4
|
+
const LATIN_LETTER = /\p{Script=Latin}/u;
|
|
5
|
+
|
|
6
|
+
/** 言葉の端の字と、その外の字が、英語の一つの語に続いていないか(below は belowground の頭ではない)。 */
|
|
7
|
+
const meetsAtWordEdge = (edge: string, outside: string): boolean => !LATIN_LETTER.test(edge) || !LATIN_LETTER.test(outside);
|
|
8
|
+
|
|
9
|
+
/** 文の中の語に、後ろで定義することを先に断る言葉(下記パブリック・ライセンス、the Licence below)が付いているか。 */
|
|
10
|
+
export const pointsAhead = (sentence: string, at: number, term: string, words: readonly ForwardReference[]): boolean => {
|
|
11
|
+
const before = sentence.slice(0, at).trimEnd().toLowerCase();
|
|
12
|
+
const after = sentence
|
|
13
|
+
.slice(at + term.length)
|
|
14
|
+
.trimStart()
|
|
15
|
+
.toLowerCase();
|
|
16
|
+
return words.some(({ pattern, position }) => {
|
|
17
|
+
const word = pattern.toLowerCase();
|
|
18
|
+
if (position === "after") return after.startsWith(word) && meetsAtWordEdge(word.slice(-1), after.charAt(word.length));
|
|
19
|
+
return before.endsWith(word) && meetsAtWordEdge(word.charAt(0), before.charAt(before.length - word.length - 1));
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -234,10 +234,49 @@ export const tableNetMismatches = (header: readonly NetCell[], rows: readonly (r
|
|
|
234
234
|
/** A line that is a label and its amount (総支給額:117,380円, - Net pay: $1,396.41). */
|
|
235
235
|
export type LabelledLine = { readonly label: string; readonly value: NetCell };
|
|
236
236
|
|
|
237
|
+
/** Every labelled amount of one section's labelled lines. */
|
|
238
|
+
export const sectionAmounts = (lines: readonly LabelledLine[], words: NetWords): LabelledAmount[] =>
|
|
239
|
+
lines.flatMap((line) => labelledCells([{ start: 0, text: line.label }], [line.value], words));
|
|
240
|
+
|
|
237
241
|
/** The labelled lines of one section: each label that names a role, with its amount. */
|
|
238
242
|
export const sectionNetMismatch = (lines: readonly LabelledLine[], words: NetWords): NetIssue | undefined =>
|
|
239
|
-
netMismatch(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
)
|
|
243
|
+
netMismatch(sectionAmounts(lines, words), words, namesNet(labelCellsOf(lines), words));
|
|
244
|
+
|
|
245
|
+
/** Every labelled amount of one table, read both ways: under a header that names its column, and beside a first cell that names its row. */
|
|
246
|
+
export const tableAmounts = (header: readonly NetCell[], rows: readonly (readonly NetCell[])[], words: NetWords): LabelledAmount[] => [
|
|
247
|
+
...rows.filter((row) => row.length === header.length).flatMap((row) => labelledCells(header, row, words)),
|
|
248
|
+
...rows.flatMap((row) => {
|
|
249
|
+
const [label] = row;
|
|
250
|
+
return label === undefined ? [] : row.slice(1).flatMap((cell) => labelledCells([label], [cell], words));
|
|
251
|
+
}),
|
|
252
|
+
];
|
|
253
|
+
|
|
254
|
+
const DOCUMENT_ROLES = ["gross", "deduction", "net"] as const;
|
|
255
|
+
type DocumentRole = (typeof DOCUMENT_ROLES)[number];
|
|
256
|
+
|
|
257
|
+
/** The names a document may set out in scopes of their own (lexicon net-amount-document-label: 総支給額, 控除合計, 差引支給額). */
|
|
258
|
+
export type DocumentLabels = Readonly<Record<DocumentRole, readonly string[]>>;
|
|
259
|
+
|
|
260
|
+
const isDocumentLabel = (amount: LabelledAmount, labels: DocumentLabels): boolean =>
|
|
261
|
+
DOCUMENT_ROLES.some((role) => role === amount.role && labels[role].some((label) => keyOf(label) === amount.label));
|
|
262
|
+
|
|
263
|
+
/** Whether each listed name is the label of one cell or line at most, its amount readable or not (差引支給額:— counts). */
|
|
264
|
+
const isEachLabelledOnce = (labelTexts: readonly string[], labels: DocumentLabels): boolean =>
|
|
265
|
+
DOCUMENT_ROLES.flatMap((role) => labels[role]).every((label) => labelTexts.filter((text) => labelKey(text) === keyOf(label)).length <= 1);
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* A payslip that sets the three out in sections of their own (総支給額 under 支給, 控除合計 under 控除, 差引支給額 under 差引). Read
|
|
269
|
+
* only where nothing else can be meant: amounts holds every labelled amount of the document, and each must be one of the
|
|
270
|
+
* listed names, each name labelling one cell or line of the whole document (labelTexts: every table cell and every
|
|
271
|
+
* line's label) with one amount.
|
|
272
|
+
*/
|
|
273
|
+
export const documentNetMismatch = (
|
|
274
|
+
amounts: readonly LabelledAmount[],
|
|
275
|
+
labelTexts: readonly string[],
|
|
276
|
+
labels: DocumentLabels,
|
|
277
|
+
words: NetWords,
|
|
278
|
+
): NetIssue | undefined => {
|
|
279
|
+
if (amounts.length !== DOCUMENT_ROLES.length || !amounts.every((amount) => isDocumentLabel(amount, labels))) return undefined;
|
|
280
|
+
if (DOCUMENT_ROLES.some((role) => !amounts.some((amount) => amount.role === role)) || !isEachLabelledOnce(labelTexts, labels)) return undefined;
|
|
281
|
+
return netMismatch(amounts, words, true);
|
|
282
|
+
};
|
|
@@ -36,8 +36,8 @@ type Unit = {
|
|
|
36
36
|
readonly start: number;
|
|
37
37
|
readonly text: string;
|
|
38
38
|
readonly headerCell: boolean;
|
|
39
|
-
/**
|
|
40
|
-
readonly context: string;
|
|
39
|
+
/** 文書の期間の名前を探す範囲。表の見出しの升なら行の升ごと(| FY2025 | FY2026 | の FY2025 は比べる相手)、文なら文そのもの。 */
|
|
40
|
+
readonly context: readonly string[];
|
|
41
41
|
readonly section: string;
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -103,9 +103,22 @@ export const refersToCurrent = (label: PeriodLabel, stated: PeriodLabel, unit: P
|
|
|
103
103
|
|
|
104
104
|
const isAside = (text: string, words: ReportingWords): boolean => hasWord(text, words.comparisons) || hasWord(text, words.forecasts);
|
|
105
105
|
|
|
106
|
+
/**
|
|
107
|
+
* 表の見出しの一つの升が言う文書の期間の名前。年の中の一部(四半期、半期)は、同じ升に文書と違う年があれば別の年の同じ期間
|
|
108
|
+
* (| Q2 FY2026 | の Q2 は前の年の第2四半期)なので、文書の期間を言わない。年は、四半期が違っても同じ年のまま。
|
|
109
|
+
*/
|
|
110
|
+
const cellNames = (cell: string, stated: readonly PeriodLabel[], words: ReportingWords): PeriodLabel[] => {
|
|
111
|
+
const labels = labelsIn(cell, words);
|
|
112
|
+
const otherYear = labels.some((label) => !label.withinYear && conflictingStated(label, stated) !== undefined);
|
|
113
|
+
return otherYear ? labels.filter((label) => !label.withinYear) : labels;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const namesIn = (unit: Unit, stated: readonly PeriodLabel[], words: ReportingWords): PeriodLabel[] =>
|
|
117
|
+
unit.context.flatMap((piece) => (unit.headerCell ? cellNames(piece, stated, words) : labelsIn(piece, words)));
|
|
118
|
+
|
|
106
119
|
const issuesIn = (unit: Unit, stated: readonly PeriodLabel[], words: ReportingWords): PeriodConflict[] => {
|
|
107
120
|
if (isAside(unit.text, words) || isAside(unit.section, words)) return [];
|
|
108
|
-
const named =
|
|
121
|
+
const named = namesIn(unit, stated, words);
|
|
109
122
|
return labelsIn(unit.text, words).flatMap((label) => {
|
|
110
123
|
const statedLabel = conflictingStated(label, stated);
|
|
111
124
|
if (statedLabel === undefined || named.some((other) => sameLabel(other, statedLabel))) return [];
|
|
@@ -139,14 +152,16 @@ const headerRows = (lines: readonly Line[]): Line[] =>
|
|
|
139
152
|
const sectionAt = (headings: readonly Heading[], offset: number): string => headings.findLast((heading) => heading.start < offset)?.text ?? "";
|
|
140
153
|
|
|
141
154
|
const headerUnits = (lines: readonly Line[], headings: readonly Heading[]): Unit[] =>
|
|
142
|
-
headerRows(lines).flatMap((row) =>
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
headerRows(lines).flatMap((row) => {
|
|
156
|
+
const cells = cellsOf(row);
|
|
157
|
+
const context = cells.map((cell) => cell.text);
|
|
158
|
+
return cells.map((cell) => ({ start: cell.start, text: cell.text, headerCell: true, context, section: sectionAt(headings, cell.start) }));
|
|
159
|
+
});
|
|
145
160
|
|
|
146
161
|
const textUnits = (source: string, spans: readonly Span[], headings: readonly Heading[]): Unit[] =>
|
|
147
162
|
spans.map((span) => {
|
|
148
163
|
const text = source.slice(span.start, span.end);
|
|
149
|
-
return { start: span.start, text, headerCell: false, context: text, section: sectionAt(headings, span.start) };
|
|
164
|
+
return { start: span.start, text, headerCell: false, context: [text], section: sectionAt(headings, span.start) };
|
|
150
165
|
});
|
|
151
166
|
|
|
152
167
|
type Head = { readonly title: string; readonly periodLine: string; readonly end: number };
|
|
@@ -7,21 +7,29 @@ import type { RangeAmount } from "./amount-range.ts";
|
|
|
7
7
|
/** Fewer digits than this are a section or a grade (A1, B12), not a serial number. */
|
|
8
8
|
const MIN_DIGITS = 3;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const HYPHEN = "[-‐-]";
|
|
11
|
+
/**
|
|
12
|
+
* The series before the serial digits: one to four capital letters, then at most one group that a hyphen closes, of digits
|
|
13
|
+
* (BW24-) or of letters and digits after a hyphen (SN-2024-). Digits right after the letters need the hyphen, or they would
|
|
14
|
+
* run into the serial (BW248600).
|
|
15
|
+
*/
|
|
16
|
+
const PREFIX = `[A-ZA-Z]{1,4}(?:[0-90-9]{1,4}${HYPHEN}|${HYPHEN}[0-9A-ZA-Z0-9]{1,6}${HYPHEN})?`;
|
|
17
|
+
/** The series, an optional hyphen, the digits; not inside a longer word or number (XA2400, A2400B). */
|
|
18
|
+
const CODE = new RegExp(`(?<![A-Za-zA-Za-z0-90-9_])(${PREFIX})(${HYPHEN}?)([0-90-9]{${MIN_DIGITS},})(?![A-Za-zA-Za-z0-90-9_])`, "gu");
|
|
19
|
+
const HYPHENS = new RegExp(HYPHEN, "gu");
|
|
12
20
|
|
|
13
21
|
/**
|
|
14
|
-
* A code as one end of a range: two ends compare only when their
|
|
15
|
-
* (A2400 with A1800; not with B0100, A-1800 or
|
|
22
|
+
* A code as one end of a range: two ends compare only when their series, their hyphen and their number of digits agree
|
|
23
|
+
* (A2400 with A1800, BW24-8600 with BW24-8100; not with B0100, A-1800, A240 or BW25-8100).
|
|
16
24
|
*/
|
|
17
25
|
const rangeEndOf = (match: RegExpMatchArray): RangeAmount => {
|
|
18
|
-
const [whole,
|
|
26
|
+
const [whole, series = "", hyphen = "", digits = ""] = match;
|
|
19
27
|
const offset = match.index ?? 0;
|
|
20
28
|
const width = digits.length;
|
|
21
29
|
return {
|
|
22
30
|
offset,
|
|
23
31
|
end: offset + whole.length,
|
|
24
|
-
currency: `${
|
|
32
|
+
currency: `${series.normalize("NFKC").replaceAll(HYPHENS, "-")}|${hyphen === "" ? "" : "-"}|${width}`,
|
|
25
33
|
value: Number(digits.normalize("NFKC")),
|
|
26
34
|
scale: undefined,
|
|
27
35
|
position: "after",
|
|
@@ -5,16 +5,24 @@ import type { Span } from "../plugin.ts";
|
|
|
5
5
|
import type { StructureIssue } from "./issues.ts";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* A dotted version of three parts (2.4.0, v1.12.3, 3.0.0-beta.2). Two parts (22.04, 3.1) are
|
|
9
|
-
* first part of four digits is too often a date (2024.01.15).
|
|
8
|
+
* A dotted version of three parts (2.4.0, v1.12.3, 3.0.0-beta.2), also at the end of a sentence. Two parts (22.04, 3.1) are
|
|
9
|
+
* too often a decimal, and a first part of four digits is too often a date (2024.01.15).
|
|
10
10
|
*/
|
|
11
|
-
const VERSION = /(?<![\w.])v?(\d{1,3}\.\d{1,4}\.\d{1,4}(?:-[0-9A-Za-z
|
|
11
|
+
const VERSION = /(?<![\w.])v?(\d{1,3}\.\d{1,4}\.\d{1,4}(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?)(?!\w|\.\w)/gu;
|
|
12
12
|
|
|
13
13
|
/** A word that makes a version a bound or a starting point, not the version installed: 「2.3.0 から」 "from 2.3.0", "20.0.0 or later". */
|
|
14
14
|
export type RangeWord = { readonly word: string; readonly position: "before" | "after" };
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* What tells which versions are the block's: the bound words, the Latin words that lead to the version installed, and for
|
|
18
|
+
* a version a copula gives ("The current release is 2.4.0") the copulas and the words that say the subject is the current one.
|
|
19
|
+
*/
|
|
20
|
+
export type VersionWords = {
|
|
21
|
+
readonly ranges: readonly RangeWord[];
|
|
22
|
+
readonly versionWords: readonly string[];
|
|
23
|
+
readonly copulas: readonly string[];
|
|
24
|
+
readonly currentWords: readonly string[];
|
|
25
|
+
};
|
|
18
26
|
|
|
19
27
|
/** One code block: where it starts and the text between its fences. */
|
|
20
28
|
export type CodeBlock = { readonly start: number; readonly code: string };
|
|
@@ -62,14 +70,39 @@ const latinWordBefore = (text: string): string | undefined => {
|
|
|
62
70
|
return LATIN.test(word) ? word.toLowerCase() : undefined;
|
|
63
71
|
};
|
|
64
72
|
|
|
73
|
+
const includesWord = (list: readonly string[], word: string | undefined): boolean =>
|
|
74
|
+
word !== undefined && list.some((entry) => entry.toLowerCase() === word.toLowerCase());
|
|
75
|
+
|
|
76
|
+
/** Where a clause starts: after a mark that ends a sentence or a clause, or a line break. */
|
|
77
|
+
const CLAUSE_BREAK = /[.!?:;,]\s+|\n/u;
|
|
78
|
+
/** How many words may stand before the subject's word of version ("The current stable release is"). */
|
|
79
|
+
const SUBJECT_REACH = 3;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* "The current release is 2.4.0": a version a copula gives to a clause's subject that is a word leading to the version
|
|
83
|
+
* installed (lexicon version-lead), with only the words saying it is the current one (the, current, latest) or the block's
|
|
84
|
+
* names before it. Any other word there names another program or another release ("The Node.js version is", "The previous
|
|
85
|
+
* release is").
|
|
86
|
+
*/
|
|
87
|
+
const isStatedCurrent = (prose: string, found: Found, names: ReadonlySet<string>, words: VersionWords): boolean => {
|
|
88
|
+
const before = prose.slice(Math.max(0, found.start - WORD_REACH), found.start);
|
|
89
|
+
const clauses = before.split(CLAUSE_BREAK);
|
|
90
|
+
const clause = clauses.at(-1)?.trim() ?? "";
|
|
91
|
+
if (clauses.length === 1 && before.length === WORD_REACH) return false;
|
|
92
|
+
const [copula, subject, ...modifiers] = clause.split(/\s+/u).toReversed();
|
|
93
|
+
const isModifier = (word: string): boolean => names.has(word.toLowerCase()) || includesWord(words.currentWords, word);
|
|
94
|
+
const isSubject = subject !== undefined && (names.has(subject.toLowerCase()) || includesWord(words.versionWords, subject));
|
|
95
|
+
return includesWord(words.copulas, copula) && isSubject && modifiers.length <= SUBJECT_REACH && modifiers.every(isModifier);
|
|
96
|
+
};
|
|
97
|
+
|
|
65
98
|
/**
|
|
66
99
|
* Whether a lead-in version is about the block's software. A Latin word right before it must be one of the words that lead
|
|
67
100
|
* to the version installed (version, release, install; lexicon version-lead) or the pinned software: "Requires Node.js
|
|
68
101
|
* 18.17.0" over `npm install pkg@2.4.0` names another program. A version after no Latin word (「npm から 2.3.0」) is the block's.
|
|
69
102
|
*/
|
|
70
|
-
const isAboutBlock = (prose: string, found: Found, names: ReadonlySet<string>,
|
|
103
|
+
const isAboutBlock = (prose: string, found: Found, names: ReadonlySet<string>, words: VersionWords): boolean => {
|
|
71
104
|
const word = latinWordBefore(prose.slice(Math.max(0, found.start - WORD_REACH), found.start));
|
|
72
|
-
return word === undefined || names.has(word) || versionWords
|
|
105
|
+
return word === undefined || names.has(word) || includesWord(words.versionWords, word) || isStatedCurrent(prose, found, names, words);
|
|
73
106
|
};
|
|
74
107
|
|
|
75
108
|
const BLANK_LINE = /\r?\n[ \t]*\r?\n/gu;
|
|
@@ -140,7 +173,7 @@ const shownMismatches = (prose: string, leadIn: Span, code: string, words: Versi
|
|
|
140
173
|
if (shown.length !== 1 || only === undefined) return [];
|
|
141
174
|
const names = pinnedNames(code);
|
|
142
175
|
return versionsIn(prose.slice(leadIn.start, leadIn.end), leadIn.start)
|
|
143
|
-
.filter((found) => found.version !== only && !isBound(prose, found, words.ranges) && isAboutBlock(prose, found, names, words
|
|
176
|
+
.filter((found) => found.version !== only && !isBound(prose, found, words.ranges) && isAboutBlock(prose, found, names, words))
|
|
144
177
|
.map((found) => ({ offset: found.start, values: { written: found.version, code: only } }));
|
|
145
178
|
};
|
|
146
179
|
|
package/src/structure/weekday.ts
CHANGED
|
@@ -76,10 +76,23 @@ const anchorOf = (dated: readonly StructureNode[], node: StructureNode, context:
|
|
|
76
76
|
return fromTree(nearest) ?? stamp ?? fromTree(opening);
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* 文書が同じ月日を、同じ曜日を添えて年まで書いた日付(議事録の頭の「Wednesday, June 11, 2025」と、閉会の「Wednesday, June 11」)。
|
|
81
|
+
* 年の無い方はその日を指している。書いた年が二つ以上あれば決めない。
|
|
82
|
+
*/
|
|
83
|
+
const sameDayDated = (dated: readonly StructureNode[], node: StructureNode): string | undefined => {
|
|
84
|
+
const monthDay = String(node.attrs["value"]);
|
|
85
|
+
const twins = dated.filter((other) => other.attrs["weekday"] === node.attrs["weekday"] && String(other.attrs["value"]).endsWith(`-${monthDay}`));
|
|
86
|
+
const years = [...new Set(twins.map((other) => String(other.attrs["value"])))];
|
|
87
|
+
return years.length === 1 ? years[0] : undefined;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** 日付の年月日。年の無い日付は、同じ月日と曜日を年まで書いた日付か、近くの年を書いた日付から年を決めて付ける。決まらなければ undefined。 */
|
|
80
91
|
const fullValueOf = (dated: readonly StructureNode[], node: StructureNode, context: YearContext): string | undefined => {
|
|
81
92
|
const value = String(node.attrs["value"]);
|
|
82
93
|
if (!MONTH_DAY.test(value)) return value;
|
|
94
|
+
const sameDay = sameDayDated(dated, node);
|
|
95
|
+
if (sameDay !== undefined) return sameDay;
|
|
83
96
|
const anchor = anchorOf(dated, node, context);
|
|
84
97
|
return anchor === undefined ? undefined : withNearestYear(value, anchor);
|
|
85
98
|
};
|
package/src/table-cells.ts
CHANGED
|
@@ -35,7 +35,7 @@ export const proseWithCells = (prose: string, cells: readonly (Span & { readonly
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
/** 表の升の語は、読む rule があるときに一度だけ作る。升ごとの解析を、表を読まない rule に払わせない。 */
|
|
38
|
-
export const lazyCells = (make: () => readonly
|
|
39
|
-
const cells: { value?: readonly
|
|
38
|
+
export const lazyCells = <T>(make: () => readonly T[]): (() => readonly T[]) => {
|
|
39
|
+
const cells: { value?: readonly T[] } = {};
|
|
40
40
|
return () => (cells.value ??= make());
|
|
41
41
|
};
|
package/src/term-form.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Span } from "./plugin.ts";
|
|
2
|
+
import { escapeRegExp, HYPHEN_CHARS } from "./orthography.ts";
|
|
3
|
+
|
|
4
|
+
// The team's terms written exactly so (chaff.yaml terms: GitHub, JavaScript). A variant is the same term once case,
|
|
5
|
+
// width (GitHub, ガ), hyphens and spaces are set aside: Github, GitHub, Java Script, Java-Script. Pure.
|
|
6
|
+
|
|
7
|
+
/** What a variant may add or drop: spaces of any width and the hyphens orthography.ts reads. */
|
|
8
|
+
const SEPARATOR = new RegExp(`[\\s${HYPHEN_CHARS}‒–—]`, "u");
|
|
9
|
+
|
|
10
|
+
/** A character as the comparison sees it: compatibility-decomposed (full width to half, ガ to カ and its mark) and lower case. */
|
|
11
|
+
const foldChar = (char: string): string => (SEPARATOR.test(char) ? "" : char.normalize("NFKD").toLowerCase());
|
|
12
|
+
|
|
13
|
+
/** The term as the comparison sees it. Empty when it is only spaces and hyphens. */
|
|
14
|
+
export const foldTerm = (term: string): string => Array.from(term, foldChar).join("");
|
|
15
|
+
|
|
16
|
+
/** The folded text, with the span of the original text each folded code unit comes from. */
|
|
17
|
+
type Folded = { readonly text: string; readonly origins: readonly Span[] };
|
|
18
|
+
|
|
19
|
+
type Piece = { readonly folded: string; readonly span: Span };
|
|
20
|
+
|
|
21
|
+
const piecesOf = (text: string): Piece[] =>
|
|
22
|
+
Array.from(text).reduce<{ at: number; readonly pieces: Piece[] }>(
|
|
23
|
+
(acc, char) => {
|
|
24
|
+
acc.pieces.push({ folded: foldChar(char), span: { start: acc.at, end: acc.at + char.length } });
|
|
25
|
+
acc.at += char.length;
|
|
26
|
+
return acc;
|
|
27
|
+
},
|
|
28
|
+
{ at: 0, pieces: [] },
|
|
29
|
+
).pieces;
|
|
30
|
+
|
|
31
|
+
const foldText = (text: string): Folded => {
|
|
32
|
+
const pieces = piecesOf(text);
|
|
33
|
+
return {
|
|
34
|
+
text: pieces.map((piece) => piece.folded).join(""),
|
|
35
|
+
origins: pieces.flatMap((piece) => Array.from({ length: piece.folded.length }, () => piece.span)),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** A Latin letter or digit: a term that starts or ends with one is a word, and a match inside a longer word is not the term. */
|
|
40
|
+
const WORD_CHAR = /[\p{Script=Latin}\p{N}_]/u;
|
|
41
|
+
|
|
42
|
+
/** A run of printable ASCII without brackets, as an address or a path is written (…/github.com/… で). */
|
|
43
|
+
const ASCII_RUN = /[!-'*-~]+/gu;
|
|
44
|
+
/** What marks a run as a URL, an address or a path rather than a word: a slash, a backslash, an @, or a dot before a letter (github.com, README.md). */
|
|
45
|
+
const ADDRESS_MARK = /[/\\@]|\.[\p{L}\p{N}]/u;
|
|
46
|
+
|
|
47
|
+
/** The ASCII run around the span, without the span. A match whose run is a URL, an address or a path is not prose. */
|
|
48
|
+
const isInAddress = (text: string, span: Span): boolean =>
|
|
49
|
+
[...text.matchAll(ASCII_RUN)].some((run) => {
|
|
50
|
+
const end = run.index + run[0].length;
|
|
51
|
+
if (run.index > span.start || span.end > end) return false;
|
|
52
|
+
return ADDRESS_MARK.test(text.slice(run.index, span.start)) || ADDRESS_MARK.test(text.slice(span.end, end));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const isWordEdge = (text: string, span: Span, term: string): boolean => {
|
|
56
|
+
const before = WORD_CHAR.test(term.charAt(0)) && WORD_CHAR.test(text.charAt(span.start - 1));
|
|
57
|
+
const after = WORD_CHAR.test(term.charAt(term.length - 1)) && WORD_CHAR.test(text.charAt(span.end));
|
|
58
|
+
return !before && !after;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** The same term written as listed. Spaces count only as spaces: a line break inside "Claude Code" is the listed form. */
|
|
62
|
+
const isListedForm = (written: string, term: string): boolean => written.replace(/\s+/gu, " ") === term.replace(/\s+/gu, " ");
|
|
63
|
+
|
|
64
|
+
export type TermVariant = { readonly span: Span; readonly written: string; readonly term: string };
|
|
65
|
+
|
|
66
|
+
/** Where the folded term is found in the folded text, as spans of the original text. A match that starts or ends inside one character's folding is not one. */
|
|
67
|
+
const spansOf = (folded: Folded, foldedTerm: string): Span[] =>
|
|
68
|
+
[...folded.text.matchAll(new RegExp(escapeRegExp(foldedTerm), "gu"))].flatMap((match) => {
|
|
69
|
+
const first = folded.origins[match.index];
|
|
70
|
+
const last = folded.origins[match.index + foldedTerm.length - 1];
|
|
71
|
+
const splitsBefore = folded.origins[match.index - 1] === first;
|
|
72
|
+
const splitsAfter = folded.origins[match.index + foldedTerm.length] === last;
|
|
73
|
+
return first === undefined || last === undefined || splitsBefore || splitsAfter ? [] : [{ start: first.start, end: last.end }];
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const variantsOfTerm = (text: string, folded: Folded, term: string): TermVariant[] => {
|
|
77
|
+
const foldedTerm = foldTerm(term);
|
|
78
|
+
if (foldedTerm === "") return [];
|
|
79
|
+
return spansOf(folded, foldedTerm)
|
|
80
|
+
.filter((span) => isWordEdge(text, span, term) && !isInAddress(text, span))
|
|
81
|
+
.map((span) => ({ span, written: text.slice(span.start, span.end), term }));
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const isInsideLonger = (variant: TermVariant, other: TermVariant): boolean =>
|
|
85
|
+
other.span.end - other.span.start > variant.span.end - variant.span.start && other.span.start <= variant.span.start && variant.span.end <= other.span.end;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Every place in the text where a listed term is written in another form, in order. A place that one term covers and a
|
|
89
|
+
* longer one covers too (Claude inside Claude Code) belongs to the longer: the shorter is part of it. A place written as
|
|
90
|
+
* the longer term listed hides the shorter's variant inside it too. A place written as any listed term is not a variant.
|
|
91
|
+
*/
|
|
92
|
+
export const termVariants = (text: string, terms: readonly string[]): TermVariant[] => {
|
|
93
|
+
const folded = foldText(text);
|
|
94
|
+
const found = terms.flatMap((term) => variantsOfTerm(text, folded, term));
|
|
95
|
+
return found
|
|
96
|
+
.filter((variant) => !found.some((other) => isInsideLonger(variant, other)))
|
|
97
|
+
.filter((variant) => !terms.some((term) => isListedForm(variant.written, term)))
|
|
98
|
+
.toSorted((left, right) => left.span.start - right.span.start);
|
|
99
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { LexiconEntry, Span } from "./plugin.ts";
|
|
2
|
+
import { escapeRegExp } from "./orthography.ts";
|
|
3
|
+
|
|
4
|
+
// The team's groups of words that are each right but must not be mixed (chaff.yaml consistent: [[顧客, お客様], [log in,
|
|
5
|
+
// sign in]]): where the text writes a member, and, within one text, which members are the minority. Pure.
|
|
6
|
+
|
|
7
|
+
/** A group's members, in the order chaff.yaml lists them. */
|
|
8
|
+
export type TermGroup = readonly string[];
|
|
9
|
+
|
|
10
|
+
/** One written member: its group (by position in chaff.yaml), the member as listed, and where it is written. */
|
|
11
|
+
export type GroupHit = { readonly group: number; readonly member: string; readonly span: Span };
|
|
12
|
+
|
|
13
|
+
/** The groups as the word list carries them: one entry per member, its group's position in `group`. */
|
|
14
|
+
export const groupsOfLexicon = (lexicon: readonly LexiconEntry[]): TermGroup[] => {
|
|
15
|
+
const byGroup = new Map<string, string[]>();
|
|
16
|
+
lexicon.forEach((entry) => {
|
|
17
|
+
if (entry.group === undefined) return;
|
|
18
|
+
byGroup.set(entry.group, [...(byGroup.get(entry.group) ?? []), entry.pattern]);
|
|
19
|
+
});
|
|
20
|
+
return [...byGroup.values()];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** A Latin letter or digit: a member that starts or ends with one is a word, and a match inside a longer word is not it. */
|
|
24
|
+
const WORD_CHAR = /[\p{Script=Latin}\p{N}_]/u;
|
|
25
|
+
|
|
26
|
+
const isWordEdge = (text: string, span: Span, member: string): boolean => {
|
|
27
|
+
const before = WORD_CHAR.test(member.charAt(0)) && WORD_CHAR.test(text.charAt(span.start - 1));
|
|
28
|
+
const after = WORD_CHAR.test(member.charAt(member.length - 1)) && WORD_CHAR.test(text.charAt(span.end));
|
|
29
|
+
return !before && !after;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** A member as written, in any case: a sentence or a title capitalises "Log in" without choosing another word. */
|
|
33
|
+
const memberHits = (text: string, group: number, member: string): GroupHit[] =>
|
|
34
|
+
[...text.matchAll(new RegExp(escapeRegExp(member), "giu"))]
|
|
35
|
+
.map((match) => ({ group, member, span: { start: match.index, end: match.index + match[0].length } }))
|
|
36
|
+
.filter((hit) => isWordEdge(text, hit.span, member));
|
|
37
|
+
|
|
38
|
+
const isInsideLonger = (hit: GroupHit, other: GroupHit): boolean =>
|
|
39
|
+
other.span.end - other.span.start > hit.span.end - hit.span.start && other.span.start <= hit.span.start && hit.span.end <= other.span.end;
|
|
40
|
+
|
|
41
|
+
/** Every member written in the text, in order. A member inside a longer one written there (申込 inside 申し込み) is part of the longer. */
|
|
42
|
+
export const groupHits = (text: string, groups: readonly TermGroup[]): GroupHit[] => {
|
|
43
|
+
const found = groups.flatMap((members, group) => members.flatMap((member) => memberHits(text, group, member)));
|
|
44
|
+
return found.filter((hit) => !found.some((other) => isInsideLonger(hit, other))).toSorted((left, right) => left.span.start - right.span.start);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** What one group comes to in one text: nothing (one member or none), the minority places, or a tie between the most used members. */
|
|
48
|
+
export type GroupVerdict<T extends GroupHit> =
|
|
49
|
+
| { readonly kind: "minority"; readonly usual: string; readonly usualCount: number; readonly odd: readonly T[] }
|
|
50
|
+
| { readonly kind: "tie"; readonly members: readonly { readonly member: string; readonly count: number }[]; readonly first: T };
|
|
51
|
+
|
|
52
|
+
const countsOf = <T extends GroupHit>(hits: readonly T[]): Map<string, number> =>
|
|
53
|
+
hits.reduce((counts, hit) => counts.set(hit.member, (counts.get(hit.member) ?? 0) + 1), new Map<string, number>());
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* One group's hits in one text. With one member used there is nothing to say. With one member used most, the places of the
|
|
57
|
+
* others are the minority. When two or more share the most, neither side is taken: one verdict names every member used.
|
|
58
|
+
*/
|
|
59
|
+
export const groupVerdict = <T extends GroupHit>(hits: readonly T[]): GroupVerdict<T> | undefined => {
|
|
60
|
+
const counts = countsOf(hits);
|
|
61
|
+
const first = hits[0];
|
|
62
|
+
if (counts.size < 2 || first === undefined) return undefined;
|
|
63
|
+
const top = Math.max(...counts.values());
|
|
64
|
+
const leaders = [...counts].filter(([, count]) => count === top).map(([member]) => member);
|
|
65
|
+
const [usual] = leaders;
|
|
66
|
+
if (leaders.length > 1 || usual === undefined) return { kind: "tie", members: [...counts].map(([member, count]) => ({ member, count })), first };
|
|
67
|
+
return { kind: "minority", usual, usualCount: top, odd: hits.filter((hit) => hit.member !== usual) };
|
|
68
|
+
};
|