chaffjs 0.44.0 → 0.46.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/dist/announced-list.d.ts +2 -1
- package/dist/announced-list.d.ts.map +1 -1
- package/dist/announced-list.js +3 -1
- package/dist/announced-list.js.map +1 -1
- package/dist/body-section.d.ts +7 -0
- package/dist/body-section.d.ts.map +1 -1
- package/dist/body-section.js +15 -0
- package/dist/body-section.js.map +1 -1
- package/dist/derived/durations.d.ts +1 -0
- package/dist/derived/durations.d.ts.map +1 -1
- package/dist/derived/durations.js +2 -2
- package/dist/derived/durations.js.map +1 -1
- package/dist/derived/marked-dates.d.ts +2 -0
- package/dist/derived/marked-dates.d.ts.map +1 -1
- package/dist/derived/marked-dates.js +2 -0
- package/dist/derived/marked-dates.js.map +1 -1
- package/dist/detectors/abstract-length.d.ts +5 -1
- package/dist/detectors/abstract-length.d.ts.map +1 -1
- package/dist/detectors/abstract-length.js +13 -5
- package/dist/detectors/abstract-length.js.map +1 -1
- package/dist/detectors/acronym-capitals.d.ts +6 -0
- package/dist/detectors/acronym-capitals.d.ts.map +1 -0
- package/dist/detectors/acronym-capitals.js +30 -0
- package/dist/detectors/acronym-capitals.js.map +1 -0
- package/dist/detectors/adversative-ga.d.ts +1 -1
- package/dist/detectors/adversative-ga.d.ts.map +1 -1
- package/dist/detectors/adversative-ga.js +19 -2
- package/dist/detectors/adversative-ga.js.map +1 -1
- package/dist/detectors/bare-comparative.d.ts +1 -0
- package/dist/detectors/bare-comparative.d.ts.map +1 -1
- package/dist/detectors/bare-comparative.js +9 -2
- package/dist/detectors/bare-comparative.js.map +1 -1
- package/dist/detectors/bare-word-list.d.ts +7 -0
- package/dist/detectors/bare-word-list.d.ts.map +1 -0
- package/dist/detectors/bare-word-list.js +43 -0
- package/dist/detectors/bare-word-list.js.map +1 -0
- package/dist/detectors/bold-field-label.d.ts +8 -0
- package/dist/detectors/bold-field-label.d.ts.map +1 -0
- package/dist/detectors/bold-field-label.js +31 -0
- package/dist/detectors/bold-field-label.js.map +1 -0
- package/dist/detectors/bold-label.d.ts +15 -1
- package/dist/detectors/bold-label.d.ts.map +1 -1
- package/dist/detectors/bold-label.js +103 -20
- package/dist/detectors/bold-label.js.map +1 -1
- package/dist/detectors/broken-link.d.ts.map +1 -1
- package/dist/detectors/broken-link.js +22 -4
- package/dist/detectors/broken-link.js.map +1 -1
- package/dist/detectors/byline-list.d.ts +4 -0
- package/dist/detectors/byline-list.d.ts.map +1 -0
- package/dist/detectors/byline-list.js +19 -0
- package/dist/detectors/byline-list.js.map +1 -0
- package/dist/detectors/caps-screen-label.d.ts +3 -0
- package/dist/detectors/caps-screen-label.d.ts.map +1 -0
- package/dist/detectors/caps-screen-label.js +13 -0
- package/dist/detectors/caps-screen-label.js.map +1 -0
- package/dist/detectors/casual-voice.d.ts +8 -0
- package/dist/detectors/casual-voice.d.ts.map +1 -0
- package/dist/detectors/casual-voice.js +22 -0
- package/dist/detectors/casual-voice.js.map +1 -0
- package/dist/detectors/char-shape.d.ts +0 -6
- package/dist/detectors/char-shape.d.ts.map +1 -1
- package/dist/detectors/char-shape.js +4 -21
- package/dist/detectors/char-shape.js.map +1 -1
- package/dist/detectors/clause-shape.d.ts +2 -0
- package/dist/detectors/clause-shape.d.ts.map +1 -1
- package/dist/detectors/clause-shape.js +11 -2
- package/dist/detectors/clause-shape.js.map +1 -1
- package/dist/detectors/cleft-focus.d.ts +4 -0
- package/dist/detectors/cleft-focus.d.ts.map +1 -0
- package/dist/detectors/cleft-focus.js +31 -0
- package/dist/detectors/cleft-focus.js.map +1 -0
- package/dist/detectors/count-per-section.d.ts.map +1 -1
- package/dist/detectors/count-per-section.js +6 -2
- package/dist/detectors/count-per-section.js.map +1 -1
- package/dist/detectors/dangling-opener.d.ts.map +1 -1
- package/dist/detectors/dangling-opener.js +10 -1
- package/dist/detectors/dangling-opener.js.map +1 -1
- package/dist/detectors/date-year.d.ts.map +1 -1
- package/dist/detectors/date-year.js +11 -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 +17 -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 +13 -3
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/document-shape.d.ts +4 -1
- package/dist/detectors/document-shape.d.ts.map +1 -1
- package/dist/detectors/document-shape.js +12 -2
- package/dist/detectors/document-shape.js.map +1 -1
- package/dist/detectors/doubled-punctuation.d.ts.map +1 -1
- package/dist/detectors/doubled-punctuation.js +24 -1
- package/dist/detectors/doubled-punctuation.js.map +1 -1
- package/dist/detectors/email-letter.d.ts.map +1 -1
- package/dist/detectors/email-letter.js +5 -2
- package/dist/detectors/email-letter.js.map +1 -1
- package/dist/detectors/email-subject-reference.d.ts +6 -0
- package/dist/detectors/email-subject-reference.d.ts.map +1 -0
- package/dist/detectors/email-subject-reference.js +31 -0
- package/dist/detectors/email-subject-reference.js.map +1 -0
- package/dist/detectors/empty-section.d.ts +1 -1
- package/dist/detectors/empty-section.d.ts.map +1 -1
- package/dist/detectors/empty-section.js +3 -2
- package/dist/detectors/empty-section.js.map +1 -1
- package/dist/detectors/fact-consistency.js +2 -2
- package/dist/detectors/fact-consistency.js.map +1 -1
- package/dist/detectors/figure-order.d.ts +1 -1
- package/dist/detectors/figure-order.d.ts.map +1 -1
- package/dist/detectors/figure-order.js +7 -2
- package/dist/detectors/figure-order.js.map +1 -1
- package/dist/detectors/fullwidth-alnum.d.ts +2 -2
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
- package/dist/detectors/fullwidth-alnum.js +19 -3
- package/dist/detectors/fullwidth-alnum.js.map +1 -1
- package/dist/detectors/gram-heading.d.ts.map +1 -1
- package/dist/detectors/gram-heading.js +13 -1
- package/dist/detectors/gram-heading.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-echo.d.ts.map +1 -1
- package/dist/detectors/heading-echo.js +20 -7
- package/dist/detectors/heading-echo.js.map +1 -1
- package/dist/detectors/heading-number.d.ts +7 -0
- package/dist/detectors/heading-number.d.ts.map +1 -0
- package/dist/detectors/heading-number.js +21 -0
- package/dist/detectors/heading-number.js.map +1 -0
- package/dist/detectors/heading-numbering.d.ts.map +1 -1
- package/dist/detectors/heading-numbering.js +1 -7
- package/dist/detectors/heading-numbering.js.map +1 -1
- package/dist/detectors/hyphen-name-suffix.d.ts +3 -0
- package/dist/detectors/hyphen-name-suffix.d.ts.map +1 -0
- package/dist/detectors/hyphen-name-suffix.js +24 -0
- package/dist/detectors/hyphen-name-suffix.js.map +1 -0
- package/dist/detectors/katakana-density.d.ts.map +1 -1
- package/dist/detectors/katakana-density.js +7 -4
- package/dist/detectors/katakana-density.js.map +1 -1
- package/dist/detectors/lexicon.d.ts +1 -0
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +19 -1
- package/dist/detectors/lexicon.js.map +1 -1
- package/dist/detectors/link-shape.d.ts.map +1 -1
- package/dist/detectors/link-shape.js +10 -2
- package/dist/detectors/link-shape.js.map +1 -1
- package/dist/detectors/list-item-phrase.d.ts +20 -0
- package/dist/detectors/list-item-phrase.d.ts.map +1 -0
- package/dist/detectors/list-item-phrase.js +73 -0
- package/dist/detectors/list-item-phrase.js.map +1 -0
- package/dist/detectors/list-layout.d.ts +5 -0
- package/dist/detectors/list-layout.d.ts.map +1 -1
- package/dist/detectors/list-layout.js +12 -0
- package/dist/detectors/list-layout.js.map +1 -1
- package/dist/detectors/list-lead-in.d.ts.map +1 -1
- package/dist/detectors/list-lead-in.js +1 -17
- package/dist/detectors/list-lead-in.js.map +1 -1
- package/dist/detectors/list-parallel.d.ts.map +1 -1
- package/dist/detectors/list-parallel.js +29 -24
- package/dist/detectors/list-parallel.js.map +1 -1
- package/dist/detectors/lookalike-character.d.ts +2 -1
- package/dist/detectors/lookalike-character.d.ts.map +1 -1
- package/dist/detectors/lookalike-character.js +14 -1
- package/dist/detectors/lookalike-character.js.map +1 -1
- package/dist/detectors/mark-shape.d.ts +7 -2
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +41 -14
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/measured-facts.d.ts +5 -1
- package/dist/detectors/measured-facts.d.ts.map +1 -1
- package/dist/detectors/measured-facts.js +7 -3
- package/dist/detectors/measured-facts.js.map +1 -1
- package/dist/detectors/middle-dot.d.ts +12 -0
- package/dist/detectors/middle-dot.d.ts.map +1 -1
- package/dist/detectors/middle-dot.js +46 -0
- 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 +13 -1
- package/dist/detectors/missing-final-period.js.map +1 -1
- package/dist/detectors/name-variant.d.ts.map +1 -1
- package/dist/detectors/name-variant.js +2 -1
- package/dist/detectors/name-variant.js.map +1 -1
- package/dist/detectors/named-by-context.d.ts +13 -0
- package/dist/detectors/named-by-context.d.ts.map +1 -0
- package/dist/detectors/named-by-context.js +10 -0
- package/dist/detectors/named-by-context.js.map +1 -0
- 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 +19 -4
- package/dist/detectors/number-style.js.map +1 -1
- package/dist/detectors/numeral-opener.d.ts +1 -1
- package/dist/detectors/numeral-opener.d.ts.map +1 -1
- package/dist/detectors/numeral-opener.js +4 -2
- package/dist/detectors/numeral-opener.js.map +1 -1
- package/dist/detectors/open-end-names.d.ts +2 -0
- package/dist/detectors/open-end-names.d.ts.map +1 -1
- package/dist/detectors/open-end-names.js +8 -1
- package/dist/detectors/open-end-names.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 +10 -0
- package/dist/detectors/ordinary-phrase.js.map +1 -1
- package/dist/detectors/orthographic-variant.js +2 -2
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/output-lead-in.d.ts +3 -0
- package/dist/detectors/output-lead-in.d.ts.map +1 -0
- package/dist/detectors/output-lead-in.js +26 -0
- package/dist/detectors/output-lead-in.js.map +1 -0
- package/dist/detectors/outside-announced-list.d.ts.map +1 -1
- package/dist/detectors/outside-announced-list.js +6 -1
- package/dist/detectors/outside-announced-list.js.map +1 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +3 -1
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/paragraph-restatement.d.ts +4 -1
- package/dist/detectors/paragraph-restatement.d.ts.map +1 -1
- package/dist/detectors/paragraph-restatement.js +17 -2
- package/dist/detectors/paragraph-restatement.js.map +1 -1
- package/dist/detectors/person-consistency.d.ts +2 -1
- package/dist/detectors/person-consistency.d.ts.map +1 -1
- package/dist/detectors/person-consistency.js +11 -2
- package/dist/detectors/person-consistency.js.map +1 -1
- package/dist/detectors/placeholder-context.d.ts +16 -0
- package/dist/detectors/placeholder-context.d.ts.map +1 -0
- package/dist/detectors/placeholder-context.js +57 -0
- package/dist/detectors/placeholder-context.js.map +1 -0
- package/dist/detectors/placeholder-text.d.ts +2 -0
- package/dist/detectors/placeholder-text.d.ts.map +1 -1
- package/dist/detectors/placeholder-text.js +1 -1
- package/dist/detectors/placeholder-text.js.map +1 -1
- package/dist/detectors/quoted-title-line.d.ts +6 -0
- package/dist/detectors/quoted-title-line.d.ts.map +1 -0
- package/dist/detectors/quoted-title-line.js +14 -0
- package/dist/detectors/quoted-title-line.js.map +1 -0
- package/dist/detectors/register-interview.d.ts +4 -0
- package/dist/detectors/register-interview.d.ts.map +1 -0
- package/dist/detectors/register-interview.js +19 -0
- package/dist/detectors/register-interview.js.map +1 -0
- package/dist/detectors/registry/colloquial-opener-pile.d.ts +3 -0
- package/dist/detectors/registry/colloquial-opener-pile.d.ts.map +1 -0
- package/dist/detectors/registry/colloquial-opener-pile.js +3 -0
- package/dist/detectors/registry/colloquial-opener-pile.js.map +1 -0
- package/dist/detectors/registry/middle-dot.js +1 -1
- package/dist/detectors/repeated-head.d.ts.map +1 -1
- package/dist/detectors/repeated-head.js +23 -4
- package/dist/detectors/repeated-head.js.map +1 -1
- package/dist/detectors/request-owner.d.ts +3 -1
- package/dist/detectors/request-owner.d.ts.map +1 -1
- package/dist/detectors/request-owner.js +5 -2
- package/dist/detectors/request-owner.js.map +1 -1
- package/dist/detectors/run-together.d.ts +3 -0
- package/dist/detectors/run-together.d.ts.map +1 -0
- package/dist/detectors/run-together.js +13 -0
- package/dist/detectors/run-together.js.map +1 -0
- package/dist/detectors/sentence-counts.d.ts +8 -2
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +32 -7
- package/dist/detectors/sentence-counts.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts +2 -0
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +8 -2
- package/dist/detectors/sentence-ending.js.map +1 -1
- package/dist/detectors/sentence-parts.d.ts +10 -1
- package/dist/detectors/sentence-parts.d.ts.map +1 -1
- package/dist/detectors/sentence-parts.js +17 -2
- package/dist/detectors/sentence-parts.js.map +1 -1
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +10 -1
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/space-before-punctuation.d.ts +2 -2
- package/dist/detectors/space-before-punctuation.d.ts.map +1 -1
- package/dist/detectors/space-before-punctuation.js +13 -2
- package/dist/detectors/space-before-punctuation.js.map +1 -1
- package/dist/detectors/stray-space.js +1 -1
- package/dist/detectors/stray-space.js.map +1 -1
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +2 -1
- package/dist/detectors/structure-tree.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 +8 -3
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/superlative-context.d.ts +7 -0
- package/dist/detectors/superlative-context.d.ts.map +1 -1
- package/dist/detectors/superlative-context.js +6 -0
- package/dist/detectors/superlative-context.js.map +1 -1
- package/dist/detectors/technical-docs.d.ts.map +1 -1
- package/dist/detectors/technical-docs.js +5 -1
- package/dist/detectors/technical-docs.js.map +1 -1
- package/dist/detectors/template-sections.d.ts +1 -0
- package/dist/detectors/template-sections.d.ts.map +1 -1
- package/dist/detectors/template-sections.js +1 -1
- package/dist/detectors/template-sections.js.map +1 -1
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +16 -3
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
- package/dist/detectors/unbalanced-bracket.js +5 -1
- package/dist/detectors/unbalanced-bracket.js.map +1 -1
- package/dist/detectors/undefined-term.d.ts.map +1 -1
- package/dist/detectors/undefined-term.js +5 -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 +18 -1
- package/dist/detectors/unfilled-placeholder.js.map +1 -1
- package/dist/detectors/vague-density.d.ts.map +1 -1
- package/dist/detectors/vague-density.js +13 -1
- package/dist/detectors/vague-density.js.map +1 -1
- package/dist/detectors/verse-block.d.ts +4 -0
- package/dist/detectors/verse-block.d.ts.map +1 -0
- package/dist/detectors/verse-block.js +40 -0
- package/dist/detectors/verse-block.js.map +1 -0
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +1 -0
- package/dist/document.js.map +1 -1
- package/dist/email-parts.d.ts +2 -0
- package/dist/email-parts.d.ts.map +1 -1
- package/dist/email-parts.js +10 -7
- package/dist/email-parts.js.map +1 -1
- package/dist/eval.d.ts.map +1 -1
- package/dist/eval.js +3 -0
- package/dist/eval.js.map +1 -1
- package/dist/front-matter.d.ts +3 -0
- package/dist/front-matter.d.ts.map +1 -0
- package/dist/front-matter.js +13 -0
- package/dist/front-matter.js.map +1 -0
- package/dist/genre-check.js +1 -1
- package/dist/genre-check.js.map +1 -1
- package/dist/genre.d.ts +0 -2
- package/dist/genre.d.ts.map +1 -1
- package/dist/genre.js +1 -12
- package/dist/genre.js.map +1 -1
- package/dist/labelled-note-paragraphs.d.ts +4 -0
- package/dist/labelled-note-paragraphs.d.ts.map +1 -0
- package/dist/labelled-note-paragraphs.js +21 -0
- package/dist/labelled-note-paragraphs.js.map +1 -0
- package/dist/list-lead-sentence.d.ts +6 -0
- package/dist/list-lead-sentence.d.ts.map +1 -0
- package/dist/list-lead-sentence.js +20 -0
- package/dist/list-lead-sentence.js.map +1 -0
- package/dist/paragraph-runs.d.ts +2 -1
- package/dist/paragraph-runs.d.ts.map +1 -1
- package/dist/paragraph-runs.js +19 -2
- 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/reasons.d.ts +2 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +2 -0
- package/dist/reasons.js.map +1 -1
- package/dist/recording-title.d.ts +5 -0
- package/dist/recording-title.d.ts.map +1 -0
- package/dist/recording-title.js +11 -0
- package/dist/recording-title.js.map +1 -0
- package/dist/rule-of-three.d.ts +7 -2
- package/dist/rule-of-three.d.ts.map +1 -1
- package/dist/rule-of-three.js +11 -3
- package/dist/rule-of-three.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -1
- package/dist/run.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 +56 -2
- package/dist/sentence-load.js.map +1 -1
- package/dist/stray-space.d.ts +5 -2
- package/dist/stray-space.d.ts.map +1 -1
- package/dist/stray-space.js +24 -2
- package/dist/stray-space.js.map +1 -1
- package/dist/structure/cited-elsewhere.d.ts +5 -2
- package/dist/structure/cited-elsewhere.d.ts.map +1 -1
- package/dist/structure/cited-elsewhere.js +16 -6
- package/dist/structure/cited-elsewhere.js.map +1 -1
- package/dist/structure/definition-use.d.ts +2 -1
- 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/due-column.d.ts +5 -0
- package/dist/structure/due-column.d.ts.map +1 -0
- package/dist/structure/due-column.js +30 -0
- package/dist/structure/due-column.js.map +1 -0
- package/dist/structure/generic-role.d.ts +1 -0
- package/dist/structure/generic-role.d.ts.map +1 -1
- package/dist/structure/generic-role.js +6 -0
- package/dist/structure/generic-role.js.map +1 -1
- package/dist/structure/issues.js +1 -1
- package/dist/structure/issues.js.map +1 -1
- package/dist/structure/party-role.d.ts.map +1 -1
- package/dist/structure/party-role.js +4 -2
- package/dist/structure/party-role.js.map +1 -1
- package/dist/title-case-name.d.ts +5 -0
- package/dist/title-case-name.d.ts.map +1 -1
- package/dist/title-case-name.js +14 -0
- package/dist/title-case-name.js.map +1 -1
- package/package.json +3 -3
- package/rules/abstract-length.yaml +2 -2
- package/rules/adversative-ga-repeat.yaml +2 -2
- package/rules/all-caps-shouting.yaml +2 -2
- package/rules/attachment-not-attached.yaml +11 -6
- package/rules/bare-url-mix.yaml +2 -2
- package/rules/bold-density.yaml +2 -2
- package/rules/bold-label-list.yaml +22 -6
- package/rules/bracket-width-consistency.yaml +2 -2
- package/rules/clause-chain.yaml +2 -2
- package/rules/closing-cliche.yaml +2 -2
- package/rules/code-fence-language-mix.yaml +2 -2
- package/rules/colloquial-opener.yaml +3 -3
- package/rules/comparative-without-baseline.yaml +2 -2
- package/rules/dangling-participle.yaml +2 -2
- package/rules/date-order.yaml +2 -2
- package/rules/defined-term-form.yaml +2 -2
- package/rules/demonstrative-opener-run.yaml +2 -2
- package/rules/doubled-punctuation.yaml +2 -2
- package/rules/duration-mismatch.yaml +2 -2
- package/rules/email-subject-length.yaml +2 -2
- package/rules/emoji-density.yaml +2 -2
- package/rules/empty-intensifier.yaml +2 -2
- package/rules/empty-section.yaml +2 -2
- package/rules/figure-reference-order.yaml +2 -2
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/katakana-density.yaml +2 -2
- package/rules/list-item-form-mix.yaml +2 -2
- package/rules/lookalike-character.yaml +8 -5
- package/rules/max-kanji-continuous.yaml +4 -0
- package/rules/max-ten.yaml +3 -3
- package/rules/missing-final-period.yaml +2 -2
- package/rules/name-variant.yaml +2 -2
- package/rules/ngram-repetition.yaml +2 -2
- package/rules/no-lead.yaml +2 -2
- package/rules/no-mixed-desumasu.yaml +3 -2
- package/rules/no-nakaguro-parallel.yaml +2 -2
- package/rules/number-style-consistency.yaml +2 -2
- package/rules/numeral-sentence-start.yaml +2 -2
- package/rules/one-sentence-paragraph-run.yaml +2 -2
- package/rules/orthographic-variant.yaml +2 -2
- package/rules/outside-announced-list.yaml +2 -2
- package/rules/oxford-comma-consistency.yaml +2 -2
- package/rules/paragraph-length-variance.yaml +27 -3
- package/rules/paragraph-restatement.yaml +2 -2
- package/rules/party-role-name.yaml +2 -2
- package/rules/person-consistency.yaml +2 -2
- package/rules/preamble-length.yaml +2 -2
- package/rules/repeated-conjunction.yaml +2 -2
- package/rules/repeated-sentence-ending.yaml +2 -2
- package/rules/repeated-sentence-head.yaml +2 -2
- package/rules/request-without-deadline.yaml +2 -2
- package/rules/requirement-smell.yaml +2 -2
- package/rules/rule-of-three.yaml +2 -2
- package/rules/sentence-spacing-consistency.yaml +2 -2
- package/rules/space-before-punctuation.yaml +2 -2
- package/rules/stray-space.yaml +7 -4
- package/rules/summary-fact-mismatch.yaml +2 -2
- package/rules/taigen-dome-in-prose.yaml +2 -2
- package/rules/teki-overuse.yaml +4 -2
- package/rules/title-case-consistency.yaml +2 -2
- package/rules/title-length.yaml +2 -2
- package/rules/total-mismatch.yaml +1 -1
- package/rules/unbalanced-bracket.yaml +3 -3
- package/rules/undefined-term.yaml +2 -2
- package/rules/unfilled-placeholder.yaml +2 -2
- package/rules/unqualified-superlative.yaml +2 -2
- package/rules/use-before-definition.yaml +2 -2
- package/rules/vague-word-density.yaml +2 -2
- package/rules/very-adjective.yaml +1 -1
- package/rules/warning-without-action.yaml +2 -2
- package/rules/yori-as-from.yaml +1 -0
- package/src/announced-list.ts +12 -3
- package/src/body-section.ts +19 -0
- package/src/derived/durations.ts +3 -2
- package/src/derived/marked-dates.ts +4 -0
- package/src/detectors/abstract-length.ts +16 -6
- package/src/detectors/acronym-capitals.ts +30 -0
- package/src/detectors/adversative-ga.ts +24 -2
- package/src/detectors/bare-comparative.ts +12 -2
- package/src/detectors/bare-word-list.ts +61 -0
- package/src/detectors/bold-field-label.ts +33 -0
- package/src/detectors/bold-label.ts +129 -20
- package/src/detectors/broken-link.ts +23 -2
- package/src/detectors/byline-list.ts +24 -0
- package/src/detectors/caps-screen-label.ts +15 -0
- package/src/detectors/casual-voice.ts +30 -0
- package/src/detectors/char-shape.ts +8 -22
- package/src/detectors/clause-shape.ts +14 -3
- package/src/detectors/cleft-focus.ts +40 -0
- package/src/detectors/count-per-section.ts +6 -2
- package/src/detectors/dangling-opener.ts +12 -1
- package/src/detectors/date-year.ts +12 -1
- package/src/detectors/defined-term-form.ts +19 -3
- package/src/detectors/definition-use.ts +23 -4
- package/src/detectors/document-shape.ts +16 -2
- package/src/detectors/doubled-punctuation.ts +26 -1
- package/src/detectors/email-letter.ts +5 -3
- package/src/detectors/email-subject-reference.ts +36 -0
- package/src/detectors/empty-section.ts +3 -2
- package/src/detectors/fact-consistency.ts +2 -2
- package/src/detectors/figure-order.ts +8 -2
- package/src/detectors/fullwidth-alnum.ts +24 -3
- package/src/detectors/gram-heading.ts +15 -1
- package/src/detectors/heading-case.ts +7 -1
- package/src/detectors/heading-echo.ts +21 -8
- package/src/detectors/heading-number.ts +20 -0
- package/src/detectors/heading-numbering.ts +1 -9
- package/src/detectors/hyphen-name-suffix.ts +30 -0
- package/src/detectors/katakana-density.ts +8 -4
- package/src/detectors/lexicon.ts +18 -1
- package/src/detectors/link-shape.ts +16 -2
- package/src/detectors/list-item-phrase.ts +86 -0
- package/src/detectors/list-layout.ts +17 -0
- package/src/detectors/list-lead-in.ts +1 -19
- package/src/detectors/list-parallel.ts +31 -28
- package/src/detectors/lookalike-character.ts +19 -2
- package/src/detectors/mark-shape.ts +46 -9
- package/src/detectors/measured-facts.ts +11 -4
- package/src/detectors/middle-dot.ts +54 -0
- package/src/detectors/missing-final-period.ts +14 -1
- package/src/detectors/name-variant.ts +2 -1
- package/src/detectors/named-by-context.ts +15 -0
- package/src/detectors/number-style.ts +26 -4
- package/src/detectors/numeral-opener.ts +4 -2
- package/src/detectors/open-end-names.ts +11 -1
- package/src/detectors/ordinary-phrase.ts +10 -0
- package/src/detectors/orthographic-variant.ts +2 -2
- package/src/detectors/output-lead-in.ts +28 -0
- package/src/detectors/outside-announced-list.ts +6 -1
- package/src/detectors/oxford-comma.ts +3 -1
- package/src/detectors/paragraph-restatement.ts +17 -2
- package/src/detectors/person-consistency.ts +14 -2
- package/src/detectors/placeholder-context.ts +72 -0
- package/src/detectors/placeholder-text.ts +1 -1
- package/src/detectors/quoted-title-line.ts +13 -0
- package/src/detectors/register-interview.ts +22 -0
- package/src/detectors/registry/colloquial-opener-pile.ts +4 -0
- package/src/detectors/registry/middle-dot.ts +1 -1
- package/src/detectors/repeated-head.ts +32 -6
- package/src/detectors/request-owner.ts +5 -2
- package/src/detectors/run-together.ts +15 -0
- package/src/detectors/sentence-counts.ts +34 -7
- package/src/detectors/sentence-ending.ts +13 -2
- package/src/detectors/sentence-parts.ts +20 -2
- package/src/detectors/signals.ts +11 -1
- package/src/detectors/space-before-punctuation.ts +24 -4
- package/src/detectors/stray-space.ts +1 -1
- package/src/detectors/structure-tree.ts +12 -9
- package/src/detectors/structure.ts +7 -3
- package/src/detectors/superlative-context.ts +10 -0
- package/src/detectors/technical-docs.ts +5 -3
- package/src/detectors/template-sections.ts +1 -1
- package/src/detectors/token-shape.ts +19 -4
- package/src/detectors/unbalanced-bracket.ts +9 -1
- package/src/detectors/undefined-term.ts +5 -1
- package/src/detectors/unfilled-placeholder.ts +22 -1
- package/src/detectors/vague-density.ts +15 -2
- package/src/detectors/verse-block.ts +48 -0
- package/src/document.ts +1 -0
- package/src/email-parts.ts +16 -7
- package/src/eval.ts +2 -0
- package/src/front-matter.ts +14 -0
- package/src/genre-check.ts +1 -1
- package/src/genre.ts +1 -15
- package/src/labelled-note-paragraphs.ts +30 -0
- package/src/list-lead-sentence.ts +24 -0
- package/src/paragraph-runs.ts +25 -2
- package/src/plugin.ts +2 -0
- package/src/reasons.ts +4 -0
- package/src/recording-title.ts +16 -0
- package/src/rule-of-three.ts +22 -5
- package/src/run.ts +3 -1
- package/src/sentence-load.ts +68 -2
- package/src/stray-space.ts +37 -6
- package/src/structure/cited-elsewhere.ts +18 -6
- package/src/structure/definition-use.ts +10 -1
- package/src/structure/due-column.ts +33 -0
- package/src/structure/generic-role.ts +8 -0
- package/src/structure/issues.ts +1 -1
- package/src/structure/party-role.ts +3 -2
- package/src/title-case-name.ts +19 -0
|
@@ -7,6 +7,7 @@ import { opensAsNounPhrase } from "./nominal-step.ts";
|
|
|
7
7
|
import { quoteAt } from "./structure-tree.ts";
|
|
8
8
|
import { escapeRegExp } from "../orthography.ts";
|
|
9
9
|
import { isFormatTemplate } from "../format-template.ts";
|
|
10
|
+
import { afterOutputLeadIn } from "./output-lead-in.ts";
|
|
10
11
|
import type { Detector, Finding, ProseDocument, Span, Token } from "../plugin.ts";
|
|
11
12
|
|
|
12
13
|
const patternsOf = (doc: ProseDocument, id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
@@ -37,11 +38,12 @@ export const untaggedFewer = (fences: readonly CodeFence[], limit: number): read
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
export const codeFenceLanguage: Detector = (doc, options): Finding[] => {
|
|
41
|
+
const outputWords = patternsOf(doc, "output-lead-in");
|
|
40
42
|
const fences = codeFences(doc.source).filter(wantsLanguage);
|
|
41
43
|
const tagged = fences.filter((fence) => fence.language !== "").length;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
44
|
+
// A block of plain output (after "we'd expect to see:") is in no language: it still counts, but is not pointed at.
|
|
45
|
+
const reported = untaggedFewer(fences, options.limit).filter((fence) => !afterOutputLeadIn(doc.source, fence.start, outputWords));
|
|
46
|
+
return reported.map((fence) => finding(doc, "code-fence-language-mix", fence.start, { tagged, untagged: fences.length - tagged }));
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
export type PromptStyle = "prompt" | "bare" | undefined;
|
|
@@ -11,7 +11,7 @@ const LATIN = /\p{Script=Latin}/u;
|
|
|
11
11
|
/** Does the character beside a match end the word? A Latin edge needs a non-letter next to it; a CJK word stands anywhere. */
|
|
12
12
|
const boundsWord = (edge: string, beside: string | undefined): boolean => !LATIN.test(edge) || beside === undefined || !/[\p{L}\p{N}]/u.test(beside);
|
|
13
13
|
|
|
14
|
-
const holdsWordAt = (text: string, pattern: string, index: number): boolean =>
|
|
14
|
+
export const holdsWordAt = (text: string, pattern: string, index: number): boolean =>
|
|
15
15
|
boundsWord(pattern[0] ?? "", text[index - 1]) && boundsWord(pattern.at(-1) ?? "", text[index + pattern.length]);
|
|
16
16
|
|
|
17
17
|
/** The heading names a template: one of the words appears in it as a whole word, in any case. */
|
|
@@ -2,11 +2,13 @@ import { hasParticle, isClosed, lastContent } from "../sentence-shape.ts";
|
|
|
2
2
|
import { isWithinAny, quotedIn } from "../quoted-span.ts";
|
|
3
3
|
import { chronologyRows } from "../chronology-rows.ts";
|
|
4
4
|
import { externalLinkTitleSpans } from "../link-title.ts";
|
|
5
|
-
import type { Detector, Finding, Span, Token } from "../plugin.ts";
|
|
5
|
+
import type { Detector, Finding, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
|
|
6
6
|
import { countedTokens, uncountedWordsOf, type UncountedWords } from "../uncounted-particles.ts";
|
|
7
7
|
import { boundWordParticles } from "../bound-word-particles.ts";
|
|
8
8
|
import { setPhraseParticles } from "../set-phrase-particles.ts";
|
|
9
9
|
import { noteSentences } from "../note-paragraphs.ts";
|
|
10
|
+
import { labelledNoteSentences } from "../labelled-note-paragraphs.ts";
|
|
11
|
+
import { listLeadSentences } from "../list-lead-sentence.ts";
|
|
10
12
|
import { documentNameSpans } from "./particle-run-names.ts";
|
|
11
13
|
import { namedLongForms } from "./particle-run-long-forms.ts";
|
|
12
14
|
import { quotedNameSpans, quotedNames } from "./particle-run-quoted-names.ts";
|
|
@@ -24,11 +26,24 @@ const isDependent = (token: Token): boolean => token.features?.["NounType"] ===
|
|
|
24
26
|
|
|
25
27
|
const inside = (span: Span, spans: readonly Span[]): boolean => spans.some((other) => span.start >= other.start && span.start < other.end);
|
|
26
28
|
|
|
29
|
+
/** 表や図の注の段落の頭の語((注1)の「注」)。 */
|
|
30
|
+
const NOTE_LABEL_LEXICON = "note-paragraph-label";
|
|
31
|
+
|
|
32
|
+
/** 名詞で止めるのが書き方の文: 年表の行、注や文献の一覧、(注1)で始まる表の注、箇条書きへ渡す文(以下のとおり説明。)。 */
|
|
33
|
+
const clippedByForm = (doc: ProseDocument): ReadonlySet<Sentence> => {
|
|
34
|
+
const patterns = (id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
35
|
+
return new Set([
|
|
36
|
+
...chronologyRows(doc),
|
|
37
|
+
...noteSentences(doc.source, doc.paragraphs),
|
|
38
|
+
...labelledNoteSentences(doc.source, doc.paragraphs, patterns(NOTE_LABEL_LEXICON), patterns("note-mark")),
|
|
39
|
+
...listLeadSentences(doc.sentences, doc.lists, doc.source),
|
|
40
|
+
]);
|
|
41
|
+
};
|
|
42
|
+
|
|
27
43
|
export const nounEnding: Detector = (doc, options): Finding[] => {
|
|
28
|
-
const
|
|
29
|
-
const notes = noteSentences(doc.source, doc.paragraphs);
|
|
44
|
+
const clipped = clippedByForm(doc);
|
|
30
45
|
const ended = doc.sentences.filter((sentence) => {
|
|
31
|
-
if (inside(sentence.span, doc.listSpans) ||
|
|
46
|
+
if (inside(sentence.span, doc.listSpans) || clipped.has(sentence) || !isClosed(sentence) || !hasParticle(sentence)) return false;
|
|
32
47
|
const last = lastContent(sentence);
|
|
33
48
|
return last !== undefined && NOMINAL.has(last.pos) && !isDependent(last);
|
|
34
49
|
});
|
|
@@ -16,6 +16,7 @@ type Bracket = { readonly open: string; readonly close: string; readonly family:
|
|
|
16
16
|
|
|
17
17
|
const BRACKETS: readonly Bracket[] = [
|
|
18
18
|
{ open: "「", close: "」", family: "kagi" },
|
|
19
|
+
{ open: "「", close: "」", family: "kagi" },
|
|
19
20
|
{ open: "『", close: "』", family: "double-kagi" },
|
|
20
21
|
{ open: "(", close: ")", family: "round" },
|
|
21
22
|
{ open: "(", close: ")", family: "round" },
|
|
@@ -51,6 +52,12 @@ export type BracketProblem = {
|
|
|
51
52
|
type Open = { readonly bracket: Bracket; readonly offset: number };
|
|
52
53
|
type Scan = { readonly open: Open[]; readonly problems: BracketProblem[] };
|
|
53
54
|
|
|
55
|
+
/** 半角の「「」」。幅の違いは hankaku-kana が指すので、全角と組んでも幅の違いとしては指さない。 */
|
|
56
|
+
const HALFWIDTH_KAGI: ReadonlySet<string> = new Set(["「", "」"]);
|
|
57
|
+
|
|
58
|
+
const isWidthSlip = (opened: Bracket, closing: Bracket): boolean =>
|
|
59
|
+
opened !== closing && !HALFWIDTH_KAGI.has(opened.open) && !HALFWIDTH_KAGI.has(closing.close);
|
|
60
|
+
|
|
54
61
|
const unclosedOf = (entry: Open): BracketProblem => ({ kind: "unclosed", offset: entry.offset, mark: entry.bracket.open });
|
|
55
62
|
|
|
56
63
|
const closeWith = (scan: Scan, text: string, bracket: Bracket, offset: number): void => {
|
|
@@ -69,7 +76,8 @@ const closeWith = (scan: Scan, text: string, bracket: Bracket, offset: number):
|
|
|
69
76
|
.slice(1)
|
|
70
77
|
.filter((inner) => !(QUOTATIONS.has(bracket.family) && inner.offset === offset - 1))
|
|
71
78
|
.forEach((inner) => scan.problems.push(unclosedOf(inner)));
|
|
72
|
-
if (opened !== undefined && opened.bracket
|
|
79
|
+
if (opened !== undefined && isWidthSlip(opened.bracket, bracket))
|
|
80
|
+
scan.problems.push({ kind: "mismatch", offset, mark: bracket.close, partner: opened.bracket.open });
|
|
73
81
|
};
|
|
74
82
|
|
|
75
83
|
/** 段落(空行で区切った塊)の最初の字。 */
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// marks a word as one of its terms; a term with that prefix and no definition leaves the reader asking what it is.
|
|
4
4
|
// Only the document's own references (本条, 本契約: self-reference-noun and document-kind) are left. Pure; the parts of
|
|
5
5
|
// speech decide where a prefix is a prefix (本 in 本成果物) and not part of a word (本人, 本日).
|
|
6
|
+
import { isRunTogether } from "./run-together.ts";
|
|
6
7
|
import { definedTerms } from "../structure/definition-use.ts";
|
|
7
8
|
import { prefixGroupsOf, prefixVariants } from "../structure/term-prefix.ts";
|
|
8
9
|
import { quoteAt } from "./structure-tree.ts";
|
|
@@ -193,5 +194,8 @@ export const undefinedTerm: Detector = (doc): Finding[] => {
|
|
|
193
194
|
groupSuffixes: patternsOf(doc, "defined-term-group-suffix"),
|
|
194
195
|
inheritsDefinitions: patternsOf(doc, "definitions-inherited").some((phrase) => phrase !== "" && doc.source.includes(phrase)),
|
|
195
196
|
});
|
|
196
|
-
|
|
197
|
+
const dictionary = doc.dictionary?.() ?? new Set<string>();
|
|
198
|
+
// A term holding a run-together word (Space Includingspecified Description) is text a conversion joined, not a term.
|
|
199
|
+
const capitalised = capitalisedUses(doc, sentences, definitions).filter((use) => !use.term.split(/\s+/u).some((word) => isRunTogether(word, dictionary)));
|
|
200
|
+
return [...prefixed, ...capitalised].map((use) => findingOf(doc, use));
|
|
197
201
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
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
|
+
import { BLANK_SUFFIX, placeholderSpans } from "./placeholder-text.ts";
|
|
5
5
|
import { TEMPLATE, isInside, templateSections } from "./template-sections.ts";
|
|
6
6
|
import { tableBodyCells } from "../facts/table-facts.ts";
|
|
7
7
|
import { proseAndTablesOf } from "../table-text.ts";
|
|
8
|
+
import { EXAMPLE_LEAD, captionsFillLine, filledFieldLabels, insideQuotedExample, lineAround } from "./placeholder-context.ts";
|
|
8
9
|
|
|
9
10
|
/** The prose covers tables, so a blank left in a cell (| Owner | [Name] |) is read from the cells themselves. */
|
|
10
11
|
const cellBlanks = (doc: ProseDocument, lexicon: Lexicon): Finding[] =>
|
|
@@ -19,6 +20,24 @@ const cellBlanks = (doc: ProseDocument, lexicon: Lexicon): Finding[] =>
|
|
|
19
20
|
})),
|
|
20
21
|
);
|
|
21
22
|
|
|
23
|
+
/**
|
|
24
|
+
* A bracket that is not a forgotten blank, read from the line around it: the caption of a form's fill line, a blank inside
|
|
25
|
+
* a quoted example, or a field label the document fills in elsewhere.
|
|
26
|
+
*/
|
|
27
|
+
const isNamedOrExample = (doc: ProseDocument, lexicon: Lexicon): ((finding: Finding) => boolean) => {
|
|
28
|
+
const leads = lexicon.filter((word) => word.group === EXAMPLE_LEAD);
|
|
29
|
+
const fields = filledFieldLabels(
|
|
30
|
+
doc.source,
|
|
31
|
+
lexicon.filter((word) => word.group === BLANK_SUFFIX),
|
|
32
|
+
);
|
|
33
|
+
return (finding) => {
|
|
34
|
+
const matched = String(finding.values["matched"]);
|
|
35
|
+
const start = Number(finding.values["offset"]);
|
|
36
|
+
const line = lineAround(doc.source, start, start + matched.length);
|
|
37
|
+
return fields.has(matched) || captionsFillLine(line) || insideQuotedExample(line, leads);
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
22
41
|
/**
|
|
23
42
|
* A blank under a heading that names a template (Template, 雛形) is what the template is for, so it is not reported.
|
|
24
43
|
* Words that hold in some genres only (〇〇様 in a letter) count in those genres.
|
|
@@ -27,7 +46,9 @@ export const unfilledPlaceholderOutsideTemplates: Detector = (doc, options) => {
|
|
|
27
46
|
const lexicon = entriesForGenre(options.lexicon ?? [], options.genre);
|
|
28
47
|
const words = lexicon.filter((word) => word.group === TEMPLATE);
|
|
29
48
|
const templates = templateSections(doc.markup?.headings ?? [], doc.source.length, words);
|
|
49
|
+
const named = isNamedOrExample(doc, lexicon);
|
|
30
50
|
return [...unfilledPlaceholder(doc, { ...options, lexicon }), ...cellBlanks(doc, lexicon)]
|
|
31
51
|
.filter((finding) => !isInside(templates, Number(finding.values["offset"])))
|
|
52
|
+
.filter((finding) => !named(finding))
|
|
32
53
|
.toSorted((left, right) => Number(left.values["offset"]) - Number(right.values["offset"]));
|
|
33
54
|
};
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
// a word inside a longer one ("timely" in "in a timely manner") is that longer word, and a word inside a term of art of the
|
|
3
3
|
// document's genre ("reasonably" in a contract, "adequately compensate" as the test for an injunction) is not vague
|
|
4
4
|
// there. The rule speaks once per sentence, about the document's density. Pure: the words come from the language's
|
|
5
|
-
// lexicons vague-word and vague-word-term-of-art, the genre from the options.
|
|
5
|
+
// lexicons vague-word and vague-word-term-of-art, the genre from the options. The lines of a table of contents are the
|
|
6
|
+
// sections' names, not the writer's sentences, and are not read.
|
|
6
7
|
import { entriesForGenre } from "../lexicon-genres.ts";
|
|
8
|
+
import { contentsLineNumbers } from "../structure/contents-lines.ts";
|
|
9
|
+
import { lineNumberAt, linesOf } from "../structure/lines.ts";
|
|
7
10
|
import { escapeRegExp } from "../orthography.ts";
|
|
8
|
-
import type { Detector, Finding, Lexicon, LexiconEntry, Sentence } from "../plugin.ts";
|
|
11
|
+
import type { Detector, Finding, Lexicon, LexiconEntry, ProseDocument, Sentence } from "../plugin.ts";
|
|
9
12
|
import { comparableText, comparableWords, entryRanges } from "./lexicon-match.ts";
|
|
10
13
|
import { rateOver } from "./lexicon.ts";
|
|
11
14
|
import { specifiedByBracket } from "./bracket-specified.ts";
|
|
@@ -64,10 +67,20 @@ export const vagueWordsIn = (sentence: Sentence, vague: Lexicon, termsOfArt: Lex
|
|
|
64
67
|
|
|
65
68
|
type SentenceHits = { readonly sentence: Sentence; readonly words: readonly string[] };
|
|
66
69
|
|
|
70
|
+
/** The sentences on a line of a table of contents (the items under a 目次 / Contents heading). */
|
|
71
|
+
const contentsSentences = (doc: ProseDocument): ReadonlySet<Sentence> => {
|
|
72
|
+
const lines = linesOf(doc.source);
|
|
73
|
+
const tocWords = (doc.lexicons["toc-heading"] ?? []).map((entry) => entry.pattern);
|
|
74
|
+
const numbers = contentsLineNumbers(lines, doc.markup?.headings ?? [], tocWords);
|
|
75
|
+
return new Set(doc.sentences.filter((sentence) => numbers.has(lineNumberAt(lines, sentence.span.start) ?? 0)));
|
|
76
|
+
};
|
|
77
|
+
|
|
67
78
|
export const vagueDensity: Detector = (doc, options): Finding[] => {
|
|
68
79
|
const termsOfArt = entriesForGenre(doc.lexicons[TERMS_OF_ART] ?? [], options.genre);
|
|
69
80
|
const nameMarkers = (doc.lexicons[NAME_MARKERS] ?? []).map((entry) => entry.pattern);
|
|
81
|
+
const contents = contentsSentences(doc);
|
|
70
82
|
const hits: SentenceHits[] = doc.sentences
|
|
83
|
+
.filter((sentence) => !contents.has(sentence))
|
|
71
84
|
.map((sentence) => ({ sentence, words: vagueWordsIn(sentence, options.lexicon ?? [], termsOfArt, nameMarkers) }))
|
|
72
85
|
.filter((hit) => hit.words.length > 0);
|
|
73
86
|
const count = hits.reduce((sum, hit) => sum + hit.words.length, 0);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
|
|
3
|
+
// Stanzas: blocks of lines between blank lines where every line opens with a capital, as a verse line does, in a document
|
|
4
|
+
// where several such blocks also run a sentence on across a line into a capital ("How public, like a frog / To tell…").
|
|
5
|
+
// Prose wrapped at a column goes on in lower case, and prose with one sentence a line ends each line with its sentence.
|
|
6
|
+
|
|
7
|
+
const VERSE_LINE = /^[\t ]*["'“‘(]?\p{Lu}/u;
|
|
8
|
+
const SENTENCE_CLOSE = /[.!?]["'”’)\]]*[\t ]*$/u;
|
|
9
|
+
/** The run-on stanzas a document needs before its capitalised blocks are read as verse: one may be a list of names. */
|
|
10
|
+
const MIN_RUN_ON_STANZAS = 3;
|
|
11
|
+
const MIN_LINES = 2;
|
|
12
|
+
|
|
13
|
+
type Block = { start: number; end: number; readonly lines: string[] };
|
|
14
|
+
|
|
15
|
+
/** The runs of lines between blank lines, each with its span in the source. */
|
|
16
|
+
const blocksOf = (source: string): Block[] => {
|
|
17
|
+
const blocks: Block[] = [];
|
|
18
|
+
const state = { offset: 0, open: false };
|
|
19
|
+
source.split("\n").forEach((line) => {
|
|
20
|
+
const start = state.offset;
|
|
21
|
+
state.offset += line.length + 1;
|
|
22
|
+
if (line.trim() === "") {
|
|
23
|
+
state.open = false;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const last = blocks.at(-1);
|
|
27
|
+
if (state.open && last !== undefined) {
|
|
28
|
+
last.end = start + line.length;
|
|
29
|
+
last.lines.push(line);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
blocks.push({ start, end: start + line.length, lines: [line] });
|
|
33
|
+
state.open = true;
|
|
34
|
+
});
|
|
35
|
+
return blocks;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const isCapitalised = (lines: readonly string[]): boolean => lines.every((line) => VERSE_LINE.test(line));
|
|
39
|
+
|
|
40
|
+
/** A line inside the block, past its first, that runs on into the next: a first line alone may be a caption ("Article 1 Purpose"). */
|
|
41
|
+
const runsOn = (lines: readonly string[]): boolean => lines.slice(1, -1).some((line) => !SENTENCE_CLOSE.test(line));
|
|
42
|
+
|
|
43
|
+
/** The spans of the source's stanzas, sorted by start and never overlapping; none when the document is not verse. */
|
|
44
|
+
export const verseBlockSpans = (source: string): Span[] => {
|
|
45
|
+
const blocks = blocksOf(source).filter(({ lines }) => lines.length >= MIN_LINES && isCapitalised(lines));
|
|
46
|
+
const runOn = blocks.filter(({ lines }) => runsOn(lines)).length;
|
|
47
|
+
return runOn >= MIN_RUN_ON_STANZAS ? blocks.map(({ start, end }) => ({ start, end })) : [];
|
|
48
|
+
};
|
package/src/document.ts
CHANGED
|
@@ -370,6 +370,7 @@ const documentOf = (path: string, source: string, adapter: LanguageAdapter, team
|
|
|
370
370
|
namedDocument: adapter.structure?.namedDocument,
|
|
371
371
|
dictionary: adapter.dictionary,
|
|
372
372
|
replyQuotes: emailLayout.replyQuotes,
|
|
373
|
+
sentMessage: emailLayout.sent,
|
|
373
374
|
get markup(): Markup {
|
|
374
375
|
return documentMarkup(root, source, markdown, [...emailLayout.replyQuotes, ...syntax]);
|
|
375
376
|
},
|
package/src/email-parts.ts
CHANGED
|
@@ -25,6 +25,8 @@ export type EmailParts = {
|
|
|
25
25
|
readonly furniture: readonly Span[];
|
|
26
26
|
/** An attribution line and the quoted lines after it: someone else's words, so not this document's headings or structure. */
|
|
27
27
|
readonly replyQuotes: readonly Span[];
|
|
28
|
+
/** A header names a field the writer does not type (From, Date): a message as sent or kept, not a draft. */
|
|
29
|
+
readonly sent: boolean;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
const lowerCased = (lexicon: Lexicon | undefined): ReadonlySet<string> => new Set((lexicon ?? []).map((entry) => entry.pattern.toLowerCase()));
|
|
@@ -142,12 +144,17 @@ const fieldMask = (field: readonly Line[], vocabulary: EmailVocabulary): Span |
|
|
|
142
144
|
return { start: first.start, end: first.start + label[0].length };
|
|
143
145
|
};
|
|
144
146
|
|
|
145
|
-
const
|
|
146
|
-
blocksOf(lines).
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
const headerBlocks = (lines: readonly Line[], vocabulary: EmailVocabulary): Line[][] =>
|
|
148
|
+
blocksOf(lines).filter((block) => block[0] !== undefined && isHeader(block, opensMessage(lines, block[0]), vocabulary));
|
|
149
|
+
|
|
150
|
+
const headerSpans = (headers: readonly Line[][], vocabulary: EmailVocabulary): Span[] =>
|
|
151
|
+
headers.flatMap((block) => fieldsOf(block).flatMap((field) => fieldMask(field, vocabulary) ?? []));
|
|
152
|
+
|
|
153
|
+
/** A header line the writer does not type: a known field outside the written ones (From, Date), or the envelope line. */
|
|
154
|
+
const isSentField = (line: Line, vocabulary: EmailVocabulary): boolean => {
|
|
155
|
+
const name = FIELD.exec(line.text)?.[1]?.toLowerCase();
|
|
156
|
+
return name === undefined ? ENVELOPE.test(line.text) : vocabulary.headerFields.has(name) && !vocabulary.writtenFields.has(name);
|
|
157
|
+
};
|
|
151
158
|
|
|
152
159
|
const isUrlField = (line: Line | undefined): boolean => {
|
|
153
160
|
const label = line === undefined ? null : FIELD.exec(line.text);
|
|
@@ -256,14 +263,16 @@ export const emailParts = (source: string, vocabulary: EmailVocabulary): EmailPa
|
|
|
256
263
|
const lines = linesOf(source);
|
|
257
264
|
const replies = repliesOf(lines, vocabulary);
|
|
258
265
|
const separators = lines.filter((line) => isSeparator(line)).map((line) => spanOfLines(line, line));
|
|
266
|
+
const headers = headerBlocks(lines, vocabulary);
|
|
259
267
|
return {
|
|
260
268
|
furniture: [
|
|
261
|
-
...headerSpans(
|
|
269
|
+
...headerSpans(headers, vocabulary),
|
|
262
270
|
...attachmentStubSpans(lines, vocabulary),
|
|
263
271
|
...separators,
|
|
264
272
|
...signatureSpans(lines),
|
|
265
273
|
...replies.map((reply) => reply.attribution),
|
|
266
274
|
].toSorted(bySpanStart),
|
|
267
275
|
replyQuotes: replies.map((reply) => reply.quote),
|
|
276
|
+
sent: headers.some((block) => block.some((line) => isSentField(line, vocabulary))),
|
|
268
277
|
};
|
|
269
278
|
};
|
package/src/eval.ts
CHANGED
|
@@ -77,6 +77,8 @@ const meets = (need: string, docs: readonly ProseDocument[]): boolean => {
|
|
|
77
77
|
if (need === "headings") return docs.some((doc) => bodySectionOf(doc.sections) !== undefined);
|
|
78
78
|
// 記法を読む rule は Markdown の文書でしか動かない。
|
|
79
79
|
if (need === "markdown") return docs.some((doc) => doc.markup?.markdown === true);
|
|
80
|
+
// 下書きでは lint が動かない。送ったメールが 1 つも無ければ、どの閾値でも 0 件になる。
|
|
81
|
+
if (need === "sent-message") return docs.some((doc) => doc.sentMessage === true);
|
|
80
82
|
return false;
|
|
81
83
|
};
|
|
82
84
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** YAML の 1 行の値。行末のコメントと、値を囲む引用符を外す。 */
|
|
2
|
+
const scalarOf = (raw: string): string => {
|
|
3
|
+
const comment = raw.search(/\s#/u);
|
|
4
|
+
const value = (comment === -1 ? raw : raw.slice(0, comment)).trim();
|
|
5
|
+
return /^(["'])(.*)\1$/u.exec(value)?.[2] ?? value;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const valuesOf = (block: string, key: string): string[] => [...block.matchAll(new RegExp(`^${key}:(.*)$`, "gmu"))].map((line) => scalarOf(line[1] ?? ""));
|
|
9
|
+
|
|
10
|
+
/** front matter の 1 つの欄に書かれた値。front matter が無ければ空。 */
|
|
11
|
+
export const frontMatterValues = (source: string, key: string): string[] => {
|
|
12
|
+
const block = /^---\n([\s\S]*?)\n---/u.exec(source)?.[1];
|
|
13
|
+
return block === undefined ? [] : valuesOf(block, key);
|
|
14
|
+
};
|
package/src/genre-check.ts
CHANGED
package/src/genre.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { frontMatterValues } from "./front-matter.ts";
|
|
1
2
|
import { loadGenres } from "./genre-load.ts";
|
|
2
3
|
|
|
3
4
|
/** chaff が知っているジャンル。genres.yaml の並び。rule の use_for はこの頭の部分で当てる。 */
|
|
@@ -40,21 +41,6 @@ export const guessGenre = (path: string, source: string, front: string | undefin
|
|
|
40
41
|
return undefined;
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
/** YAML の 1 行の値。行末のコメントと、値を囲む引用符を外す。 */
|
|
44
|
-
const scalarOf = (raw: string): string => {
|
|
45
|
-
const comment = raw.search(/\s#/u);
|
|
46
|
-
const value = (comment === -1 ? raw : raw.slice(0, comment)).trim();
|
|
47
|
-
return /^(["'])(.*)\1$/u.exec(value)?.[2] ?? value;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const valuesOf = (block: string, key: string): string[] => [...block.matchAll(new RegExp(`^${key}:(.*)$`, "gmu"))].map((line) => scalarOf(line[1] ?? ""));
|
|
51
|
-
|
|
52
|
-
/** front matter の 1 つの欄に書かれた値。front matter が無ければ空。 */
|
|
53
|
-
export const frontMatterValues = (source: string, key: string): string[] => {
|
|
54
|
-
const block = /^---\n([\s\S]*?)\n---/u.exec(source)?.[1];
|
|
55
|
-
return block === undefined ? [] : valuesOf(block, key);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
44
|
/**
|
|
59
45
|
* front matter の genre / type を拾う。失敗しても落とさない。genre が type より先。
|
|
60
46
|
* 知っているジャンルだけを返す。Zenn の type(tech / idea)のような別の意味の値をジャンルにすると、どの rule も当てはまらず「指摘なし」になる。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { escapeRegExp } from "./orthography.ts";
|
|
2
|
+
import type { Paragraph, Sentence } from "./plugin.ts";
|
|
3
|
+
|
|
4
|
+
// A paragraph opened by a note's label ((注1)…をもって算定。 / ※ …を計上。) is a note to a table or a figure, written in the
|
|
5
|
+
// clipped style of notes, not body text. Pure.
|
|
6
|
+
|
|
7
|
+
/** The paragraph-head pattern: a label word with an optional number, bracketed or closed by a bracket, a colon or a space; or a mark. */
|
|
8
|
+
const labelPattern = (words: readonly string[], marks: readonly string[]): RegExp | undefined => {
|
|
9
|
+
const alternatives = [
|
|
10
|
+
...(words.length === 0
|
|
11
|
+
? []
|
|
12
|
+
: [`[((](?:${words.map(escapeRegExp).join("|")})[\\d0-9]{0,3}[))]`, `(?:${words.map(escapeRegExp).join("|")})[\\d0-9]{0,3}[))::\\u3000 ]`]),
|
|
13
|
+
...marks.map(escapeRegExp),
|
|
14
|
+
];
|
|
15
|
+
return alternatives.length === 0 ? undefined : new RegExp(`^[ \\t\\u3000]*(?:${alternatives.join("|")})`, "u");
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** The sentences of the paragraphs that open with a note's label. words are label words (注), marks are note marks (※). */
|
|
19
|
+
export const labelledNoteSentences = (
|
|
20
|
+
source: string,
|
|
21
|
+
paragraphs: readonly Paragraph[],
|
|
22
|
+
words: readonly string[],
|
|
23
|
+
marks: readonly string[],
|
|
24
|
+
): ReadonlySet<Sentence> => {
|
|
25
|
+
const pattern = labelPattern(words, marks);
|
|
26
|
+
if (pattern === undefined) return new Set();
|
|
27
|
+
return new Set(
|
|
28
|
+
paragraphs.filter((paragraph) => pattern.test(source.slice(paragraph.span.start, paragraph.span.end))).flatMap((paragraph) => paragraph.sentences),
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BulletList, Sentence } from "./plugin.ts";
|
|
2
|
+
|
|
3
|
+
/** Between a lead-in and its list: only blank space. A thematic break (`***`) separates them; bold marks sit inside the sentence. */
|
|
4
|
+
const ONLY_BLANKS = /^\s*$/u;
|
|
5
|
+
|
|
6
|
+
/** How many sentences end at or before an offset. Sentences are in document order, so a binary search. */
|
|
7
|
+
const countEndingBy = (sentences: readonly Sentence[], offset: number): number => {
|
|
8
|
+
const search = (low: number, high: number): number => {
|
|
9
|
+
if (low >= high) return low;
|
|
10
|
+
const middle = Math.floor((low + high) / 2);
|
|
11
|
+
return (sentences[middle]?.span.end ?? Infinity) <= offset ? search(middle + 1, high) : search(low, middle);
|
|
12
|
+
};
|
|
13
|
+
return search(0, sentences.length);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** The sentence that ends last before the list starts, if nothing but blanks lies between them. */
|
|
17
|
+
export const sentenceRightBefore = (sentences: readonly Sentence[], list: BulletList, source: string): Sentence | undefined => {
|
|
18
|
+
const before = sentences[countEndingBy(sentences, list.span.start) - 1];
|
|
19
|
+
return before !== undefined && ONLY_BLANKS.test(source.slice(before.span.end, list.span.start)) ? before : undefined;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** The sentences that hand the reader straight to a list (以下のとおり説明。 / 主な内容は以下の通り。), one per list at most. Pure. */
|
|
23
|
+
export const listLeadSentences = (sentences: readonly Sentence[], lists: readonly BulletList[], source: string): ReadonlySet<Sentence> =>
|
|
24
|
+
new Set(lists.flatMap((list) => sentenceRightBefore(sentences, list, source) ?? []));
|
package/src/paragraph-runs.ts
CHANGED
|
@@ -111,10 +111,33 @@ const isParallel = (source: string, run: readonly Paragraph[]): boolean => {
|
|
|
111
111
|
return run.length > 1 && first !== undefined && first.split(" ").length === PARALLEL_WORDS && openings.every((opening) => opening === first);
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
+
/** How many opening words a key term set in bold may sit within (For **jury duty**, use …). */
|
|
115
|
+
const KEY_TERM_WORDS = 6;
|
|
116
|
+
|
|
117
|
+
/** A phrase set in bold, of a few words: **jury duty**, __vote__. */
|
|
118
|
+
const BOLD_PHRASE = /(\*\*|__)(?=\S)[^*_\n]{1,60}?\S\1/u;
|
|
119
|
+
|
|
120
|
+
const wordCount = (text: string): number => text.split(/\s+/u).filter((word) => word !== "").length;
|
|
121
|
+
|
|
122
|
+
/** Whether a paragraph opens with a key term in bold, among its first words: an entry keyed by its subject. */
|
|
123
|
+
const opensWithBoldKey = (source: string, paragraph: Paragraph): boolean => {
|
|
124
|
+
const text = source.slice(paragraph.span.start, paragraph.span.end).trim();
|
|
125
|
+
const match = BOLD_PHRASE.exec(text);
|
|
126
|
+
return match !== null && wordCount(text.slice(0, match.index)) < KEY_TERM_WORDS;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Whether most paragraphs of a run open with a key term in bold (For **religious observances**, …; For **jury duty**, …): one
|
|
131
|
+
* entry per case, a list in all but markup.
|
|
132
|
+
*/
|
|
133
|
+
const isKeyedByBold = (source: string, run: readonly Paragraph[]): boolean =>
|
|
134
|
+
run.filter((paragraph) => opensWithBoldKey(source, paragraph)).length * 2 > run.length;
|
|
135
|
+
|
|
114
136
|
/**
|
|
115
137
|
* Each run of adjacent one-sentence paragraphs, in document order, as the paragraphs it holds. A paragraph of two sentences or
|
|
116
138
|
* more, a paragraph that does not end as a sentence, opens with an item mark or an enumerator, follows a lead-in as its item or
|
|
117
|
-
* is a reference list's entry, or anything between two paragraphs, ends the run. A run of parallel entries
|
|
139
|
+
* is a reference list's entry, or anything between two paragraphs, ends the run. A run of parallel entries, or of entries keyed
|
|
140
|
+
* by a term in bold, is a list, not a run.
|
|
118
141
|
*/
|
|
119
142
|
export const oneSentenceRuns = (source: string, paragraphs: readonly Paragraph[], referenceLists: readonly Span[] = []): Paragraph[][] => {
|
|
120
143
|
const leadInItems = underLeadIn(source, paragraphs);
|
|
@@ -128,5 +151,5 @@ export const oneSentenceRuns = (source: string, paragraphs: readonly Paragraph[]
|
|
|
128
151
|
else runs.push([paragraph]);
|
|
129
152
|
return runs;
|
|
130
153
|
}, [])
|
|
131
|
-
.filter((run) => !isParallel(source, run));
|
|
154
|
+
.filter((run) => !isParallel(source, run) && !isKeyedByBold(source, run));
|
|
132
155
|
};
|
package/src/plugin.ts
CHANGED
|
@@ -381,6 +381,8 @@ export type ProseDocument = {
|
|
|
381
381
|
readonly namedDocument?: DocumentNamer | undefined;
|
|
382
382
|
/** メールの引用した返信(前置きの行と「> 」の行)。ほかの人の言葉なので、見出しにも木にも入れない。 */
|
|
383
383
|
readonly replyQuotes?: readonly Span[] | undefined;
|
|
384
|
+
/** ヘッダーに書き手の打たない項目(From・Date)がある。送った・届いたメールで、下書きではない。下書きの添付は送るときに付くので本文から見えない。 */
|
|
385
|
+
readonly sentMessage?: boolean | undefined;
|
|
384
386
|
/** 記法の手がかり(見出し・画像・リンク)。記法を読む rule だけが触れ、触れたときに作る。 */
|
|
385
387
|
readonly markup?: Markup | undefined;
|
|
386
388
|
/** adapter の綴りの辞書。持たない言語では無い。 */
|
package/src/reasons.ts
CHANGED
|
@@ -20,6 +20,8 @@ export type Reasons = {
|
|
|
20
20
|
readonly noHeadings: string;
|
|
21
21
|
readonly patternTimeout: (budgetMs: number) => string;
|
|
22
22
|
readonly notMarkdown: string;
|
|
23
|
+
/** A rule that reads what a message carries, on a draft: its attachments are added when sending. */
|
|
24
|
+
readonly draftMessage: string;
|
|
23
25
|
/** A rule that compares documents, in a run of one: it runs when chaff is given two or more files, or a folder. */
|
|
24
26
|
readonly oneDocument: string;
|
|
25
27
|
};
|
|
@@ -57,6 +59,7 @@ export const REASONS: Texts<Reasons> = {
|
|
|
57
59
|
noHeadings: "表題より下の見出しが無いため",
|
|
58
60
|
patternTimeout: (budgetMs) => `正規表現が ${String(budgetMs)} ms で終わらなかったため(chaff.yaml の pattern を単純にしてください)`,
|
|
59
61
|
notMarkdown: "Markdown の文書ではないため",
|
|
62
|
+
draftMessage: "送る前の下書き(差出人や日時のヘッダーが無い)で、添付は送るときに付けるため本文からは見えないため",
|
|
60
63
|
oneDocument: "比べるほかの文書が無いため(ファイルを二つ以上かフォルダを渡すと動きます)",
|
|
61
64
|
},
|
|
62
65
|
en: {
|
|
@@ -80,6 +83,7 @@ export const REASONS: Texts<Reasons> = {
|
|
|
80
83
|
noHeadings: "the document has no headings below its title",
|
|
81
84
|
patternTimeout: (budgetMs) => `the pattern did not finish within ${String(budgetMs)} ms (simplify the pattern in chaff.yaml)`,
|
|
82
85
|
notMarkdown: "the document is not Markdown",
|
|
86
|
+
draftMessage: "the text is a draft (no From: or Date: header), and a draft's files are attached when sending, out of the text's sight",
|
|
83
87
|
oneDocument: "it compares documents, and there is only one to compare (it runs when chaff is given two or more files, or a folder)",
|
|
84
88
|
},
|
|
85
89
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Section, Sentence } from "./plugin.ts";
|
|
2
|
+
|
|
3
|
+
// A heading that ends with a running time in brackets ((3分00秒), (12:30)) is the title of a video or a recording the page
|
|
4
|
+
// shows, and the text under it is that recording's own caption. Neither is the writer's to shorten or to bring into the
|
|
5
|
+
// page's register. Pure.
|
|
6
|
+
|
|
7
|
+
/** Minutes and seconds in brackets ((3分00秒), (45秒)). */
|
|
8
|
+
const MINUTES_END = /[((]\s*[0-90-9]+(?:分(?:[0-90-9]+秒)?|秒)\s*[))]$/u;
|
|
9
|
+
/** A clock time in brackets ((12:30), (1:02:15)). */
|
|
10
|
+
const CLOCK_END = /[((]\s*\d{1,2}(?::\d{2}){1,2}\s*[))]$/u;
|
|
11
|
+
|
|
12
|
+
export const isRecordingTitle = (heading: string): boolean => MINUTES_END.test(heading.trim()) || CLOCK_END.test(heading.trim());
|
|
13
|
+
|
|
14
|
+
/** The sentences of every section a recording's title heads: its caption, in the recording's words. */
|
|
15
|
+
export const recordingCaptionSentences = (sections: readonly Section[]): Set<Sentence> =>
|
|
16
|
+
new Set(sections.filter((section) => isRecordingTitle(section.unlabeledHeading ?? section.heading)).flatMap((section) => section.sentences));
|
package/src/rule-of-three.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { BulletList } from "./plugin.ts";
|
|
|
6
6
|
* 箇条書きが少ないと、1 つで割合が大きく動く(4 つなら 25 ポイント)。そのときは全部が 3 項目のときだけ報告する。
|
|
7
7
|
* 2 つでも測る。生成文の報告書は「要因 3 つ」「提言 3 つ」の 2 つの箇条書きで終わることが多く、人の文書で 2 つとも 3 項目は少ない。
|
|
8
8
|
* 本文の最初の文より前の箇条書き(題・日付・見出しのすぐ下の要点や概要)は数えない。項目の数はサイトの型が決めている。
|
|
9
|
-
*
|
|
9
|
+
* どの項目も「札:数」の内訳も、どの項目も 3 文以上ある箇条書きも、ちょうど 3 項目とは数えない。
|
|
10
10
|
*/
|
|
11
11
|
export type ThreeShare = { readonly count: number; readonly total: number; readonly share: number; readonly first: BulletList };
|
|
12
12
|
|
|
@@ -74,14 +74,31 @@ const isLabelledFigure = (item: string): boolean => {
|
|
|
74
74
|
export const isFigureBreakdown = (source: string, list: BulletList): boolean =>
|
|
75
75
|
list.itemSpans.length > 0 && list.itemSpans.every((item) => isLabelledFigure(source.slice(item.start, item.end)));
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
/** 段落として書いた項目の文の数の下限。太字の見出しの文と、それを説く 2 文。 */
|
|
78
|
+
const MIN_ITEM_SENTENCES = 3;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* どの項目も 3 文以上ある箇条書き(太字の助言と、それを説く数文)。項目ごとに段落を書いた心得の一覧で、数は中身が決めている。
|
|
82
|
+
* 数を合わせるために足した項目は、1 文か 2 文の薄いものになる。
|
|
83
|
+
*/
|
|
84
|
+
export const isParagraphItems = (list: BulletList, sentenceStarts: readonly number[]): boolean =>
|
|
85
|
+
list.itemSpans.length > 0 &&
|
|
86
|
+
list.itemSpans.every((item) => sentenceStarts.filter((start) => start >= item.start && start < item.end).length >= MIN_ITEM_SENTENCES);
|
|
87
|
+
|
|
88
|
+
const isExactlyThree = (source: string, list: BulletList, openWords: readonly string[], sentenceStarts: readonly number[]): boolean =>
|
|
89
|
+
list.items.length === THREE && !continuesBeyond(source, list, openWords) && !isFigureBreakdown(source, list) && !isParagraphItems(list, sentenceStarts);
|
|
79
90
|
|
|
80
91
|
/** 報告するときの数。報告しないときは undefined。 */
|
|
81
|
-
export const threeShare = (
|
|
92
|
+
export const threeShare = (
|
|
93
|
+
source: string,
|
|
94
|
+
allLists: readonly BulletList[],
|
|
95
|
+
openWords: readonly string[],
|
|
96
|
+
limit: number,
|
|
97
|
+
sentenceStarts: readonly number[] = [],
|
|
98
|
+
): ThreeShare | undefined => {
|
|
82
99
|
const bodyStart = firstProseOffset(source);
|
|
83
100
|
const lists = allLists.filter((list) => list.span.start >= bodyStart);
|
|
84
|
-
const threes = lists.filter((list) => isExactlyThree(source, list, openWords));
|
|
101
|
+
const threes = lists.filter((list) => isExactlyThree(source, list, openWords, sentenceStarts));
|
|
85
102
|
const first = threes[0];
|
|
86
103
|
if (lists.length < MIN_LISTS || first === undefined) return undefined;
|
|
87
104
|
const share = Math.round((threes.length / lists.length) * PERCENT);
|
package/src/run.ts
CHANGED
|
@@ -103,11 +103,13 @@ const unreadOf = (doc: ProseDocument): Unread | undefined => {
|
|
|
103
103
|
/** 見出しを読む rule の要求。表題より下の見出しが無い文書では、本題の前を測れない。0 件を「前置きが短い」に見せない。 */
|
|
104
104
|
/** 記法を読む rule の要求(markdown)。.txt には見出しの記法も画像もリンクの記法も無いので、0 件を「問題なし」に見せない。 */
|
|
105
105
|
/** documents: a rule that compares the documents of one run (cross-run.ts). Run on one document, it says so instead of finding nothing. */
|
|
106
|
-
|
|
106
|
+
/** sent-message: a rule that reads what a message carries (its attachments). A draft's are added when sending, out of the text's sight. */
|
|
107
|
+
const DOCUMENT_NEEDS: ReadonlySet<string> = new Set(["headings", "markdown", "documents", "sent-message"]);
|
|
107
108
|
|
|
108
109
|
const documentNeed = (rule: RuleDefinition, doc: ProseDocument): string | undefined => {
|
|
109
110
|
if (rule.requires.includes("markdown") && !isMarkdownPath(doc.path)) return reasonsFor(doc).notMarkdown;
|
|
110
111
|
if (rule.requires.includes("headings") && bodySectionOf(doc.sections) === undefined) return reasonsFor(doc).noHeadings;
|
|
112
|
+
if (rule.requires.includes("sent-message") && doc.sentMessage !== true) return reasonsFor(doc).draftMessage;
|
|
111
113
|
if (!rule.requires.includes("documents")) return undefined;
|
|
112
114
|
// Set aside only what the cross pass can run: a missing word list is said here, as for any rule.
|
|
113
115
|
const absent = missingList(rule, doc.lexicons);
|