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,6 +1,7 @@
|
|
|
1
1
|
import type { Detector, Finding, Lexicon, ProseDocument, Sentence } from "../plugin.ts";
|
|
2
2
|
import { escapeRegExp } from "../orthography.ts";
|
|
3
3
|
import { isConventionalPhrase } from "./caps-phrase.ts";
|
|
4
|
+
import { namesScreenLabel } from "./caps-screen-label.ts";
|
|
4
5
|
import { minorityReport } from "../spacing-minority.ts";
|
|
5
6
|
import { externalLinkTitleSpans } from "../link-title.ts";
|
|
6
7
|
import { formulaBracketSpans } from "../formula-brackets.ts";
|
|
@@ -11,6 +12,8 @@ import { lineStarts } from "../position.ts";
|
|
|
11
12
|
import { isTypewritten } from "./typewritten.ts";
|
|
12
13
|
import { divisionLabelPattern, isDivisionSeparator } from "./division-label-separator.ts";
|
|
13
14
|
import { isInCopiedText } from "./hyphen-copied-text.ts";
|
|
15
|
+
import { joinsNameSuffix } from "./hyphen-name-suffix.ts";
|
|
16
|
+
import { verseBlockSpans } from "./verse-block.ts";
|
|
14
17
|
|
|
15
18
|
/** The letters a mark must touch to count as part of the document's text, by language. */
|
|
16
19
|
const SCRIPT: Readonly<Record<string, RegExp>> = {
|
|
@@ -180,6 +183,22 @@ export const noteMarkerOffsets = (source: string): ReadonlySet<number> =>
|
|
|
180
183
|
|
|
181
184
|
const NOTE_KIND = "\u0000note";
|
|
182
185
|
|
|
186
|
+
/**
|
|
187
|
+
* A note's number cited in the prose (注(24)で示した): an author writes it as the notes' labels are, or as the prose's
|
|
188
|
+
* brackets are, and either is the document's own notation for it.
|
|
189
|
+
*/
|
|
190
|
+
const NOTE_ADDRESS = /(?<=[注註])(?:\([0-90-9]{1,3}\)|([0-90-9]{1,3}))/gu;
|
|
191
|
+
|
|
192
|
+
/** The offsets in `source` of the brackets of every note's cited number. */
|
|
193
|
+
export const noteAddressOffsets = (source: string): ReadonlySet<number> =>
|
|
194
|
+
new Set([...source.matchAll(NOTE_ADDRESS)].flatMap((match) => [match.index, match.index + match[0].length - 1]));
|
|
195
|
+
|
|
196
|
+
const NOTE_ADDRESS_KIND = "\u0000noteaddress";
|
|
197
|
+
|
|
198
|
+
/** A note's cited number is a kind of its own, compared only with the other cited note numbers. */
|
|
199
|
+
const withNoteAddressKind = (mark: Mark, addresses: ReadonlySet<number>): Mark =>
|
|
200
|
+
addresses.has(mark.offset) ? { ...mark, form: { ...mark.form, kind: `${mark.form.kind}${NOTE_ADDRESS_KIND}` } } : mark;
|
|
201
|
+
|
|
183
202
|
/** A note marker's bracket is a kind of its own, compared only with the other note markers' brackets. */
|
|
184
203
|
const withNoteKind = (mark: Mark, notes: ReadonlySet<number>): Mark =>
|
|
185
204
|
notes.has(mark.offset) && !mark.form.kind.endsWith(ENUMERATOR_KIND) ? { ...mark, form: { ...mark.form, kind: `${mark.form.kind}${NOTE_KIND}` } } : mark;
|
|
@@ -199,8 +218,11 @@ export const markConsistency: Detector = (doc, options): Finding[] => {
|
|
|
199
218
|
const enumerators = enumeratorBracketOffsets(doc.source);
|
|
200
219
|
const doubled = doubledParenOffsets(doc.source);
|
|
201
220
|
const notes = noteMarkerOffsets(doc.source);
|
|
221
|
+
const noteAddresses = noteAddressOffsets(doc.source);
|
|
202
222
|
const marks = ownSentences(doc).flatMap((sentence) =>
|
|
203
|
-
marksIn(doc.source, sentence, forms, script).map((mark) =>
|
|
223
|
+
marksIn(doc.source, sentence, forms, script).map((mark) =>
|
|
224
|
+
withNoteAddressKind(withNoteKind(withDoubledKind(withEnumeratorKind(mark, enumerators), doubled), notes), noteAddresses),
|
|
225
|
+
),
|
|
204
226
|
);
|
|
205
227
|
const kinds = [...new Set(marks.map((mark) => mark.form.kind))];
|
|
206
228
|
return kinds.flatMap((kind) =>
|
|
@@ -219,18 +241,25 @@ export const markConsistency: Detector = (doc, options): Finding[] => {
|
|
|
219
241
|
const SENTENCE_END = /(?<![\p{L}\d.])\p{Ll}{2,}[.!?]["'”’)\]]?$/u;
|
|
220
242
|
/** The next sentence starts with a capital, past an opening quote: not a citation ("[ISO99]") or an aside in brackets. */
|
|
221
243
|
const SENTENCE_START = /^["'“‘]?\p{Lu}/u;
|
|
244
|
+
/** "Affiliation: …", "Note: …": a field's label opens what follows, as in an author block joined into one line. */
|
|
245
|
+
const FIELD_LABEL = /^\p{Lu}\p{Ll}+:\s/u;
|
|
222
246
|
const ONE_SPACE = " ";
|
|
223
247
|
const TWO_SPACES = " ";
|
|
224
248
|
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
|
|
249
|
+
/**
|
|
250
|
+
* The space between two sentences on one line, when the first ends with a period, question or exclamation mark. spaced is
|
|
251
|
+
* two spaces. A pause inside a verse line ("I'm nobody! Who are you?") is the stanza's layout, not the prose's spacing.
|
|
252
|
+
*/
|
|
253
|
+
export const sentenceGaps = (doc: ProseDocument): Sided[] => {
|
|
254
|
+
const stanzas = verseBlockSpans(doc.source);
|
|
255
|
+
return ownSentences(doc).flatMap((sentence, at, sentences) => {
|
|
228
256
|
const next = sentences[at + 1];
|
|
229
|
-
if (next === undefined || !SENTENCE_END.test(sentence.text) || !SENTENCE_START.test(next.text)) return [];
|
|
257
|
+
if (next === undefined || !SENTENCE_END.test(sentence.text) || !SENTENCE_START.test(next.text) || FIELD_LABEL.test(next.text)) return [];
|
|
230
258
|
const gap = doc.source.slice(sentence.span.end, next.span.start);
|
|
231
|
-
if (gap !== ONE_SPACE && gap !== TWO_SPACES) return [];
|
|
259
|
+
if ((gap !== ONE_SPACE && gap !== TWO_SPACES) || isWithinSorted(stanzas, { start: sentence.span.end, end: next.span.start })) return [];
|
|
232
260
|
return [{ sentence: next, spaced: gap === TWO_SPACES, offset: sentence.span.end }];
|
|
233
261
|
});
|
|
262
|
+
};
|
|
234
263
|
|
|
235
264
|
/** One space between sentences and two, mixed in one document: the less common is reported. */
|
|
236
265
|
export const sentenceSpacing: Detector = (doc, options): Finding[] =>
|
|
@@ -294,7 +323,13 @@ export const hyphenDash: Detector = (doc, options): Finding[] => {
|
|
|
294
323
|
return reportFrom(
|
|
295
324
|
[...hitsOf(sentences, HYPHEN_DASH), ...codeHits]
|
|
296
325
|
.toSorted((left, right) => left.offset - right.offset)
|
|
297
|
-
.filter(
|
|
326
|
+
.filter(
|
|
327
|
+
(hit) =>
|
|
328
|
+
!isTypedDash(hit, setsDashes) &&
|
|
329
|
+
!isDivisionSeparator(doc.source, hit.offset, divisionLabel) &&
|
|
330
|
+
!isInCopiedText(doc.source, hit.offset) &&
|
|
331
|
+
!joinsNameSuffix(doc.source, hit.offset),
|
|
332
|
+
),
|
|
298
333
|
options.limit,
|
|
299
334
|
);
|
|
300
335
|
};
|
|
@@ -348,7 +383,7 @@ export const isShouting = (run: string, known: ReadonlySet<string>, conventional
|
|
|
348
383
|
/**
|
|
349
384
|
* Runs of three or more all-capital words that are ordinary words, not acronyms ("DO NOT DELETE THIS"), and not a
|
|
350
385
|
* caption, a mention of one, a paragraph of capital lines that ends no sentence (a letterhead, a heading), a roster name, a
|
|
351
|
-
* placeholder in square brackets, or a
|
|
386
|
+
* placeholder in square brackets, a whole quotation, or a label a sentence names as on a screen ("in SUBMIT TO APPROVER status").
|
|
352
387
|
*/
|
|
353
388
|
export const capsShouting: Detector = (doc, options): Finding[] => {
|
|
354
389
|
const known = lowerCaseWords(doc.prose ?? doc.source);
|
|
@@ -356,6 +391,7 @@ export const capsShouting: Detector = (doc, options): Finding[] => {
|
|
|
356
391
|
const captions = captionsOf(doc.source);
|
|
357
392
|
const capitalLines = capitalLineSpans(doc.source);
|
|
358
393
|
const placeholders = bracketPlaceholderSpans(doc.source);
|
|
394
|
+
const screenNouns = new Set((doc.lexicons["screen-label-noun"] ?? []).map((entry) => entry.pattern));
|
|
359
395
|
const isCaptionOrLetterhead = (hit: Hit): boolean => {
|
|
360
396
|
const span = { start: hit.offset, end: hit.offset + hit.matched.length };
|
|
361
397
|
return (
|
|
@@ -363,7 +399,8 @@ export const capsShouting: Detector = (doc, options): Finding[] => {
|
|
|
363
399
|
isCaptionAt(doc.source, span.start, span.end) ||
|
|
364
400
|
isWithinSorted(capitalLines, span) ||
|
|
365
401
|
isWithinAny(placeholders, span) ||
|
|
366
|
-
isWholeQuotation(doc.source, span.start, span.end)
|
|
402
|
+
isWholeQuotation(doc.source, span.start, span.end) ||
|
|
403
|
+
namesScreenLabel(doc.source, span.start, span.end, screenNouns)
|
|
367
404
|
);
|
|
368
405
|
};
|
|
369
406
|
const hits = hitsOf(ownSentences(doc), CAPS_RUN).filter((hit) => isShouting(hit.matched, known, conventional) && !isCaptionOrLetterhead(hit));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProseDocument, StructureNode } from "../plugin.ts";
|
|
1
|
+
import type { ProseDocument, Span, StructureNode } from "../plugin.ts";
|
|
2
2
|
import { nameSpans } from "../compare/proper-nouns.ts";
|
|
3
3
|
import { overlapsAny, spanIndex } from "../compare/spans.ts";
|
|
4
4
|
import { factValues, type FactValue } from "../facts/fact-values.ts";
|
|
@@ -6,15 +6,22 @@ import { codeFences } from "./code-fences.ts";
|
|
|
6
6
|
import { measuredValues, type Measured } from "../facts/measures.ts";
|
|
7
7
|
import { measureUnitsOf } from "../facts/measure-units.ts";
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
export const
|
|
9
|
+
/** 値がコードの塊の外にあるか。コードの中の値(// @errors: 2345)は例の一部で、文書の項目の値ではない。 */
|
|
10
|
+
export const outsideCode = (doc: ProseDocument): ((value: Span) => boolean) => {
|
|
11
11
|
const fences = codeFences(doc.source);
|
|
12
|
-
return
|
|
12
|
+
return (value) => !fences.some((fence) => fence.start <= value.start && value.end <= fence.end);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
/** 文書の中の、単位の語彙表の単位が付いた量。コードの塊の中の量は、項目の値ではない。 */
|
|
16
|
+
export const measuredOf = (doc: ProseDocument): Measured[] => measuredValues(doc.source, measureUnitsOf(doc)).filter(outsideCode(doc));
|
|
17
|
+
|
|
15
18
|
/** fact-conflict の値に、単位の付いた量を足す。量と重なる値(量の数だけを読んだもの)は量に置き換える。 */
|
|
16
19
|
export const valuesWith = (tree: StructureNode, doc: ProseDocument, measured: readonly FactValue[]): FactValue[] => {
|
|
17
20
|
const taken = spanIndex(measured);
|
|
18
21
|
const others = factValues(tree, doc.source, nameSpans(doc)).filter((value) => !overlapsAny(taken, value));
|
|
19
22
|
return [...others, ...measured].toSorted((left, right) => left.start - right.start);
|
|
20
23
|
};
|
|
24
|
+
|
|
25
|
+
/** valuesWith の値のうち、コードの塊の外のもの。項目の値を読む rule は、例のコードの中の値を文書の値と比べない。 */
|
|
26
|
+
export const valuesOutsideCode = (tree: StructureNode, doc: ProseDocument, measured: readonly FactValue[]): FactValue[] =>
|
|
27
|
+
valuesWith(tree, doc, measured).filter(outsideCode(doc));
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Detector, Finding } from "../plugin.ts";
|
|
2
|
+
import { isFlattenedTable } from "./sentence-parts.ts";
|
|
3
|
+
|
|
1
4
|
const MIDDLE_DOT = /・/gu;
|
|
2
5
|
|
|
3
6
|
/** 文頭か行頭(前に空白だけ)の「・」。前に並べる項目が無いので、箇条書きの印。 */
|
|
@@ -13,3 +16,54 @@ const withoutWordDots = (text: string, words: readonly string[]): string =>
|
|
|
13
16
|
*/
|
|
14
17
|
export const parallelDotCount = (text: string, words: readonly string[] = []): number =>
|
|
15
18
|
[...withoutWordDots(text, words).replace(BULLET_DOT, "$1").matchAll(MIDDLE_DOT)].length;
|
|
19
|
+
|
|
20
|
+
/** 項目を数える一続きの区切り。読点、句点、改行や空白で切る。半角の , と . は数(1,000、12.0)の中にあるので切らない。 */
|
|
21
|
+
const STRETCH_END = /[、。,\s]+/u;
|
|
22
|
+
/** 長さを比べる最少の項目の数。これより少なければ、語の並びか句の並びか決めない。 */
|
|
23
|
+
const MIN_INNER_ITEMS = 3;
|
|
24
|
+
/** 項目の字数の中央値がこれを超えれば、語でなく句の並び(オーナーチェンジ物件への回帰・都市部シェア拡大・…)。 */
|
|
25
|
+
const MAX_WORD_ITEM_CHARS = 10;
|
|
26
|
+
|
|
27
|
+
/** 一続きの区切りの中で、前後を中黒で挟まれた項目。最初と最後の項目は、前後の文の語とつながっていて長さが読めないので除く。 */
|
|
28
|
+
const innerItems = (text: string, words: readonly string[]): string[] =>
|
|
29
|
+
withoutWordDots(text, words)
|
|
30
|
+
.replace(BULLET_DOT, "$1")
|
|
31
|
+
.split(STRETCH_END)
|
|
32
|
+
.flatMap((stretch) => stretch.split("・").slice(1, -1));
|
|
33
|
+
|
|
34
|
+
const median = (values: readonly number[]): number => {
|
|
35
|
+
const sorted = values.toSorted((left, right) => left - right);
|
|
36
|
+
const middle = Math.floor(sorted.length / 2);
|
|
37
|
+
return sorted.length % 2 === 1 ? (sorted[middle] ?? 0) : ((sorted[middle - 1] ?? 0) + (sorted[middle] ?? 0)) / 2;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 一行に一項目の箇条書きを、変換が一続きにしたもの(<事業戦略>・オーナーチェンジ物件への回帰・都市部シェア拡大・…)。
|
|
42
|
+
* 中黒で並べる語(企画・開発・運用)は短く、項目が句の長さなら、中黒は箇条書きの印が行の切れ目を失ったもの。
|
|
43
|
+
*/
|
|
44
|
+
export const isRunTogetherList = (text: string, words: readonly string[] = []): boolean => {
|
|
45
|
+
const items = innerItems(text, words);
|
|
46
|
+
return items.length >= MIN_INNER_ITEMS && median(items.map((item) => [...item].length)) > MAX_WORD_ITEM_CHARS;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 中黒で並べると、どこまでが 1 つの項目か分からなくなる。
|
|
51
|
+
* 「企画・開発・運用・保守体制」は、保守体制が 1 つなのか保守と体制なのか読めない。
|
|
52
|
+
* 語彙表(nakaguro-word)の、中黒を含めて 1 語の語(キャッシュ・フロー)の中黒は並べていないので数えない。
|
|
53
|
+
*/
|
|
54
|
+
export const middleDot: Detector = (doc, options): Finding[] => {
|
|
55
|
+
const words = (options.lexicon ?? []).map((entry) => entry.pattern).toSorted((left, right) => right.length - left.length);
|
|
56
|
+
// 表や箇条書きを変換が一続きにした文(年表の行、一行一項目の箇条書き)は、中黒が並べた語の切れ目か、項目の印か読めない。
|
|
57
|
+
return doc.sentences
|
|
58
|
+
.filter((sentence) => !isFlattenedTable(sentence.text) && !isRunTogetherList(sentence.text, words))
|
|
59
|
+
.map((sentence) => ({ sentence, count: parallelDotCount(sentence.text, words) }))
|
|
60
|
+
.filter(({ count }) => count > options.limit)
|
|
61
|
+
.map(({ sentence, count }) => ({
|
|
62
|
+
rule: "no-nakaguro-parallel",
|
|
63
|
+
severity: "info",
|
|
64
|
+
line: 0,
|
|
65
|
+
column: 0,
|
|
66
|
+
quote: sentence.text.trim(),
|
|
67
|
+
values: { count, limit: options.limit, offset: sentence.span.start },
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
@@ -31,6 +31,8 @@ const DESCRIPTION = /^[::](?![::])/u;
|
|
|
31
31
|
const LAYOUT = /[ \u3000]{2}/u;
|
|
32
32
|
/** Fewer characters than this is a label or a caption, not a sentence. */
|
|
33
33
|
const MIN_SENTENCE_CHARS = 15;
|
|
34
|
+
/** A cell is short: a one-line paragraph this long or longer is a clause (…と認められた場合), not a cell before the term. A paragraph masked to nothing (a quotation) is no cell either. */
|
|
35
|
+
const MAX_CELL_CHARS = MIN_SENTENCE_CHARS * 2;
|
|
34
36
|
/** Words that end a clause: a verb, an adjective or an auxiliary in its dictionary form ends the sentence. */
|
|
35
37
|
const PREDICATE: ReadonlySet<string> = new Set(["VERB", "ADJ", "AUX"]);
|
|
36
38
|
|
|
@@ -79,9 +81,20 @@ const isTerm = (body: string, marks: PeriodMarks): boolean =>
|
|
|
79
81
|
const isDescription = (text: string, paragraph: Paragraph, marks: PeriodMarks, previous: Paragraph | undefined): boolean =>
|
|
80
82
|
DESCRIPTION.test(bodyOf(text, paragraph)) && previous !== undefined && isTerm(bodyOf(text, previous), marks);
|
|
81
83
|
|
|
84
|
+
/**
|
|
85
|
+
* A cell of a table laid out as paragraphs: a term line with its note under it (乾式バッテリー / …マンガンバッテリーも含む), right after
|
|
86
|
+
* another open one-line cell (ニッケル水素電池等). The note annotates the term, like the cell it came from.
|
|
87
|
+
*/
|
|
88
|
+
const isTermCell = (text: string, paragraph: Paragraph, marks: PeriodMarks, previous: Paragraph | undefined): boolean => {
|
|
89
|
+
const [first, ...rest] = bodyOf(text, paragraph).split("\n");
|
|
90
|
+
const cellBefore = previous === undefined ? "\n" : bodyOf(text, previous);
|
|
91
|
+
const isCell = cellBefore !== "" && !cellBefore.includes("\n") && Array.from(cellBefore).length < MAX_CELL_CHARS && !isClosed(cellBefore, marks.ends);
|
|
92
|
+
return rest.length > 0 && isTerm(first?.trim() ?? "", marks) && isCell;
|
|
93
|
+
};
|
|
94
|
+
|
|
82
95
|
/** How a paragraph ends, or undefined when its last line is not a sentence (a label, a lead-in, a note, a laid-out row). */
|
|
83
96
|
export const paragraphEnd = (text: string, paragraph: Paragraph, marks: PeriodMarks, next?: Paragraph, previous?: Paragraph): ParagraphEnd | undefined => {
|
|
84
|
-
if (isDescription(text, paragraph, marks, previous)) return undefined;
|
|
97
|
+
if (isDescription(text, paragraph, marks, previous) || isTermCell(text, paragraph, marks, previous)) return undefined;
|
|
85
98
|
const body = text.slice(paragraph.span.start, paragraph.span.end).trimEnd();
|
|
86
99
|
const last = body.split("\n").at(-1)?.trim() ?? "";
|
|
87
100
|
if (Array.from(last).length < MIN_SENTENCE_CHARS || LEAD_IN.test(last)) return undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Detector, Finding, ProseDocument } from "../plugin.ts";
|
|
2
|
+
import { spellsAcronym } from "./acronym-capitals.ts";
|
|
2
3
|
import { cuedNamesIn, mentionsIn, nameVariants, suffixedNamesIn, type NameMention, type VariantChars } from "../name-variants.ts";
|
|
3
4
|
import { withKnownNeighbours } from "../name-neighbours.ts";
|
|
4
5
|
import type { SpellingInput } from "../name-spelling-chars.ts";
|
|
@@ -388,7 +389,7 @@ export const nameVariant: Detector = (doc): Finding[] => {
|
|
|
388
389
|
const isTwoThings = twoThingsIn(doc, tokensOf(doc), speller, use.ordinary);
|
|
389
390
|
return [...withCodes, ...titles]
|
|
390
391
|
.filter(({ name, usual }) => speller === undefined || !isDictionaryPair(name, usual, speller))
|
|
391
|
-
.filter((found) => !isTwoThings(found))
|
|
392
|
+
.filter((found) => !isTwoThings(found) && !spellsAcronym(doc.source, found.offset, found.name))
|
|
392
393
|
.filter(notAnotherAuthorIn(doc))
|
|
393
394
|
.toSorted((left, right) => left.offset - right.offset)
|
|
394
395
|
.map(({ offset, name, usual, kind }) => ({
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** 連なりの前後の字と、名前を示す句の語彙。 */
|
|
2
|
+
type Surroundings = { readonly before: string; readonly next: string };
|
|
3
|
+
type ContextWords = { readonly designations: readonly string[]; readonly noticeEndings: readonly string[] };
|
|
4
|
+
|
|
5
|
+
/** 連なりの後ろ(next)が、制度が区分に入れることを言う句で始まるか(認定希少種保全動植物園等として認定)。 */
|
|
6
|
+
const isDesignated = (run: Surroundings, words: ContextWords): boolean => words.designations.some((phrase) => run.next.startsWith(phrase));
|
|
7
|
+
|
|
8
|
+
/** 行がお知らせの題で、連なりがその「の」の前か([e-Gov]〜設定解除完了のお知らせ)。題は句点で閉じない一行。 */
|
|
9
|
+
const isNoticeTitle = (run: Surroundings, words: ContextWords): boolean => {
|
|
10
|
+
const next = run.next.trim();
|
|
11
|
+
return !run.before.includes("\n") && words.noticeEndings.some((ending) => next === `の${ending}`);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** 前後の字が、漢字の連なりを名前と示しているか: 制度が決めた区分の名前か、送り手が付けたお知らせの題の名前。 */
|
|
15
|
+
export const isNamedByContext = (run: Surroundings, words: ContextWords): boolean => isDesignated(run, words) || isNoticeTitle(run, words);
|
|
@@ -22,6 +22,8 @@ export type NumberWords = {
|
|
|
22
22
|
readonly figureNouns: readonly string[];
|
|
23
23
|
/** Words written before a number to name one of a series (Grade 5, Room 12): the number after one is not a count. */
|
|
24
24
|
readonly nameWords: readonly string[];
|
|
25
|
+
/** Kanji counts read the native way (二通り, ふたとおり): written in kanji whatever the document's style for counts. */
|
|
26
|
+
readonly nativeCounts: readonly string[];
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
const alternation = (words: readonly string[]): string =>
|
|
@@ -81,7 +83,7 @@ const countMarks = (text: string, base: number, words: NumberWords, tokens: read
|
|
|
81
83
|
if (pattern === undefined) return [];
|
|
82
84
|
return [...text.matchAll(pattern)].flatMap((match): NumberMark[] => {
|
|
83
85
|
const [written, digits, kanji] = match;
|
|
84
|
-
if (kanji !== undefined && (isIdiomNumeral(kanji) || isInsideWord(written, base + match.index, tokens))) return [];
|
|
86
|
+
if (kanji !== undefined && (isIdiomNumeral(kanji) || words.nativeCounts.includes(written) || isInsideWord(written, base + match.index, tokens))) return [];
|
|
85
87
|
if (isBeforeLongerWord(digits ?? kanji ?? "", written, base + match.index, tokens)) return [];
|
|
86
88
|
return [{ kind: "count", style: digits === undefined ? "kanji" : "digits", written, offset: base + match.index }];
|
|
87
89
|
});
|
|
@@ -115,12 +117,20 @@ const isHexCode = (written: string, after: string): boolean => {
|
|
|
115
117
|
return /^\d+$/u.test(written) && LETTER_THEN_DIGIT.test(tail) && written.length + tail.length >= HEX_CODE_MIN;
|
|
116
118
|
};
|
|
117
119
|
|
|
120
|
+
/** A word that says a quantity is about so much (約1500): a number right after it is a quantity, not part of a code. */
|
|
121
|
+
const APPROXIMATELY = "約";
|
|
122
|
+
|
|
123
|
+
const isOpenBefore = (text: string, index: number): boolean => {
|
|
124
|
+
const before = text.charAt(index - 1);
|
|
125
|
+
return before === APPROXIMATELY || !NOT_BEFORE.test(before);
|
|
126
|
+
};
|
|
127
|
+
|
|
118
128
|
/** Each number of four digits or more standing alone, grouped (1,000) or not (1000). */
|
|
119
129
|
const bigNumbers = (text: string): DigitRun[] =>
|
|
120
130
|
[...text.matchAll(DIGITS_AND_COMMAS)].flatMap((match): DigitRun[] => {
|
|
121
131
|
const written = match[0];
|
|
122
132
|
const after = text.slice(match.index + written.length);
|
|
123
|
-
const standsAlone =
|
|
133
|
+
const standsAlone = isOpenBefore(text, match.index) && !NOT_AFTER.test(after.charAt(0)) && !isHexCode(written, after);
|
|
124
134
|
return standsAlone && (GROUPED.test(written) || PLAIN_BIG.test(written)) ? [{ written, index: match.index }] : [];
|
|
125
135
|
});
|
|
126
136
|
|
|
@@ -149,6 +159,17 @@ const countedAfter = (after: string, words: NumberWords): boolean => {
|
|
|
149
159
|
/** What follows a quantity: a Japanese counter, or a word in lower case (10000 users). */
|
|
150
160
|
const quantityAfter = (after: string, words: NumberWords): boolean => /^\s?[a-z]/u.test(after) || countedAfter(after, words);
|
|
151
161
|
|
|
162
|
+
/** The numbers after this one in a list that shares one unit (約1500、3,000、9,000m): each item takes the unit written after the last. */
|
|
163
|
+
const LIST_TAIL = /^(?:[、,]\s?約?[0-90-9]+(?:[,,][0-90-9]{3})*)+/u;
|
|
164
|
+
|
|
165
|
+
const GROUPED_ITEM = /[0-90-9][,,][0-90-9]{3}/u;
|
|
166
|
+
|
|
167
|
+
/** What follows a number, past the rest of the list it heads or stands in, and whether that list groups its digits (years never do). */
|
|
168
|
+
const afterList = (after: string): { readonly rest: string; readonly beforeGrouped: boolean } => {
|
|
169
|
+
const tail = LIST_TAIL.exec(after)?.[0] ?? "";
|
|
170
|
+
return { rest: after.slice(tail.length), beforeGrouped: GROUPED_ITEM.test(tail) };
|
|
171
|
+
};
|
|
172
|
+
|
|
152
173
|
/** How far back to look for a currency sign or a label word. The sentence may start right after one (H.R. ends a sentence). */
|
|
153
174
|
const BEFORE_REACH = 16;
|
|
154
175
|
|
|
@@ -156,11 +177,11 @@ const groupingMarks = (text: string, base: number, words: NumberWords, source: s
|
|
|
156
177
|
bigNumbers(text).flatMap(({ written, index }): NumberMark[] => {
|
|
157
178
|
const grouped = GROUPED.test(written);
|
|
158
179
|
const before = source.slice(Math.max(0, base + index - BEFORE_REACH), base + index);
|
|
159
|
-
const after = text.slice(index + written.length);
|
|
180
|
+
const { rest: after, beforeGrouped } = afterList(text.slice(index + written.length));
|
|
160
181
|
const currency = CURRENCY_BEFORE.test(before);
|
|
161
182
|
if (!currency && !quantityAfter(after, words)) return [];
|
|
162
183
|
if (!grouped && isLabelBefore(before)) return [];
|
|
163
|
-
if (!grouped && !currency && isYearLike(written) && !countedAfter(after, words)) return [];
|
|
184
|
+
if (!grouped && !currency && !beforeGrouped && isYearLike(written) && !countedAfter(after, words)) return [];
|
|
164
185
|
return [{ kind: "grouping", style: grouped ? "grouped" : "plain", written, offset: base + index }];
|
|
165
186
|
});
|
|
166
187
|
|
|
@@ -252,6 +273,7 @@ const wordsOf = (doc: ProseDocument): NumberWords => {
|
|
|
252
273
|
countWords: patterns("count-number"),
|
|
253
274
|
figureNouns: patterns("figure-noun"),
|
|
254
275
|
nameWords: patterns("number-name-word"),
|
|
276
|
+
nativeCounts: patterns("numeral-native-count"),
|
|
255
277
|
};
|
|
256
278
|
};
|
|
257
279
|
|
|
@@ -20,13 +20,15 @@ const DIGITS = /^\d+$/u;
|
|
|
20
20
|
/** 前の文の終わりを探す字数。見出しの行と、終わりの語が入れば足りる。 */
|
|
21
21
|
const LOOKBACK = 300;
|
|
22
22
|
const PLAIN_WORD = /^\p{L}{2,}$/u;
|
|
23
|
+
/** A worked sum (182 hours + 154 hours = 336 hours.): an operator, then an equals sign, each between spaces; Markdown may escape both. */
|
|
24
|
+
const WORKED_SUM = /\s\\?[+\-−–×÷*/]\s.*\s\\?=\s/u;
|
|
23
25
|
|
|
24
|
-
/**
|
|
26
|
+
/** 文の頭の数字。年、数字の後ろが小文字の語でないもの、言い終えていない行(見出しのような)、計算の式の行は無い。 */
|
|
25
27
|
export const openingNumeral = (text: string): string | undefined => {
|
|
26
28
|
const trimmed = text.trim();
|
|
27
29
|
const match = OPENING_NUMERAL.exec(trimmed);
|
|
28
30
|
const numeral = match?.groups?.["numeral"];
|
|
29
|
-
if (match === null || numeral === undefined || YEAR.test(numeral) || !SENTENCE_END.test(trimmed)) return undefined;
|
|
31
|
+
if (match === null || numeral === undefined || YEAR.test(numeral) || !SENTENCE_END.test(trimmed) || WORKED_SUM.test(trimmed)) return undefined;
|
|
30
32
|
return match[0];
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -50,6 +50,8 @@ export type OpenEndNames = {
|
|
|
50
50
|
readonly heads: readonly string[];
|
|
51
51
|
/** Every term the document defines (「秘密情報」): the word right after one (秘密情報等) widens a named thing, not an open list. */
|
|
52
52
|
readonly terms: ReadonlySet<string>;
|
|
53
|
+
/** The document's headings: a noun a heading names with the word (## 出願書類等の送付先) is the page's subject, not an open list. */
|
|
54
|
+
readonly headings: readonly string[];
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
const attached = (left: Token | undefined, right: Token | undefined): boolean =>
|
|
@@ -148,7 +150,8 @@ export const openEndNames = (doc: ProseDocument, words: readonly LexiconEntry[],
|
|
|
148
150
|
const occurrences = doc.sentences.flatMap((sentence) => words.flatMap((word) => occurrencesIn(sentence, word)));
|
|
149
151
|
const defined = occurrences.filter((occurrence) => definedInAside(doc.source, occurrence, statements)).map((occurrence) => nounOf(doc.source, occurrence));
|
|
150
152
|
const heads = occurrences.filter((occurrence) => headsItem(doc.source, occurrence, statements)).map((occurrence) => nounOf(doc.source, occurrence));
|
|
151
|
-
|
|
153
|
+
const headings = doc.sections.map((section) => section.heading).filter((heading) => heading.trim() !== "");
|
|
154
|
+
return { quoted: quotedNames(doc.source, words), defined: new Set(defined), heads: [...new Set(heads)], terms: definedTerms(doc), headings };
|
|
152
155
|
};
|
|
153
156
|
|
|
154
157
|
/** Whether a quoted name holds this occurrence: the text around it reads the whole name (当該責任追及等 holds 「責任追及等」). */
|
|
@@ -170,8 +173,15 @@ const partsHoldingWord = (source: string, occurrence: Occurrence): string[] => {
|
|
|
170
173
|
const followsTerm = (source: string, occurrence: Occurrence, terms: ReadonlySet<string>): boolean =>
|
|
171
174
|
occurrence.tokens.slice(occurrence.first, occurrence.range.start).some((token) => terms.has(source.slice(token.span.start, occurrence.start)));
|
|
172
175
|
|
|
176
|
+
/** Whether a heading writes the noun the word ends, whole from its first noun (出願書類等 in ## 出願書類等の送付先). */
|
|
177
|
+
const namedByHeading = (source: string, occurrence: Occurrence, headings: readonly string[]): boolean => {
|
|
178
|
+
const noun = source.slice(startOf(occurrence, occurrence.first), occurrence.end);
|
|
179
|
+
return occurrence.first < occurrence.range.start && headings.some((heading) => heading.includes(noun));
|
|
180
|
+
};
|
|
181
|
+
|
|
173
182
|
const isNamed = (source: string, occurrence: Occurrence, names: OpenEndNames): boolean =>
|
|
174
183
|
inQuotedName(source, occurrence, names.quoted) ||
|
|
184
|
+
namedByHeading(source, occurrence, names.headings) ||
|
|
175
185
|
followsTerm(source, occurrence, names.terms) ||
|
|
176
186
|
partsHoldingWord(source, occurrence).some((part) => names.defined.has(part) || names.heads.some((head) => head.startsWith(part)));
|
|
177
187
|
|
|
@@ -20,6 +20,16 @@ export const isNarrowedUse = (tokens: readonly Token[], at: number, pointers: re
|
|
|
20
20
|
return !pointers.some((pointer) => pointer.toLowerCase() === before.surface.toLowerCase());
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* A partitive picks some out of the kind: "some of these terms", "many of the services". The defined term names one
|
|
25
|
+
* thing or one set, so items picked from it are the ordinary word.
|
|
26
|
+
*/
|
|
27
|
+
export const isPartitiveUse = (tokens: readonly Token[], at: number, quantifiers: readonly string[]): boolean => {
|
|
28
|
+
const [quantifier, of, determiner] = [tokens[at - 3], tokens[at - 2], tokens[at - 1]];
|
|
29
|
+
if (quantifier === undefined || of?.surface.toLowerCase() !== "of" || determiner?.pos !== "DET") return false;
|
|
30
|
+
return quantifiers.some((word) => word.toLowerCase() === quantifier.surface.toLowerCase());
|
|
31
|
+
};
|
|
32
|
+
|
|
23
33
|
/**
|
|
24
34
|
* The use heads a phrase that names a kind of thing with "of" and a bare noun (certificates of deposit, letters of credit);
|
|
25
35
|
* "of" followed by an article, a pronoun or a name (the certificate of the Company) is the defined thing again.
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
type InContext,
|
|
26
26
|
type Uses,
|
|
27
27
|
} from "../word-use.ts";
|
|
28
|
-
import { titleCaseNameRuns } from "../title-case-name.ts";
|
|
28
|
+
import { bracketedTitleRuns, titleCaseNameRuns } from "../title-case-name.ts";
|
|
29
29
|
import { withoutQuotedSpellings, type Quoted } from "../quoted-spelling.ts";
|
|
30
30
|
import { teFormOf, withTeFormFullVerbs, type TeForm } from "../te-form-helper.ts";
|
|
31
31
|
import { citedSpans, isOpenIn, namesOf, patternsOf, type IsOpen, type Names } from "./orthographic-variant-open.ts";
|
|
@@ -267,7 +267,7 @@ const latinSpelling = (word: string): string =>
|
|
|
267
267
|
const latinWords = ({ sentence, isOpen, cited }: Place, skip: ReadonlySet<string>, joiners: readonly string[]): Placed[] => {
|
|
268
268
|
const { text } = sentence;
|
|
269
269
|
const acronyms = acronymsIn(text);
|
|
270
|
-
const names = titleCaseNameRuns(text, joiners);
|
|
270
|
+
const names = [...bracketedTitleRuns(text), ...titleCaseNameRuns(text, joiners)];
|
|
271
271
|
const quotedAt = (start: number, end: number): Pick<Placed, "quoted" | "name"> => {
|
|
272
272
|
if (isWithinAny(cited, { start, end })) return { quoted: "cited" };
|
|
273
273
|
const run = names.find(({ name }) => name.start <= start && end <= name.end);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// A code block whose lead-in says it holds what a program shows ("So, on day 3, we'd expect to see:"): the block is plain
|
|
2
|
+
// output, which is in no language. Pure; the lead-in words come from the output-lead-in lexicon.
|
|
3
|
+
|
|
4
|
+
const LEAD_IN_END = /[::]\s*$/u;
|
|
5
|
+
const LETTER = /\p{L}/u;
|
|
6
|
+
|
|
7
|
+
/** The last line with text before `offset`. */
|
|
8
|
+
const lineAbove = (source: string, offset: number): string =>
|
|
9
|
+
source
|
|
10
|
+
.slice(0, offset)
|
|
11
|
+
.split("\n")
|
|
12
|
+
.findLast((line) => line.trim() !== "") ?? "";
|
|
13
|
+
|
|
14
|
+
/** A Latin word stands whole (output, not outputs); 「表示され」 may sit inside a longer run. */
|
|
15
|
+
const holdsWord = (line: string, word: string): boolean => {
|
|
16
|
+
const at = line.indexOf(word);
|
|
17
|
+
if (at === -1) return false;
|
|
18
|
+
if (!/^[a-z]/u.test(word)) return true;
|
|
19
|
+
const whole = !LETTER.test(line.charAt(at - 1)) && !LETTER.test(line.charAt(at + word.length));
|
|
20
|
+
return whole || holdsWord(line.slice(at + word.length), word);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Whether the line just above the block at `offset` ends in a colon and says the block is output. */
|
|
24
|
+
export const afterOutputLeadIn = (source: string, offset: number, words: readonly string[]): boolean => {
|
|
25
|
+
const line = lineAbove(source, offset);
|
|
26
|
+
const lower = line.toLowerCase();
|
|
27
|
+
return LEAD_IN_END.test(line) && words.some((word) => word !== "" && holdsWord(lower, word.toLowerCase()));
|
|
28
|
+
};
|
|
@@ -6,7 +6,12 @@ import { quoteAt } from "./structure-tree.ts";
|
|
|
6
6
|
/** 最初に挙げた一覧(対応 OS は Windows と macOS)に無い名前を、後の文が同じ語で言う所(Linux にも対応)。 */
|
|
7
7
|
export const outsideAnnouncedList: Detector = (doc): Finding[] => {
|
|
8
8
|
const lowered = (id: string): Set<string> => new Set((doc.lexicons[id] ?? []).map((entry) => entry.pattern.toLowerCase()));
|
|
9
|
-
const words = {
|
|
9
|
+
const words = {
|
|
10
|
+
frames: doc.lexicons["enumeration-frame"] ?? [],
|
|
11
|
+
joiners: lowered("enumeration-joiner"),
|
|
12
|
+
negations: lowered("enumeration-negation"),
|
|
13
|
+
ordinals: lowered("ordinal-word"),
|
|
14
|
+
};
|
|
10
15
|
const statements = doc.sentences.flatMap((sentence) => listStatementsIn(sentence, words, doc.source));
|
|
11
16
|
const lines = linesOf(doc.source);
|
|
12
17
|
return outsideMembers(statements).map(({ member, announced }) => ({
|
|
@@ -57,6 +57,7 @@ import { inExcerpt } from "./quoted-excerpt.ts";
|
|
|
57
57
|
import { listContinues, walker, type Walk } from "./list-run.ts";
|
|
58
58
|
import { joinsUnfinished, repeatsConjunction } from "./list-joint.ts";
|
|
59
59
|
import { insideSentenceCaseTitle } from "./title-list.ts";
|
|
60
|
+
import { insideByline } from "./byline-list.ts";
|
|
60
61
|
|
|
61
62
|
const EMPTY: TokenRange = { start: 0, end: 0 };
|
|
62
63
|
|
|
@@ -383,12 +384,13 @@ export const listVerdicts = (tokens: readonly Token[], words: ListWords, source:
|
|
|
383
384
|
const breaks = dashBreaks(tokens, source);
|
|
384
385
|
const excerpt = inExcerpt(tokens, source, words.elision ?? []);
|
|
385
386
|
const inTitle = insideSentenceCaseTitle(tokens);
|
|
387
|
+
const inByline = insideByline(tokens);
|
|
386
388
|
const walk = walker();
|
|
387
389
|
return tokens.flatMap((token, at) => {
|
|
388
390
|
if (!isJudgedConjunction(token, at)) return [];
|
|
389
391
|
// 郵便番号で終わる住所のあとの and / or は、住所の行を区切る読点のあと。並びの読点ではない。
|
|
390
392
|
// 最後の読点のあとに前後を空けたダッシュがあれば(Washington, DC – The …)、読点はダッシュの前で閉じた日付行や見出しのもの。
|
|
391
|
-
const notList = sentence.inCitedTitle(at) || inTitle(at) || excerpt(at) || followsPostcode(source, token.span.start) || breaks[at] === true;
|
|
393
|
+
const notList = sentence.inCitedTitle(at) || inTitle(at) || inByline(at) || excerpt(at) || followsPostcode(source, token.span.start) || breaks[at] === true;
|
|
392
394
|
return [notList ? undefined : listAt(readItems(at), at, walk)];
|
|
393
395
|
});
|
|
394
396
|
};
|
|
@@ -55,7 +55,21 @@ const findingOf = (paragraph: Paragraph, opener: string, share: number, limit: n
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Whether the sentences after the opener's sentence go on to something new: a summary that leads into the next step
|
|
60
|
+
* (このように、…状況となっていた。その一方で、…を確認した。) sums up on purpose. A one-sentence paragraph does not go on.
|
|
61
|
+
*/
|
|
62
|
+
const goesOn = (earlier: Paragraph, later: Paragraph, limit: number): boolean => {
|
|
63
|
+
const rest = later.sentences.slice(1).flatMap((sentence) => sentence.tokens ?? []);
|
|
64
|
+
if (rest.length === 0) return false;
|
|
65
|
+
const { share, words } = repeatedShare(tokensOf(earlier), rest);
|
|
66
|
+
return words >= MIN_CONTENT_WORDS && share < limit;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Each paragraph that opens with a restating word and repeats at least limit percent of the previous paragraph's words,
|
|
71
|
+
* unless its later sentences go on to something new.
|
|
72
|
+
*/
|
|
59
73
|
export const paragraphRestatement: Detector = (doc, options): Finding[] => {
|
|
60
74
|
const openers = (doc.lexicons["restating-opener"] ?? []).map((entry) => entry.pattern);
|
|
61
75
|
return doc.paragraphs.flatMap((later, index): Finding[] => {
|
|
@@ -63,6 +77,7 @@ export const paragraphRestatement: Detector = (doc, options): Finding[] => {
|
|
|
63
77
|
const opener = openerOf(later.sentences[0]?.text ?? "", openers);
|
|
64
78
|
if (earlier === undefined || opener === undefined || !isNextTo(doc, earlier, later)) return [];
|
|
65
79
|
const { share, words } = repeatedShare(tokensOf(earlier), tokensAfterOpener(later, opener));
|
|
66
|
-
|
|
80
|
+
const restates = words >= MIN_CONTENT_WORDS && share >= options.limit && !goesOn(earlier, later, options.limit);
|
|
81
|
+
return restates ? [findingOf(later, opener, share, options.limit)] : [];
|
|
67
82
|
});
|
|
68
83
|
};
|
|
@@ -7,16 +7,28 @@ const wordsOf = (doc: ProseDocument, words: PersonWords["words"]): PersonWords =
|
|
|
7
7
|
notAfter: doc.lexicons["person-not-after"] ?? [],
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
const TOPIC = "は";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A self-reference set as a topic against another person's in the same sentence (僕は左を向く、君は右を向いても): the two
|
|
14
|
+
* people of an example, not the writer naming itself. others: the person-contrast word list.
|
|
15
|
+
*/
|
|
16
|
+
const contrastsPeople = (sentence: Sentence, mention: PersonMention, others: readonly string[]): boolean =>
|
|
17
|
+
sentence.text.startsWith(TOPIC, mention.at + mention.written.length) && others.some((other) => other !== "" && sentence.text.includes(`${other}${TOPIC}`));
|
|
18
|
+
|
|
10
19
|
/**
|
|
11
20
|
* One document naming itself (私たち / 弊社, 私 / 筆者) or its reader (you / one) two ways: the minority form of each slot.
|
|
12
|
-
* Sentences in another language than the document's are left out; quotations are left out by personMentions
|
|
21
|
+
* Sentences in another language than the document's are left out; quotations are left out by personMentions, and so is a
|
|
22
|
+
* self-reference contrasted with another person in one sentence (僕は…、君は…). A form the
|
|
13
23
|
* language package lists in person-other-sense (本社, also the head office) counts only where it is the usual form.
|
|
14
24
|
*/
|
|
15
25
|
export const personMix: Detector = (doc, options): Finding[] => {
|
|
16
26
|
const person = wordsOf(doc, options.lexicon ?? []);
|
|
27
|
+
const others = (doc.lexicons["person-contrast"] ?? []).map((entry) => entry.pattern);
|
|
17
28
|
const entries: { readonly sentence: Sentence; readonly mention: PersonMention }[] = doc.sentences
|
|
18
29
|
.filter((sentence) => sentence.embeddedLanguage === undefined)
|
|
19
|
-
.flatMap((sentence) => personMentions(sentence.text, person).map((mention) => ({ sentence, mention })))
|
|
30
|
+
.flatMap((sentence) => personMentions(sentence.text, person).map((mention) => ({ sentence, mention })))
|
|
31
|
+
.filter(({ sentence, mention }) => !contrastsPeople(sentence, mention, others));
|
|
20
32
|
const otherSenses = new Set((doc.lexicons["person-other-sense"] ?? []).map((entry) => entry.pattern));
|
|
21
33
|
return personMinorities(withoutOtherSenses(entries, otherSenses), options.limit).flatMap(({ odd, usual, of }) =>
|
|
22
34
|
odd.map(({ sentence, mention }) => ({
|