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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { lengthOf, proseText } from "../measure.ts";
|
|
2
|
+
import { cleftFocus } from "./cleft-focus.ts";
|
|
2
3
|
import { newContentMorphemes } from "./content-morphemes.ts";
|
|
3
4
|
import { echoedHeadingUnits, trigrams } from "./heading-overlap.ts";
|
|
4
5
|
import { fieldValueStart } from "./field-label.ts";
|
|
@@ -9,7 +10,7 @@ import { handsOver } from "./lead-in.ts";
|
|
|
9
10
|
import { holdsLink, namesLocation } from "./location-pointer.ts";
|
|
10
11
|
import { withoutQuotedVariants } from "./quoted-variant.ts";
|
|
11
12
|
import { namesHeadingSubject } from "./subject-name-line.ts";
|
|
12
|
-
import type { Detector, Finding, LengthUnit, ProseDocument, Section, Sentence } from "../plugin.ts";
|
|
13
|
+
import type { Detector, Finding, LengthUnit, ProseDocument, Section, Sentence, Token } from "../plugin.ts";
|
|
13
14
|
|
|
14
15
|
/** 見出しが短すぎると、偶然の一致で 100% になる。これ未満の見出しは見ない。 */
|
|
15
16
|
const MIN_GRAMS = 4;
|
|
@@ -46,11 +47,23 @@ const NEW_CONTENT_MORPHEMES = 1;
|
|
|
46
47
|
/** 重なりを測る見出し。頭の番号の札(例 3:、Step 3:、1.)は本文で繰り返されないので、数えると短い見出しほど重なりが下がる。 */
|
|
47
48
|
const measuredHeading = (section: Section): string => section.unlabeledHeading ?? section.heading;
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
/**
|
|
51
|
+
* 内容を測る文の語。分裂文(いちばん大きく変わったのは、季節の移り変わりに気づくようになったことだ。)は焦点の語だけ:
|
|
52
|
+
* 主題の節は焦点を差し出すだけで、焦点が見出しを言い直していれば、文は見出しを繰り返している。
|
|
53
|
+
*/
|
|
54
|
+
const statedTokens = (doc: ProseDocument, sentence: Sentence): readonly Token[] | undefined => {
|
|
55
|
+
const focus = cleftFocus(sentence.text, doc.lexicons["cleft-frame"] ?? []);
|
|
56
|
+
if (sentence.tokens === undefined || focus === undefined) return sentence.tokens;
|
|
57
|
+
const [start, end] = [sentence.span.start + focus.start, sentence.span.start + focus.end];
|
|
58
|
+
return sentence.tokens.filter((token) => token.span.start >= start && token.span.end <= end);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const addsLittle = (doc: ProseDocument, section: Section, unit: LengthUnit): boolean => {
|
|
50
62
|
const first = section.firstSentence;
|
|
51
63
|
if (first === undefined) return false;
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
const stated = statedTokens(doc, first);
|
|
65
|
+
if (unit === "char" && stated !== undefined && section.headingTokens !== undefined)
|
|
66
|
+
return newContentMorphemes(titleTokens(section.heading, measuredHeading(section), section.headingTokens), stated) <= NEW_CONTENT_MORPHEMES;
|
|
54
67
|
return lengthOf(first, unit) - echoedHeadingUnits(measuredHeading(section), proseText(first), unit) <= NEW_MATERIAL[unit];
|
|
55
68
|
};
|
|
56
69
|
|
|
@@ -74,10 +87,10 @@ const pointsElsewhere = (doc: ProseDocument, section: Section): boolean => {
|
|
|
74
87
|
* 予告や指示の語(covers, below, 説明, 以下)だけを述語にする文は、見出しを言い直しているだけで繰り返し。
|
|
75
88
|
*/
|
|
76
89
|
const statesClaim = (doc: ProseDocument, section: Section): boolean => {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
90
|
+
const stated = section.firstSentence === undefined ? undefined : statedTokens(doc, section.firstSentence);
|
|
91
|
+
if (stated === undefined || section.headingTokens === undefined) return false;
|
|
79
92
|
const heading = titleTokens(section.heading, measuredHeading(section), section.headingTokens);
|
|
80
|
-
return makesClaim(heading,
|
|
93
|
+
return makesClaim(heading, stated, announcerWords(doc.lexicons["heading-announcer"] ?? []));
|
|
81
94
|
};
|
|
82
95
|
|
|
83
96
|
/** A figure, with its thousands separators (1,320,000), compared without them. */
|
|
@@ -138,7 +151,7 @@ const echoedText = (section: Section): string =>
|
|
|
138
151
|
export const headingEcho: Detector = (doc, options): Finding[] => {
|
|
139
152
|
const leadIns = (doc.lexicons["lead-in"] ?? []).map((entry) => entry.pattern);
|
|
140
153
|
return doc.sections
|
|
141
|
-
.filter((section) => section.heading.length > 0 && section.firstSentence !== undefined && addsLittle(section, doc.lengthUnit))
|
|
154
|
+
.filter((section) => section.heading.length > 0 && section.firstSentence !== undefined && addsLittle(doc, section, doc.lengthUnit))
|
|
142
155
|
.filter(
|
|
143
156
|
(section) =>
|
|
144
157
|
!leadsIn(doc, section, leadIns) &&
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A heading's number at its head: 3, 4.2, 4.2.1 (a full stop after it, as in "3.", is not part of it). */
|
|
2
|
+
const DOTTED_NUMBER = /^(\d{1,3}(?:\.\d{1,3})*)\.?(?!\d)/u;
|
|
3
|
+
/** The first item of a bracketed series under a numbered heading: (1), (1). */
|
|
4
|
+
const FIRST_BRACKETED = /^\(1\)/u;
|
|
5
|
+
|
|
6
|
+
const numberOf = (heading: string): string | undefined => DOTTED_NUMBER.exec(heading.normalize("NFKC").trim())?.[1];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Whether `child`, the next heading at the same depth, opens a subsection of `parent` by its number: 3. then 3.1, 4.2 then
|
|
10
|
+
* 4.2.1, or a numbered heading then its first bracketed item ((1)). Some documents number their subsections at the
|
|
11
|
+
* heading level of the section itself, so the depth alone does not show the split.
|
|
12
|
+
*/
|
|
13
|
+
export const opensSubsection = (parent: string, child: string): boolean => {
|
|
14
|
+
const parentNumber = numberOf(parent);
|
|
15
|
+
if (parentNumber === undefined) return false;
|
|
16
|
+
const normalizedChild = child.normalize("NFKC").trim();
|
|
17
|
+
if (FIRST_BRACKETED.test(normalizedChild)) return true;
|
|
18
|
+
const childNumber = numberOf(normalizedChild);
|
|
19
|
+
return childNumber !== undefined && childNumber.startsWith(`${parentNumber}.`) && !childNumber.slice(parentNumber.length + 1).includes(".");
|
|
20
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Detector, Finding, LexiconEntry } from "../plugin.ts";
|
|
2
2
|
import { findingAt, writtenHeadings } from "./markup-finding.ts";
|
|
3
|
+
import { isFrontOrBackMatter } from "../body-section.ts";
|
|
3
4
|
import {
|
|
4
5
|
numberingMinorities,
|
|
5
6
|
numberingStyleOf,
|
|
@@ -13,15 +14,6 @@ import {
|
|
|
13
14
|
const labelsOf = (entries: readonly LexiconEntry[]): NumberLabel[] =>
|
|
14
15
|
entries.map((entry) => ({ word: entry.pattern, position: entry.position === "after" ? "after" : "before" }));
|
|
15
16
|
|
|
16
|
-
/** 前後の見出しの語のあとに続いてよい区切りか番号(「付録: 用語」「Appendix A」「図1」)。 */
|
|
17
|
-
const AFTER_MATTER = /^[\s::、0-90-9]/u;
|
|
18
|
-
|
|
19
|
-
/** 番号を付けない前後の見出し(目次・参考文献・付録 A)か。言葉全体が語彙表の語か、語彙表の語に区切りが続くとき。 */
|
|
20
|
-
const isFrontOrBackMatter = (text: string, words: readonly string[]): boolean => {
|
|
21
|
-
const lowered = text.trim().toLowerCase();
|
|
22
|
-
return words.some((word) => lowered === word || (lowered.startsWith(word) && AFTER_MATTER.test(lowered.slice(word.length))));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
17
|
const variantOf = (minority: NumberingMinority): string => {
|
|
26
18
|
if (minority.kind === "style") return "style";
|
|
27
19
|
return minority.majority === UNNUMBERED ? "numbered" : "unnumbered";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// A spaced hyphen that joins one capitalised word onto a name ("the Islamic State of Iraq and Syria - Khorasan, as …"): the
|
|
2
|
+
// hyphen is part of the name, not a dash in the sentence. Pure.
|
|
3
|
+
|
|
4
|
+
/** A capitalised word: the one ending right before the hyphen's space. */
|
|
5
|
+
const CAPITALISED_WORD = /^\p{Lu}[\p{L}'’]*$/u;
|
|
6
|
+
const NOT_WORD = /[^\p{L}'’]/u;
|
|
7
|
+
/** Longer than any word, to look back over. */
|
|
8
|
+
const WORD_REACH = 40;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The hyphen, then one word in title case that ends the phrase: a comma, a stop, a bracket or the end of the line follows.
|
|
12
|
+
* A word all in capitals after it (I - JURISDICTION) is a heading's title set off by a dash.
|
|
13
|
+
*/
|
|
14
|
+
const SUFFIX_AFTER = /^ -{1,2} \p{Lu}\p{Ll}[\p{L}'’]*(?=[,.;:)\]]|$)/u;
|
|
15
|
+
|
|
16
|
+
const lineEnd = (text: string, offset: number): number => {
|
|
17
|
+
const end = text.indexOf("\n", offset);
|
|
18
|
+
return end === -1 ? text.length : end;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** `offset` is where the hit starts in `text`: the space before the hyphen. */
|
|
22
|
+
export const joinsNameSuffix = (text: string, offset: number): boolean =>
|
|
23
|
+
offset > 0 &&
|
|
24
|
+
CAPITALISED_WORD.test(
|
|
25
|
+
text
|
|
26
|
+
.slice(Math.max(0, offset - WORD_REACH), offset)
|
|
27
|
+
.split(NOT_WORD)
|
|
28
|
+
.at(-1) ?? "",
|
|
29
|
+
) &&
|
|
30
|
+
SUFFIX_AFTER.test(text.slice(offset, lineEnd(text, offset)));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Detector, Finding, ProseDocument, Sentence } from "../plugin.ts";
|
|
2
|
+
import { frontMatterValues } from "../front-matter.ts";
|
|
2
3
|
import { proseText } from "../measure.ts";
|
|
3
4
|
import { rateOver } from "./lexicon.ts";
|
|
4
5
|
|
|
@@ -33,14 +34,17 @@ export const mostFrequent = (words: readonly string[], count: number): string[]
|
|
|
33
34
|
.map(([word]) => word);
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
/** The document's titles: its first top-level heading, and the title its front matter gives (a site generator shows that one instead). */
|
|
38
|
+
const titlesOf = (doc: ProseDocument): string[] => [
|
|
39
|
+
doc.markup?.headings.find((heading) => heading.depth === 1)?.text ?? "",
|
|
40
|
+
...frontMatterValues(doc.source, "title"),
|
|
41
|
+
];
|
|
42
|
+
|
|
36
43
|
/**
|
|
37
44
|
* The katakana words of the document's title: what the document is about (e-Govアカウントの登録方法). A manual on accounts
|
|
38
45
|
* cannot say アカウント another way, so the subject is not a loanword to trim.
|
|
39
46
|
*/
|
|
40
|
-
export const subjectWords = (doc: ProseDocument): ReadonlySet<string> =>
|
|
41
|
-
const title = doc.markup?.headings.find((heading) => heading.depth === 1)?.text ?? "";
|
|
42
|
-
return new Set(katakanaWordsIn(title, doc.names ?? []));
|
|
43
|
-
};
|
|
47
|
+
export const subjectWords = (doc: ProseDocument): ReadonlySet<string> => new Set(titlesOf(doc).flatMap((title) => katakanaWordsIn(title, doc.names ?? [])));
|
|
44
48
|
|
|
45
49
|
const wordsOfDocument = (doc: ProseDocument): KatakanaWord[] => {
|
|
46
50
|
const subject = subjectWords(doc);
|
package/src/detectors/lexicon.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { joinWords } from "./word-list.ts";
|
|
2
|
+
import { FIGURE_NUMBER } from "../figure-references.ts";
|
|
3
|
+
import { escapeRegExp } from "../orthography.ts";
|
|
2
4
|
import { densestStretch } from "./densest-stretch.ts";
|
|
3
5
|
import { wordsOf } from "./structure.ts";
|
|
4
6
|
import type { Detector, Finding, Lexicon, LexiconEntry, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
|
|
@@ -11,7 +13,7 @@ import { restricted, type Restrictors } from "./superlative-clause.ts";
|
|
|
11
13
|
import { stackedHedges, type StackedHedge } from "./stacked-hedge.ts";
|
|
12
14
|
import { comparisonMarkersOf, counterpartBefore, onlyQuoted, quotedRange, type ComparisonMarkers } from "./superlative-comparison.ts";
|
|
13
15
|
import { inPhrase, ownedBefore } from "./superlative-phrase.ts";
|
|
14
|
-
import { asked, contextOf, picksFromNamedSet, pointsAtReferent, ranksParts, sought, viewpointBefore, type Context } from "./superlative-context.ts";
|
|
16
|
+
import { asked, contextOf, picksFromNamedSet, pointsAtReferent, ranksParts, sought, supposed, viewpointBefore, type Context } from "./superlative-context.ts";
|
|
15
17
|
|
|
16
18
|
const PER = 1000;
|
|
17
19
|
|
|
@@ -173,6 +175,7 @@ const everyQualified = (sentence: Sentence, entry: LexiconEntry, qualifiers: Qua
|
|
|
173
175
|
quotedRange(sentence, range) ||
|
|
174
176
|
inPhrase(tokens, range, qualifiers.phrases) ||
|
|
175
177
|
sought(sentence, range, qualifiers.context.goals) ||
|
|
178
|
+
supposed(sentence.tokens ?? [], range, qualifiers.context.conditions) ||
|
|
176
179
|
qualifiedAt(tokens, range, qualifiers),
|
|
177
180
|
)
|
|
178
181
|
);
|
|
@@ -216,14 +219,28 @@ const openerOf = (doc: ProseDocument, lexicon: Lexicon): (string | undefined)[]
|
|
|
216
219
|
return head === undefined ? undefined : lexicon.find((entry) => entryOpens(head, entry))?.pattern;
|
|
217
220
|
});
|
|
218
221
|
|
|
222
|
+
/** 句点の無い一行の段落で、図・表の名前(語彙表 figure-label)と番号で始まるもの(表2-2-1 …の概要)。本文の間に置いた図表の題。 */
|
|
223
|
+
const captionTest = (doc: ProseDocument): ((index: number) => boolean) => {
|
|
224
|
+
const labels = (doc.lexicons["figure-label"] ?? []).map((entry) => escapeRegExp(entry.pattern));
|
|
225
|
+
if (labels.length === 0) return () => false;
|
|
226
|
+
const caption = new RegExp(`^(?:${labels.join("|")})${FIGURE_NUMBER}[^\\n。..]*$`, "u");
|
|
227
|
+
return (index) => {
|
|
228
|
+
const paragraph = doc.paragraphs[index];
|
|
229
|
+
return paragraph !== undefined && caption.test(doc.source.slice(paragraph.span.start, paragraph.span.end).trim());
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
|
|
219
233
|
/**
|
|
220
234
|
* 段落が同じ接続詞で始まり続ける。1 つなら流れを作るが、続くとどの段落も
|
|
221
235
|
* 前の段落の付け足しに見えて、話がどこへ向かっているのか分からなくなる。
|
|
236
|
+
* 段落の間に置いた図表の題(表2-2-1 …)は本文の段落ではないので、並びを切らない。
|
|
222
237
|
*/
|
|
223
238
|
export const repeatedConjunction: Detector = (doc, options): Finding[] => {
|
|
224
239
|
const openers = openerOf(doc, options.lexicon ?? []);
|
|
240
|
+
const isCaption = captionTest(doc);
|
|
225
241
|
const runs = openers.reduce<{ runs: number[][]; current: number[] }>(
|
|
226
242
|
(acc, opener, index) => {
|
|
243
|
+
if (opener === undefined && isCaption(index)) return acc;
|
|
227
244
|
if (opener === undefined) return { runs: [...acc.runs, acc.current], current: [] };
|
|
228
245
|
return { runs: acc.runs, current: [...acc.current, index] };
|
|
229
246
|
},
|
|
@@ -30,17 +30,31 @@ const isFieldValue = (source: string, url: Span): boolean => {
|
|
|
30
30
|
return isFieldValueUrl(source.slice(lineStart, url.start), source.slice(url.end, lineEnd === -1 ? source.length : lineEnd));
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
/** A placeholder the reader replaces: `<user_name>` right after the URL (where the URL stops), or `{repo}` inside it. */
|
|
34
|
+
const PLACEHOLDER_AFTER = /^<[^\s<>]+>/u;
|
|
35
|
+
const PLACEHOLDER_INSIDE = /\{[^\s{}]+\}/u;
|
|
36
|
+
|
|
37
|
+
/** A URL template (`https://e.com/viewer/?uri=<platform>.com/<user>`): no worded link can stand for an address yet to be filled in. */
|
|
38
|
+
const isTemplate = (source: string, url: Span): boolean =>
|
|
39
|
+
PLACEHOLDER_AFTER.test(source.slice(url.end)) || PLACEHOLDER_INSIDE.test(source.slice(url.start, url.end));
|
|
40
|
+
|
|
33
41
|
/**
|
|
34
42
|
* The bare URLs the reader sees as text (outside links, code and quotations). A URL in a table cell is a value the table lists
|
|
35
43
|
* (an example request, a field's content), not a link the prose points to, so tables are left out, and so is a field's value
|
|
36
|
-
* on its own line (`**Licence text** https://…`).
|
|
44
|
+
* on its own line (`**Licence text** https://…`), and so is a template with placeholders to fill in.
|
|
37
45
|
*/
|
|
38
46
|
const bareUrlSpans = (source: string, markup: Markup): Span[] => {
|
|
39
47
|
const tables = spansOfType(readMarkdown(source).root, "table");
|
|
40
48
|
return markup.texts.flatMap((text) =>
|
|
41
49
|
bareUrls(source.slice(text.start, text.end))
|
|
42
50
|
.map((url) => ({ start: text.start + url.start, end: text.start + url.end }))
|
|
43
|
-
.filter(
|
|
51
|
+
.filter(
|
|
52
|
+
(url) =>
|
|
53
|
+
!source.startsWith(FAILED_DESTINATION, url.start - FAILED_DESTINATION.length) &&
|
|
54
|
+
!inside(url, tables) &&
|
|
55
|
+
!isFieldValue(source, url) &&
|
|
56
|
+
!isTemplate(source, url),
|
|
57
|
+
),
|
|
44
58
|
);
|
|
45
59
|
};
|
|
46
60
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// How an English list item reads as a phrase: a noun phrase may hold verbs of its own (Text that is at least 11pt, lists
|
|
2
|
+
// using the tools), and a full stop may close an aside rather than the item. Pure; reads the item's tokens.
|
|
3
|
+
import type { Token } from "../plugin.ts";
|
|
4
|
+
|
|
5
|
+
/** Parts of speech a noun phrase is made of; the Japanese reading of an item's ending uses them too. */
|
|
6
|
+
export const NOMINAL = new Set(["NOUN", "PROPN", "NUM", "PRON"]);
|
|
7
|
+
export const NOUN_HEAD = new Set(["NOUN", "ADJ", "DET", "NUM", "PRON", "PROPN"]);
|
|
8
|
+
export const SENTENCE_END = /[.!?。.!?]["'”’))」』]*$/u;
|
|
9
|
+
|
|
10
|
+
/** A finite verb or auxiliary: an English item with one says something. A gerund or participle (Running, nested) does not. */
|
|
11
|
+
export const isFiniteVerb = (token: Token): boolean =>
|
|
12
|
+
(token.pos === "VERB" || token.pos === "AUX") && !["Ger", "Part"].includes(token.features?.["VerbForm"] ?? "");
|
|
13
|
+
|
|
14
|
+
/** A determiner that opens an object (the, a, your): no noun phrase goes on from its head with one. */
|
|
15
|
+
export const opensObject = (token: Token | undefined): boolean => token?.features?.["PronType"] === "Art" || token?.features?.["Poss"] === "Yes";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* An -ed word the tagger left without VerbForm (decreased, agreed, unauthorized): like a participle, it may modify the noun
|
|
19
|
+
* after it. Proceed and need end in -ed too but are their own base forms.
|
|
20
|
+
*/
|
|
21
|
+
export const isPastForm = (token: Token): boolean =>
|
|
22
|
+
token.pos === "VERB" &&
|
|
23
|
+
token.features?.["VerbForm"] === undefined &&
|
|
24
|
+
/ed$/iu.test(token.surface) &&
|
|
25
|
+
(token.lemma !== token.surface.toLowerCase() || !/eed$/iu.test(token.surface));
|
|
26
|
+
|
|
27
|
+
/** A relative pronoun after a noun (text that is …, staff who work …): the verbs right after it belong to the noun phrase. */
|
|
28
|
+
const RELATIVE_PRONOUNS = new Set(["that", "which", "who", "whom", "whose"]);
|
|
29
|
+
|
|
30
|
+
const opensRelativeClause = (tokens: readonly Token[], at: number): boolean =>
|
|
31
|
+
RELATIVE_PRONOUNS.has(tokens[at]?.surface.toLowerCase() ?? "") && NOMINAL.has(tokens[at - 1]?.pos ?? "");
|
|
32
|
+
|
|
33
|
+
/** Words that hold a verb group together: verbs, auxiliaries, "not", adverbs and "to". */
|
|
34
|
+
const VERB_GROUP = new Set(["VERB", "AUX", "ADV", "PART"]);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The positions of a relative clause's own verb group: the verbs, with adverbs and "not", right after each relative
|
|
38
|
+
* pronoun (that is left justified, who are assessed). A verb after the group (Team members who are assessed … are
|
|
39
|
+
* eligible) is the item's own.
|
|
40
|
+
*/
|
|
41
|
+
const relativeVerbGroups = (tokens: readonly Token[]): ReadonlySet<number> => {
|
|
42
|
+
const positions = new Set<number>();
|
|
43
|
+
tokens.forEach((_token, at) => {
|
|
44
|
+
if (!opensRelativeClause(tokens, at)) return;
|
|
45
|
+
const end = tokens.findIndex((token, index) => index > at && !VERB_GROUP.has(token.pos));
|
|
46
|
+
Array.from({ length: (end === -1 ? tokens.length : end) - at - 1 }, (_unused, offset) => positions.add(at + 1 + offset));
|
|
47
|
+
});
|
|
48
|
+
return positions;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether an item opens as a noun phrase does: with a noun, an adjective or a determiner, or with an -ed word modifying
|
|
53
|
+
* what follows (Bulleted or numbered lists). An -ed word before "the" or "a" is a verb and its object (Fixed the link).
|
|
54
|
+
*/
|
|
55
|
+
const opensNounPhrase = (tokens: readonly Token[]): boolean => {
|
|
56
|
+
const [first, second] = [tokens[0], tokens[1]];
|
|
57
|
+
if (first === undefined) return false;
|
|
58
|
+
if (first.pos === "VERB") return (isPastForm(first) || first.features?.["VerbForm"] === "Part") && !opensObject(second);
|
|
59
|
+
return NOUN_HEAD.has(first.pos) && first.pos !== "PRON";
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* In an item that opens as a noun phrase, a verb that belongs to it: a participle or gerund (lists using the tools), an -ed
|
|
64
|
+
* form, one after "to" (a background to ensure contrast), or one in a relative clause's verb group (Text that is large).
|
|
65
|
+
*/
|
|
66
|
+
const isPhraseVerb = (tokens: readonly Token[], at: number, relative: ReadonlySet<number>): boolean => {
|
|
67
|
+
const token = tokens[at];
|
|
68
|
+
if (token === undefined) return false;
|
|
69
|
+
if (!isFiniteVerb(token) || isPastForm(token)) return true;
|
|
70
|
+
return tokens[at - 1]?.pos === "PART" || relative.has(at);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const isVerb = (token: Token): boolean => token.pos === "VERB" || token.pos === "AUX";
|
|
74
|
+
|
|
75
|
+
/** Whether an item opens as a noun phrase and holds only the verbs of that phrase (Text that is at least 11pt). */
|
|
76
|
+
export const isNounPhraseWithVerbs = (tokens: readonly Token[]): boolean => {
|
|
77
|
+
if (!opensNounPhrase(tokens)) return false;
|
|
78
|
+
const relative = relativeVerbGroups(tokens);
|
|
79
|
+
return tokens.every((token, at) => !isVerb(token) || isPhraseVerb(tokens, at, relative));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** A full stop inside a closing bracket (tools (e.g. Captivate, etc.)): the aside's own stop, not the item's. */
|
|
83
|
+
const ASIDE_STOP = /\.\)$/u;
|
|
84
|
+
|
|
85
|
+
/** Whether an English item ends as a sentence does: a closing mark, not one that ends an aside opened inside the item. */
|
|
86
|
+
export const closesAsSentence = (text: string): boolean => SENTENCE_END.test(text) && !(ASIDE_STOP.test(text) && !text.startsWith("("));
|
|
@@ -37,3 +37,20 @@ export const itemLayout = (source: string, spans: readonly Span[]): ItemLayout =
|
|
|
37
37
|
const heads = spans.filter((_, index) => headsRun(index));
|
|
38
38
|
return { groups: labels.length < MIN_GROUP_LABELS ? [spans] : labels.map(runAfter), heads };
|
|
39
39
|
};
|
|
40
|
+
|
|
41
|
+
/** An item that ends in a colon leads into the items after it. */
|
|
42
|
+
const ITEM_LEAD_IN = /[::]$/u;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The items split after each item that ends in a colon (Exceptions to this:): the items after it are its own, a nested
|
|
46
|
+
* list flattened into the outer one, and are compared among themselves.
|
|
47
|
+
*/
|
|
48
|
+
export const splitAtLeadIns = (source: string, spans: readonly Span[]): Span[][] =>
|
|
49
|
+
spans.reduce<Span[][]>(
|
|
50
|
+
(groups, span) => {
|
|
51
|
+
groups.at(-1)?.push(span);
|
|
52
|
+
if (ITEM_LEAD_IN.test(source.slice(span.start, span.end).trim())) groups.push([]);
|
|
53
|
+
return groups;
|
|
54
|
+
},
|
|
55
|
+
[[]],
|
|
56
|
+
);
|
|
@@ -3,25 +3,7 @@ import { densityFindings } from "./ai-phrasing.ts";
|
|
|
3
3
|
import { endsWithColon } from "./lead-in.ts";
|
|
4
4
|
import { comparableText, comparableWords, entryIn, entryRanges } from "./lexicon-match.ts";
|
|
5
5
|
import { isMarkdownPath } from "../structure/markdown-path.ts";
|
|
6
|
-
|
|
7
|
-
/** Between a lead-in and its list: only blank space. A thematic break (`***`) separates them; bold marks sit inside the sentence. */
|
|
8
|
-
const ONLY_BLANKS = /^\s*$/u;
|
|
9
|
-
|
|
10
|
-
/** How many sentences end at or before an offset. Sentences are in document order, so a binary search. */
|
|
11
|
-
const countEndingBy = (sentences: readonly Sentence[], offset: number): number => {
|
|
12
|
-
const search = (low: number, high: number): number => {
|
|
13
|
-
if (low >= high) return low;
|
|
14
|
-
const middle = Math.floor((low + high) / 2);
|
|
15
|
-
return (sentences[middle]?.span.end ?? Infinity) <= offset ? search(middle + 1, high) : search(low, middle);
|
|
16
|
-
};
|
|
17
|
-
return search(0, sentences.length);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/** The sentence that ends last before the list starts, if nothing but blanks lies between them. */
|
|
21
|
-
const sentenceRightBefore = (sentences: readonly Sentence[], list: BulletList, source: string): Sentence | undefined => {
|
|
22
|
-
const before = sentences[countEndingBy(sentences, list.span.start) - 1];
|
|
23
|
-
return before !== undefined && ONLY_BLANKS.test(source.slice(before.span.end, list.span.start)) ? before : undefined;
|
|
24
|
-
};
|
|
6
|
+
import { sentenceRightBefore } from "../list-lead-sentence.ts";
|
|
25
7
|
|
|
26
8
|
const insideAny = (spans: readonly Span[], offset: number): boolean => spans.some((span) => span.start <= offset && offset < span.end);
|
|
27
9
|
|
|
@@ -6,7 +6,8 @@ import { isQuotedAt } from "./bold-label.ts";
|
|
|
6
6
|
import { endsAsHeadline, markOrSkipped, withoutFootnoteReference, withoutTrailingMarks } from "./list-item-ending.ts";
|
|
7
7
|
import type { BulletList, Detector, Finding, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
|
|
8
8
|
import { isLinkLabel } from "./link-label.ts";
|
|
9
|
-
import { itemLayout } from "./list-layout.ts";
|
|
9
|
+
import { itemLayout, splitAtLeadIns } from "./list-layout.ts";
|
|
10
|
+
import { closesAsSentence, isFiniteVerb, isNounPhraseWithVerbs, isPastForm, isVerb, NOMINAL, NOUN_HEAD, opensObject } from "./list-item-phrase.ts";
|
|
10
11
|
|
|
11
12
|
/** What an item is made of: a phrase or a sentence (ending), and the word it opens with (head, English only). */
|
|
12
13
|
export type Axis = "ending" | "head";
|
|
@@ -16,19 +17,13 @@ export const FORMS: Readonly<Record<Axis, readonly [string, string]>> = { ending
|
|
|
16
17
|
|
|
17
18
|
const SKIPPED_AT_END = new Set(["PUNCT", "SYM", "X"]);
|
|
18
19
|
const isMark = markOrSkipped(SKIPPED_AT_END);
|
|
19
|
-
const NOMINAL = new Set(["NOUN", "PROPN", "NUM", "PRON"]);
|
|
20
20
|
const PREDICATE = new Set(["VERB", "AUX", "ADJ"]);
|
|
21
|
-
const NOUN_HEAD = new Set(["NOUN", "ADJ", "DET", "NUM", "PRON", "PROPN"]);
|
|
22
|
-
const SENTENCE_END = /[.!?。.!?]["'”’))」』]*$/u;
|
|
23
21
|
const OPENING_BRACKETS = new Set(["(", "(", "[", "[", "【"]);
|
|
24
22
|
const CLOSING_BRACKETS = new Set([")", ")", "]", "]", "】"]);
|
|
25
23
|
|
|
26
24
|
/** A word the tagger only guessed at, or one that is also a verb (Design, Document): its form is not known. */
|
|
27
25
|
const isUnsure = (token: Token | undefined): boolean => token?.features?.["Guess"] === "Yes" || token?.features?.["AlsoVerb"] === "Yes";
|
|
28
26
|
|
|
29
|
-
/** A finite verb or auxiliary: an English item with one says something. A gerund or participle (Running, nested) does not. */
|
|
30
|
-
const isFiniteVerb = (token: Token): boolean => (token.pos === "VERB" || token.pos === "AUX") && !["Ger", "Part"].includes(token.features?.["VerbForm"] ?? "");
|
|
31
|
-
|
|
32
27
|
/** The tokens before a closing aside: 「健康診断書(3か月以内のもの)」 ends, for its form, at 健康診断書. */
|
|
33
28
|
const withoutClosingAside = (tokens: readonly Token[]): readonly Token[] => {
|
|
34
29
|
const last = tokens.findLastIndex((token) => !SKIPPED_AT_END.has(token.pos) || CLOSING_BRACKETS.has(token.surface));
|
|
@@ -114,15 +109,20 @@ const japaneseEnding = (item: readonly Sentence[], headlineEndings: ReadonlySet<
|
|
|
114
109
|
return sentences.length > 1 ? "sentence" : japaneseSentenceEnding(sentences[0], headlineEndings);
|
|
115
110
|
};
|
|
116
111
|
|
|
117
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* English: a sentence closes with a full stop and has a finite verb outside a noun phrase; a phrase has neither, nor any
|
|
114
|
+
* verb but those of its noun phrase. Anything between is not judged.
|
|
115
|
+
*/
|
|
118
116
|
const englishEnding = (item: readonly Sentence[]): string | undefined => {
|
|
119
117
|
const sentences = ownEnding(item);
|
|
120
118
|
const tokens = sentences.flatMap((sentence) => sentence.tokens ?? []);
|
|
121
119
|
if (tokens.length === 0) return undefined;
|
|
122
|
-
const closed =
|
|
123
|
-
if (sentences.length > 1
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
const closed = closesAsSentence(sentences.at(-1)?.text.trim() ?? "");
|
|
121
|
+
if (sentences.length > 1) return "sentence";
|
|
122
|
+
// A noun phrase with a stray full stop (Shelter – a charity who offer advice.) says nothing: neither form.
|
|
123
|
+
const nounPhrase = isNounPhraseWithVerbs(tokens);
|
|
124
|
+
if (closed) return tokens.some(isFiniteVerb) && !nounPhrase ? "sentence" : undefined;
|
|
125
|
+
return (nounPhrase || !tokens.some(isVerb)) && !isUnsure(tokens[0]) ? "phrase" : undefined;
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
/** English: the word an item opens with. Install and Running open with a verb; The, Fast and Docker with a noun phrase. */
|
|
@@ -136,9 +136,6 @@ const isTitleCase = (text: string): boolean =>
|
|
|
136
136
|
.split(/\s+/u)
|
|
137
137
|
.every((word) => TITLE_SMALL_WORDS.has(word) || /^\p{Lu}/u.test(word));
|
|
138
138
|
|
|
139
|
-
/** A determiner that opens an object (the, a, your): no noun phrase goes on from its head with one. */
|
|
140
|
-
const opensObject = (token: Token | undefined): boolean => token?.features?.["PronType"] === "Art" || token?.features?.["Poss"] === "Yes";
|
|
141
|
-
|
|
142
139
|
const AFTER_ADJECTIVE = new Set(["ADP", "PART"]);
|
|
143
140
|
|
|
144
141
|
/** A noun or adjective, or an ordinary word the tagger took for a name because it is capitalised (Toggle). */
|
|
@@ -149,16 +146,6 @@ const isNounOrAdjective = (token: Token): boolean =>
|
|
|
149
146
|
const isBaseVerb = (token: Token | undefined): boolean =>
|
|
150
147
|
token?.pos === "VERB" && token.features?.["VerbForm"] === undefined && token.lemma === token.surface.toLowerCase();
|
|
151
148
|
|
|
152
|
-
/**
|
|
153
|
-
* An -ed word the tagger left without VerbForm (decreased, agreed, unauthorized): like a participle, it may modify the noun
|
|
154
|
-
* after it. Proceed and need end in -ed too but are their own base forms.
|
|
155
|
-
*/
|
|
156
|
-
const isPastForm = (token: Token): boolean =>
|
|
157
|
-
token.pos === "VERB" &&
|
|
158
|
-
token.features?.["VerbForm"] === undefined &&
|
|
159
|
-
/ed$/iu.test(token.surface) &&
|
|
160
|
-
(token.lemma !== token.surface.toLowerCase() || !/eed$/iu.test(token.surface));
|
|
161
|
-
|
|
162
149
|
/** An -s word read as a verb that the tagger could not take back to a base form (Revisions): a plural noun, misread. Discuss and Focus are verbs. */
|
|
163
150
|
const isMisreadPlural = (token: Token): boolean =>
|
|
164
151
|
token.pos === "VERB" && token.features?.["VerbForm"] === undefined && /[^su]s$/iu.test(token.surface) && token.lemma === token.surface.toLowerCase();
|
|
@@ -406,9 +393,15 @@ const MIN_WORDS = 2;
|
|
|
406
393
|
const wordCount = (sentences: readonly Sentence[]): number =>
|
|
407
394
|
sentences.flatMap((sentence) => sentence.tokens ?? []).filter((token) => !SKIPPED_AT_END.has(token.pos)).length;
|
|
408
395
|
|
|
396
|
+
/** An item wholly in bold (**Nice to have**): the label of the items after it, not one of them. */
|
|
397
|
+
const BOLD_LABEL = /^(\*\*|__)[^*_]+\1[::]?$/u;
|
|
398
|
+
const LIST_MARKER = /^\s*(?:\d+[.)]|[-*+])\s+/u;
|
|
399
|
+
|
|
400
|
+
const isBoldLabel = (written: string): boolean => BOLD_LABEL.test(written.replace(LIST_MARKER, "").trim());
|
|
401
|
+
|
|
409
402
|
const isJudged = (written: string, sentences: readonly Sentence[]): boolean => {
|
|
410
403
|
const text = sentences.map((sentence) => sentence.text).join(" ");
|
|
411
|
-
return wordCount(sentences) >= MIN_WORDS && !LABELLED.test(text.trim()) && !CODE_OR_LINK.test(written);
|
|
404
|
+
return wordCount(sentences) >= MIN_WORDS && !LABELLED.test(text.trim()) && !CODE_OR_LINK.test(written) && !isBoldLabel(written);
|
|
412
405
|
};
|
|
413
406
|
|
|
414
407
|
const runsOn = (sentences: readonly Sentence[]): boolean => RUNNING_ON.test(sentences.at(-1)?.text.trim() ?? "");
|
|
@@ -431,7 +424,17 @@ const headContext = (doc: ProseDocument, items: readonly (readonly Sentence[])[]
|
|
|
431
424
|
|
|
432
425
|
const listFindings = (doc: ProseDocument, list: BulletList, limit: number): Finding[] => {
|
|
433
426
|
const layout = itemLayout(doc.source, list.itemSpans);
|
|
434
|
-
return layout.groups.flatMap((spans) =>
|
|
427
|
+
return layout.groups.flatMap((spans) => splitAtLeadIns(doc.source, spans).flatMap((group) => groupFindings(doc, group, layout.heads, limit)));
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Where the item as written ends: past its last sentence, up to a list nested in it or a note line under it. A link after
|
|
432
|
+
* the last sentence (Names of travellers [What if this changes?](#…)) is the item's too.
|
|
433
|
+
*/
|
|
434
|
+
const writtenEnd = (doc: ProseDocument, item: Span, sentences: readonly Sentence[], noteLeads: readonly string[]): number => {
|
|
435
|
+
const nested = doc.lists.map((list) => list.span.start).filter((start) => start > item.start && start < item.end);
|
|
436
|
+
const end = Math.min(itemOwnEnd(doc.source, item, noteLeads), ...nested);
|
|
437
|
+
return Math.max(end, sentences.at(-1)?.span.end ?? end);
|
|
435
438
|
};
|
|
436
439
|
|
|
437
440
|
/** A phrase heading a run of items (- 使用する際の注意ポイント): the heading of a flattened nested list, not one of its items. */
|
|
@@ -446,7 +449,7 @@ const groupFindings = (doc: ProseDocument, itemSpans: readonly Span[], heads: re
|
|
|
446
449
|
const judged = sentencesOf.filter((sentences, index) => {
|
|
447
450
|
const span = itemSpans[index];
|
|
448
451
|
if (span === undefined) return false;
|
|
449
|
-
const written = doc.source.slice(span.start,
|
|
452
|
+
const written = doc.source.slice(span.start, writtenEnd(doc, span, sentences, noteLeads));
|
|
450
453
|
return isJudged(written, sentences) && !isLinkLabel(written, linkEndings) && !(heads.includes(span) && isGroupLabel(sentences, doc.language));
|
|
451
454
|
});
|
|
452
455
|
const context = headContext(doc, judged);
|
|
@@ -7,8 +7,9 @@ import { codePointName } from "./invisible-character.ts";
|
|
|
7
7
|
* compatibility: a CJK compatibility ideograph (or one of its supplement) that Unicode maps to a unified one (樂 U+F914 for 樂).
|
|
8
8
|
* decomposed: a letter and a separate combining mark (か + U+3099 for が, e + U+0301 for é), from file names or text
|
|
9
9
|
* copied on macOS. spacing-mark: kana followed by the spacing ゛ or ゜, typed in place of the combined letter.
|
|
10
|
+
* dash: a dash or minus between katakana (ニュ-ス, U+FF0D), typed in place of the long-vowel mark ー.
|
|
10
11
|
*/
|
|
11
|
-
export type LookalikeKind = "radical" | "compatibility" | "decomposed" | "spacing-mark";
|
|
12
|
+
export type LookalikeKind = "radical" | "compatibility" | "decomposed" | "spacing-mark" | "dash";
|
|
12
13
|
|
|
13
14
|
export type Lookalike = { readonly span: Span; readonly kind: LookalikeKind; readonly written: string; readonly usual: string };
|
|
14
15
|
|
|
@@ -48,8 +49,24 @@ const spacingMarkLookalikes = (source: string): Lookalike[] =>
|
|
|
48
49
|
return [{ span: { start: match.index, end: match.index + match[0].length }, kind: "spacing-mark", written: match[0], usual }];
|
|
49
50
|
});
|
|
50
51
|
|
|
52
|
+
const LONG_VOWEL = "ー";
|
|
53
|
+
/**
|
|
54
|
+
* A dash, a minus or a box line after a katakana letter that can be lengthened and before another katakana letter. The
|
|
55
|
+
* half-width - is left out: between katakana it joins the parts of a template or a range (<アルゴリズム>-<ハッシュ>, ァ-ヶ).
|
|
56
|
+
*/
|
|
57
|
+
const DASH_FOR_LONG_VOWEL = /(?<=[ァ-ヂツ-ヲヴ-ヺ])[\u2010-\u2015\u2212\uFF0D\u2500\u2501](?=[ァ-ヺ])/gu;
|
|
58
|
+
|
|
59
|
+
/** A dash typed in place of the long-vowel mark between katakana (ニュ-ス → ニュース). */
|
|
60
|
+
const dashLookalikes = (source: string): Lookalike[] =>
|
|
61
|
+
[...source.matchAll(DASH_FOR_LONG_VOWEL)].map((match) => ({
|
|
62
|
+
span: { start: match.index, end: match.index + match[0].length },
|
|
63
|
+
kind: "dash",
|
|
64
|
+
written: match[0],
|
|
65
|
+
usual: LONG_VOWEL,
|
|
66
|
+
}));
|
|
67
|
+
|
|
51
68
|
export const lookalikesIn = (source: string): Lookalike[] =>
|
|
52
|
-
[...singleLookalikes(source), ...decomposedLookalikes(source), ...spacingMarkLookalikes(source)].toSorted(
|
|
69
|
+
[...singleLookalikes(source), ...decomposedLookalikes(source), ...spacingMarkLookalikes(source), ...dashLookalikes(source)].toSorted(
|
|
53
70
|
(left, right) => left.span.start - right.span.start,
|
|
54
71
|
);
|
|
55
72
|
|