chaffjs 0.45.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/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/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 +54 -12
- 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/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/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/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/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-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/mark-shape.d.ts +1 -1
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +10 -3
- 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 +5 -0
- package/dist/detectors/middle-dot.d.ts.map +1 -1
- package/dist/detectors/middle-dot.js +27 -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/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/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/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 +6 -2
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +19 -3
- 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/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 +5 -1
- 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/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/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/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/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/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/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/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/all-caps-shouting.yaml +2 -2
- package/rules/bare-url-mix.yaml +2 -2
- package/rules/bold-density.yaml +2 -2
- package/rules/bold-label-list.yaml +4 -4
- 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/doubled-punctuation.yaml +2 -2
- package/rules/duration-mismatch.yaml +2 -2
- package/rules/email-subject-length.yaml +2 -2
- package/rules/empty-intensifier.yaml +2 -2
- package/rules/figure-reference-order.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/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-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-head.yaml +2 -2
- package/rules/request-without-deadline.yaml +2 -2
- package/rules/requirement-smell.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 +2 -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/unqualified-superlative.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/acronym-capitals.ts +30 -0
- 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 +74 -12
- 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/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/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/fact-consistency.ts +2 -2
- package/src/detectors/figure-order.ts +8 -2
- package/src/detectors/gram-heading.ts +15 -1
- package/src/detectors/heading-case.ts +7 -1
- 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/mark-shape.ts +13 -3
- package/src/detectors/measured-facts.ts +11 -4
- package/src/detectors/middle-dot.ts +32 -0
- package/src/detectors/missing-final-period.ts +14 -1
- package/src/detectors/name-variant.ts +2 -1
- 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/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/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 +18 -3
- package/src/detectors/sentence-ending.ts +13 -2
- package/src/detectors/sentence-parts.ts +20 -2
- 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 +4 -1
- package/src/detectors/superlative-context.ts +10 -0
- package/src/detectors/technical-docs.ts +5 -3
- 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/vague-density.ts +15 -2
- 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/recording-title.ts +16 -0
- package/src/sentence-load.ts +68 -2
- package/src/stray-space.ts +37 -6
- package/src/structure/due-column.ts +33 -0
- package/src/structure/generic-role.ts +8 -0
- package/src/structure/party-role.ts +3 -2
- package/src/title-case-name.ts +19 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const QUOTE_OPENERS: Readonly<Record<string, string>> = { "”": "“", "’": "‘", '"': '"', "」": "「", "』": "『" };
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether the line ends with a quotation it opens after words of its own (Revised “Getting It Right!”): the stop belongs to
|
|
5
|
+
* the quoted title, not to a sentence of the line's.
|
|
6
|
+
*/
|
|
7
|
+
export const endsWithQuotedTitle = (line: string): boolean => {
|
|
8
|
+
const text = line.trimEnd();
|
|
9
|
+
const opener = QUOTE_OPENERS[text.at(-1) ?? ""];
|
|
10
|
+
if (opener === undefined) return false;
|
|
11
|
+
const opened = text.slice(0, -1).lastIndexOf(opener);
|
|
12
|
+
return opened > 0 && text.slice(0, opened).trim() !== "";
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isInterview } from "../section-levels.ts";
|
|
2
|
+
import type { ProseDocument, Sentence } from "../plugin.ts";
|
|
3
|
+
|
|
4
|
+
// An interview's answers are speech set down (いえ、会社からの打診でした。…だいたい見当がつく。): one speaker mixes
|
|
5
|
+
// polite and plain sentences as people talk, as a transcript does. The interviewer's turns (――…?) and the writer's
|
|
6
|
+
// introduction before the first turn are written prose and stay compared. Pure.
|
|
7
|
+
|
|
8
|
+
const LEADING_EMPHASIS = /^[\s*_]+/u;
|
|
9
|
+
|
|
10
|
+
const opensWithMark = (text: string, marks: readonly string[]): boolean => {
|
|
11
|
+
const start = text.replace(LEADING_EMPHASIS, "");
|
|
12
|
+
return marks.some((mark) => start.startsWith(mark));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** The sentences of an interview's answers: paragraphs after the first interviewer's turn that are not turns themselves. */
|
|
16
|
+
export const spokenAnswerSentences = (doc: ProseDocument, marks: readonly string[]): Set<Sentence> => {
|
|
17
|
+
const starts = doc.paragraphs.map((paragraph) => paragraph.span.start);
|
|
18
|
+
if (!isInterview(doc.source, doc.sections, starts, marks)) return new Set();
|
|
19
|
+
const isTurn = doc.paragraphs.map((paragraph) => opensWithMark(doc.source.slice(paragraph.span.start, paragraph.span.end), marks));
|
|
20
|
+
const firstTurn = isTurn.indexOf(true);
|
|
21
|
+
return new Set(doc.paragraphs.flatMap((paragraph, index) => (index > firstTurn && isTurn[index] === false ? paragraph.sentences : [])));
|
|
22
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Detector, Finding, LengthUnit, Sentence, Span } from "../plugin.ts";
|
|
1
|
+
import type { Detector, Finding, LengthUnit, Paragraph, Section, Sentence, Span } from "../plugin.ts";
|
|
2
|
+
import { isFlattenedTableBlock } from "./sentence-parts.ts";
|
|
2
3
|
|
|
3
4
|
const HEAD_CHARS = 6;
|
|
4
5
|
const HEAD_WORDS = 3;
|
|
@@ -17,7 +18,14 @@ const headOf = (sentence: Sentence, unit: LengthUnit): string => {
|
|
|
17
18
|
const containerOf = (sentence: Sentence, lists: readonly Span[]): number =>
|
|
18
19
|
lists.filter((item) => item.start <= sentence.span.start && sentence.span.start < item.end).reduce((innermost, item) => Math.max(innermost, item.start), -1);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
/** 文の節。文の始まりを含む節の始まり。見出しを挟めば別の節で、FAQ の答えどうしのように別の話になる。 */
|
|
22
|
+
const sectionOf = (sentence: Sentence, sections: readonly Section[]): number =>
|
|
23
|
+
sections
|
|
24
|
+
.filter((section) => section.span.start <= sentence.span.start && sentence.span.start < section.span.end)
|
|
25
|
+
.reduce((innermost, section) => Math.max(innermost, section.span.start), -1);
|
|
26
|
+
|
|
27
|
+
/** 連なりが続ける範囲: 箇条書きの項目と節の組。 */
|
|
28
|
+
type Run = { readonly head: string; readonly container: string; readonly members: readonly Sentence[] };
|
|
21
29
|
|
|
22
30
|
/** 前の文と今の文のあいだで、箇条書きの項目が始まっているか。文を持たない項目(画像だけの - )も連なりを切る。 */
|
|
23
31
|
const listBetween = (previous: Sentence | undefined, sentence: Sentence, lists: readonly Span[]): boolean =>
|
|
@@ -26,11 +34,12 @@ const listBetween = (previous: Sentence | undefined, sentence: Sentence, lists:
|
|
|
26
34
|
/**
|
|
27
35
|
* 連なりは同じ入れ物の中でだけ続く。箇条書きの項目どうしは同じ形で並べるのが書き方そのもの(「1. SRE に関する…」「2. SRE に関する…」)で、
|
|
28
36
|
* 項目をまたぐと切る。一つの項目の中の段落や、地の文の中では、これまでどおり数える。箇条書きの前後の地の文も、箇条書きで切れる。
|
|
37
|
+
* 見出しを挟んでも切る(FAQ の答えごとの「Learn more about …」)。
|
|
29
38
|
*/
|
|
30
|
-
const runsOf = (sentences: readonly Sentence[], unit: LengthUnit, lists: readonly Span[]): Run[] =>
|
|
39
|
+
const runsOf = (sentences: readonly Sentence[], unit: LengthUnit, lists: readonly Span[], sections: readonly Section[]): Run[] =>
|
|
31
40
|
sentences.reduce<Run[]>((acc, sentence) => {
|
|
32
41
|
const head = headOf(sentence, unit);
|
|
33
|
-
const container = containerOf(sentence, lists)
|
|
42
|
+
const container = `${String(containerOf(sentence, lists))} ${String(sectionOf(sentence, sections))}`;
|
|
34
43
|
const last = acc.at(-1);
|
|
35
44
|
// 短すぎる書き出しは「同じ」と言えない。単位ぶん揃って初めて連なりと見る。
|
|
36
45
|
const full = unit === "char" ? head.length === HEAD_CHARS : head.split(" ").length === HEAD_WORDS;
|
|
@@ -40,9 +49,26 @@ const runsOf = (sentences: readonly Sentence[], unit: LengthUnit, lists: readonl
|
|
|
40
49
|
return acc;
|
|
41
50
|
}, []);
|
|
42
51
|
|
|
52
|
+
/** 一文だけの段落の文か。 */
|
|
53
|
+
const standsAlone = (sentence: Sentence, paragraphs: readonly Paragraph[]): boolean =>
|
|
54
|
+
paragraphs.some((paragraph) => paragraph.sentences.length === 1 && paragraph.sentences[0]?.span.start === sentence.span.start);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 連なりのどの文も一文だけの段落(「The government's 'How to rent' guide …」を案内ごとに一段落)なら、同じ型で並べた項目で、
|
|
58
|
+
* 印の無い箇条書き。同じ段落の中で続く書き出しだけを言う。
|
|
59
|
+
*/
|
|
60
|
+
const isEntryList = (run: Run, paragraphs: readonly Paragraph[]): boolean => run.members.every((sentence) => standsAlone(sentence, paragraphs));
|
|
61
|
+
|
|
62
|
+
/** 連なりの最初の文を含む段落が、行の区切りの落ちた表(升の文字がつながった段落)か。行ごとに同じ升で始まるのは表の形。 */
|
|
63
|
+
const inFlattenedTable = (run: Run, paragraphs: readonly Paragraph[], source: string): boolean => {
|
|
64
|
+
const start = run.members[0]?.span.start ?? -1;
|
|
65
|
+
const paragraph = paragraphs.find((candidate) => candidate.span.start <= start && start < candidate.span.end);
|
|
66
|
+
return paragraph !== undefined && isFlattenedTableBlock(source.slice(paragraph.span.start, paragraph.span.end));
|
|
67
|
+
};
|
|
68
|
+
|
|
43
69
|
export const repeatedHead: Detector = (doc, options): Finding[] =>
|
|
44
|
-
runsOf(doc.sentences, doc.lengthUnit, doc.listSpans)
|
|
45
|
-
.filter((run) => run.members.length > options.limit)
|
|
70
|
+
runsOf(doc.sentences, doc.lengthUnit, doc.listSpans, doc.sections)
|
|
71
|
+
.filter((run) => run.members.length > options.limit && !isEntryList(run, doc.paragraphs) && !inFlattenedTable(run, doc.paragraphs, doc.source))
|
|
46
72
|
.map((run) => ({
|
|
47
73
|
rule: "repeated-sentence-head",
|
|
48
74
|
severity: "warning",
|
|
@@ -15,6 +15,7 @@ export const REQUEST_LEXICONS = {
|
|
|
15
15
|
owner: "request-owner",
|
|
16
16
|
pointer: "request-pointer",
|
|
17
17
|
offer: "request-offer",
|
|
18
|
+
instruction: "request-instruction",
|
|
18
19
|
timing: "request-timing",
|
|
19
20
|
invitation: "request-invitation",
|
|
20
21
|
contact: "request-contact",
|
|
@@ -39,6 +40,7 @@ const wordsOf = (doc: ProseDocument): Words => ({
|
|
|
39
40
|
owner: patternsOf(doc.lexicons[REQUEST_LEXICONS.owner]),
|
|
40
41
|
pointer: patternsOf(doc.lexicons[REQUEST_LEXICONS.pointer]),
|
|
41
42
|
offer: patternsOf(doc.lexicons[REQUEST_LEXICONS.offer]),
|
|
43
|
+
instruction: patternsOf(doc.lexicons[REQUEST_LEXICONS.instruction]),
|
|
42
44
|
timing: patternsOf(doc.lexicons[REQUEST_LEXICONS.timing]),
|
|
43
45
|
invitation: patternsOf(doc.lexicons[REQUEST_LEXICONS.invitation]),
|
|
44
46
|
contact: patternsOf(doc.lexicons[REQUEST_LEXICONS.contact]),
|
|
@@ -103,7 +105,8 @@ const isProhibition = (text: string, endings: readonly Place[], words: Words): b
|
|
|
103
105
|
/**
|
|
104
106
|
* A request for an action: an action word next to a request ending (「確認してください」「please send」), not a condition
|
|
105
107
|
* (「ご不明な点があれば…ください」 is an offer), not an open offer to take the reader's questions (「ご質問はメールでお送りください」),
|
|
106
|
-
* not a pointer to where to read more (「詳細は資料をご確認ください」), not
|
|
108
|
+
* not a pointer to where to read more (「詳細は資料をご確認ください」), not the writer asking how to do something
|
|
109
|
+
* (「返送の方法を教えてください」 "let me know how to send it back"), not what an invitation is for (「登録をしにお越しください」),
|
|
107
110
|
* not a prohibition (「メールでは送らないでください」 "Please do not submit comments by email"),
|
|
108
111
|
* and not the way to reach the writer on a contact line (「ファックス番号:… 送信後、ご連絡ください」).
|
|
109
112
|
* The action has to be close to the ending, or a noun like 検討会 or 履修登録 earlier in the sentence would make one.
|
|
@@ -117,7 +120,7 @@ export const isRequest = (text: string, words: Words): boolean => {
|
|
|
117
120
|
endings.some((ending) => gapBetween(action, ending) <= ACTION_REACH) && !invitations.some((invitation) => invitedTo(comparable, action, invitation)),
|
|
118
121
|
);
|
|
119
122
|
if (!asked || holdsContactLine(text, words) || isProhibition(text, endings, words)) return false;
|
|
120
|
-
return ![words.condition, words.offer, words.pointer].some((patterns) => containsAny(text, patterns));
|
|
123
|
+
return ![words.condition, words.offer, words.instruction, words.pointer].some((patterns) => containsAny(text, patterns));
|
|
121
124
|
};
|
|
122
125
|
|
|
123
126
|
const NAMED = new Set(["PROPN"]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// A word run together from two long words where a conversion lost the space between them ("Includingspecified" where a
|
|
2
|
+
// table's cells met): the dictionary knows both halves and not the whole. Halves this long are not a coined compound
|
|
3
|
+
// (crowdwork), which joins short roots. Pure; the dictionary is the language package's word list.
|
|
4
|
+
|
|
5
|
+
/** The shortest half: below it, two words make a compound a writer may coin (crowdwork, workflow). */
|
|
6
|
+
const MIN_HALF = 6;
|
|
7
|
+
|
|
8
|
+
/** Whether `word` is two dictionary words of at least MIN_HALF letters each run together, and no dictionary word itself. */
|
|
9
|
+
export const isRunTogether = (word: string, dictionary: ReadonlySet<string>): boolean => {
|
|
10
|
+
const lower = word.toLowerCase();
|
|
11
|
+
if (!/^\p{L}+$/u.test(lower) || dictionary.has(lower)) return false;
|
|
12
|
+
return Array.from({ length: lower.length - MIN_HALF * 2 + 1 }, (_unused, index) => index + MIN_HALF).some(
|
|
13
|
+
(cut) => dictionary.has(lower.slice(0, cut)) && dictionary.has(lower.slice(cut)),
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -4,6 +4,8 @@ import { isWithinAny, quotedIn } from "../quoted-span.ts";
|
|
|
4
4
|
import { entryOpens } from "./lexicon-match.ts";
|
|
5
5
|
import { laterAlternatives, laterJoined } from "../alternative-words.ts";
|
|
6
6
|
import { isContrastiveGa } from "./adversative-ga.ts";
|
|
7
|
+
import { isFlattenedTable } from "./sentence-parts.ts";
|
|
8
|
+
import { bareListCommas } from "./bare-word-list.ts";
|
|
7
9
|
|
|
8
10
|
type TokenTest = (token: Token, at: number, tokens: readonly Token[]) => boolean;
|
|
9
11
|
|
|
@@ -63,7 +65,8 @@ const largestItem = (sentence: Sentence, counted: readonly Token[]): readonly To
|
|
|
63
65
|
/**
|
|
64
66
|
* A sentence holding more than limit tokens written as one of the lexicon's words (the suffix 的). The options of one choice
|
|
65
67
|
* (連続的か断続的か、一時的) and a joined pair (信仰的主観的) count once: each names one point. A list written inside the sentence
|
|
66
|
-
* (①…、②…) is counted item by item, as each item is a point of its own.
|
|
68
|
+
* (①…、②…) is counted item by item, as each item is a point of its own. A table a converter flattened into one sentence
|
|
69
|
+
* is cells, not the writer's sentence (the same 経常的 in each row).
|
|
67
70
|
*/
|
|
68
71
|
export const sentenceWordCount: Detector = (doc, options): Finding[] => {
|
|
69
72
|
const words = wordsOf(options.lexicon);
|
|
@@ -81,6 +84,7 @@ export const sentenceWordCount: Detector = (doc, options): Finding[] => {
|
|
|
81
84
|
const isCounted: TokenTest = (token, at, tokens) => words.has(token.surface) && !laterOf(tokens).has(at);
|
|
82
85
|
const fixedTerms = doc.lexicons[FIXED_TERM_LEXICON] ?? [];
|
|
83
86
|
return doc.sentences.flatMap((sentence) => {
|
|
87
|
+
if (isFlattenedTable(sentence.text)) return [];
|
|
84
88
|
const counted = largestItem(sentence, countedTokens(sentence, isCounted, fixedTerms));
|
|
85
89
|
return counted.length > options.limit ? [findingOf(sentence, counted, options.limit)] : [];
|
|
86
90
|
});
|
|
@@ -145,10 +149,21 @@ export const separatesItems = (at: number, tokens: readonly Token[]): boolean =>
|
|
|
145
149
|
return betweenQuotations(at, tokens) || (isNominal(itemEnd) && startsNoun(at, tokens, itemEnd));
|
|
146
150
|
};
|
|
147
151
|
|
|
148
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* A sentence cut by more than limit of the lexicon's commas (読点). Commas between listed nouns, and between the short bare words
|
|
154
|
+
* of a list, are not counted. A table a converter flattened into one sentence is cells, not the writer's sentence.
|
|
155
|
+
*/
|
|
149
156
|
export const sentenceCommaCount: Detector = (doc, options): Finding[] => {
|
|
150
157
|
const commas = wordsOf(options.lexicon);
|
|
151
|
-
|
|
158
|
+
const isComma = (token: Token): boolean => commas.has(token.surface);
|
|
159
|
+
const listed = new WeakMap<readonly Token[], ReadonlySet<number>>();
|
|
160
|
+
const listedIn = (tokens: readonly Token[]): ReadonlySet<number> => {
|
|
161
|
+
const known = listed.get(tokens) ?? bareListCommas(tokens, isComma);
|
|
162
|
+
listed.set(tokens, known);
|
|
163
|
+
return known;
|
|
164
|
+
};
|
|
165
|
+
const counts: TokenTest = (token, at, tokens) => isComma(token) && !separatesItems(at, tokens) && !listedIn(tokens).has(at);
|
|
166
|
+
return sentencesOver({ ...doc, sentences: doc.sentences.filter((sentence) => !isFlattenedTable(sentence.text)) }, options.limit, counts);
|
|
152
167
|
};
|
|
153
168
|
|
|
154
169
|
const CONJUNCTIVE = "SCONJ";
|
|
@@ -5,9 +5,11 @@ import { isRunInLabel } from "./run-in-label.ts";
|
|
|
5
5
|
import { noticeSentences } from "./notice-paragraph.ts";
|
|
6
6
|
import { separatePartSentences, trailingPartSentences } from "./register-separate-part.ts";
|
|
7
7
|
import { askerSentences } from "./asker-voice.ts";
|
|
8
|
+
import { recordingCaptionSentences } from "../recording-title.ts";
|
|
8
9
|
import { licenceNoticeSentences } from "./licence-notice.ts";
|
|
9
10
|
import { chronologyRows } from "../chronology-rows.ts";
|
|
10
11
|
import { isNeutralPlainShape } from "./register-neutral-shape.ts";
|
|
12
|
+
import { spokenAnswerSentences } from "./register-interview.ts";
|
|
11
13
|
import { contactBlockSentences, fieldValueSentences, labelledQuoteSentences, referenceNoteSentences, tableCellSentences } from "./register-set-apart.ts";
|
|
12
14
|
import { endsInSetGreeting, isDeclaration, isExclamation, isTakenUp } from "./register-voice.ts";
|
|
13
15
|
import { entriesForGenre } from "../lexicon-genres.ts";
|
|
@@ -22,6 +24,7 @@ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span, To
|
|
|
22
24
|
* 年表の行(1921年信号装置の製作を開始する。)も、文書の文体と揃えない書き方なので数えない。
|
|
23
25
|
* 断り書きの段落(…ご了承ください。)も、本文とは別の声で書く決まり文句なので数えない(notice-paragraph.ts)。
|
|
24
26
|
* 読み手の相談や質問を載せる節(【相談事例等】)の文は尋ねた人の言葉のままなので数えない(asker-voice.ts)。
|
|
27
|
+
* 動画の題(…(3分00秒))の下の説明も、動画の言葉のままなので数えない(recording-title.ts)。
|
|
25
28
|
* 文書の最後に掲載先が付けた利用条件の断り書き(…ライセンスの下に提供されています。)も数えない(licence-notice.ts)。
|
|
26
29
|
* 札を付けて引いた言葉(例:…。Q: …?)、印を付けた札の行の下の記入欄の値(■ 調査目的\n…とする。)、
|
|
27
30
|
* 〒や電話の行のある問い合わせ先の段落も数えない(register-set-apart.ts)。
|
|
@@ -33,6 +36,7 @@ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span, To
|
|
|
33
36
|
* 丁寧な形でしか言わない挨拶(お疲れ様でした。)、演説の決意の言い切り(二度と繰り返さない。)、
|
|
34
37
|
* 次の文が「そんな」「これだけ」で受ける場面の書き出し、「!」で終わる叫び(わかるかっ!)も quiet(register-voice.ts)。
|
|
35
38
|
* ※で始まる行の注記と、行に並べ直した表のセル(制限なし。)は、どちらの調子でも quiet(register-set-apart.ts)。
|
|
39
|
+
* インタビューの答え(聞き手の「――」の後の段落)は話した言葉なので quiet(register-interview.ts)。
|
|
36
40
|
* 数には入れる。数から外すと、常体を何度も使う文書(演説)で少数派が閾値を下回り、残りの常体の文が新たに指されてしまう。
|
|
37
41
|
*/
|
|
38
42
|
type Entry = { readonly sentence: Sentence; readonly register: Register; readonly group: number | undefined; readonly quiet: boolean };
|
|
@@ -101,12 +105,19 @@ export const judgedSentences = (doc: ProseDocument, polite: readonly LexiconEntr
|
|
|
101
105
|
const words = endingWords(doc, polite, genre);
|
|
102
106
|
const lists = doc.lists.map((list) => list.span);
|
|
103
107
|
const rows = chronologyRows(doc);
|
|
104
|
-
const asked = askerSentences(doc.sections, doc.lexicons["asker-heading"] ?? []);
|
|
108
|
+
const asked = new Set([...askerSentences(doc.sections, doc.lexicons["asker-heading"] ?? []), ...recordingCaptionSentences(doc.sections)]);
|
|
105
109
|
const licence = licenceNoticeSentences(doc, doc.lexicons["licence-word"] ?? []);
|
|
106
110
|
const quoted = labelledQuoteSentences(doc.paragraphs, doc.source, doc.lexicons["quote-label"] ?? []);
|
|
107
111
|
const fields = fieldValueSentences(doc.sentences, doc.source);
|
|
108
112
|
const contact = contactBlockSentences(doc.sentences, doc.source, doc.lexicons["contact-line-opener"] ?? []);
|
|
109
|
-
const asides = new Set([
|
|
113
|
+
const asides = new Set([
|
|
114
|
+
...referenceNoteSentences(doc.sentences, doc.source),
|
|
115
|
+
...tableCellSentences(doc.sentences, doc.source),
|
|
116
|
+
...spokenAnswerSentences(
|
|
117
|
+
doc,
|
|
118
|
+
(doc.lexicons["interviewer-mark"] ?? []).map((entry) => entry.pattern),
|
|
119
|
+
),
|
|
120
|
+
]);
|
|
110
121
|
const all = doc.sentences.flatMap((sentence, index): { sentence: Sentence; register: Register; quiet: boolean }[] => {
|
|
111
122
|
if (
|
|
112
123
|
!isClosed(sentence) ||
|
|
@@ -83,6 +83,24 @@ const UNIT_HEADER = /[((](?:%|%|人|名|株|件|台|社|円|千円|百万円
|
|
|
83
83
|
/** Fewer unit headers than this are a sentence that names a unit or two, not a table's header row. */
|
|
84
84
|
const MIN_UNIT_HEADERS = 3;
|
|
85
85
|
|
|
86
|
-
/**
|
|
86
|
+
/** Ditto marks in a row (―〃〃〃): cells that repeat the row above, which only a table has. */
|
|
87
|
+
const DITTO_CELLS = /〃\s*〃/u;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Whether a sentence is a table a converter flattened: glued numbers, rows opened by dates, a header row of cells closed by
|
|
91
|
+
* units, or ditto cells.
|
|
92
|
+
*/
|
|
87
93
|
export const isFlattenedTable = (text: string): boolean =>
|
|
88
|
-
flattenedTableParts(text) !== undefined || (text.match(UNIT_HEADER)?.length ?? 0) >= MIN_UNIT_HEADERS;
|
|
94
|
+
flattenedTableParts(text) !== undefined || (text.match(UNIT_HEADER)?.length ?? 0) >= MIN_UNIT_HEADERS || DITTO_CELLS.test(text);
|
|
95
|
+
|
|
96
|
+
/** A decimal cell run in between a bracketed cell and the next cell's word ((日本)100.0自動車関連): where one row's cells meet. */
|
|
97
|
+
const GLUED_DECIMAL_CELL = /[))]\d{1,3}\.\d+(?=\p{L})/gu;
|
|
98
|
+
/** Fewer such joins than this are a version or a figure after a name ((RSL)1.0), not the rows of a table. */
|
|
99
|
+
const MIN_GLUED_ROWS = 3;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Whether a block of text (a paragraph) is a table a converter flattened: a flattened table by the sentence signals, or a
|
|
103
|
+
* decimal cell glued between a bracketed cell and the next cell in row after row. Its sentences are rows cut at the
|
|
104
|
+
* stops inside cells, not the writer's sentences.
|
|
105
|
+
*/
|
|
106
|
+
export const isFlattenedTableBlock = (text: string): boolean => isFlattenedTable(text) || (text.match(GLUED_DECIMAL_CELL)?.length ?? 0) >= MIN_GLUED_ROWS;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Detector, Finding } from "../plugin.ts";
|
|
1
|
+
import type { Detector, Finding, Span } from "../plugin.ts";
|
|
2
|
+
import { referenceListSpans } from "../reference-lists.ts";
|
|
2
3
|
import { quoteAround } from "./quote-around.ts";
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -14,15 +15,34 @@ const DOTS_REACH = 3;
|
|
|
14
15
|
|
|
15
16
|
const isSpacedEllipsis = (text: string, space: number): boolean => SPACED_DOTS.test(text.slice(space + 1, space + 1 + DOTS_REACH));
|
|
16
17
|
|
|
18
|
+
/** 文献一覧で、値を落とした欄の名前("ISBN ,")。大文字だけの名前のすぐ後ろが読点になるのは、文献の書式が空の値を埋めたところ。 */
|
|
19
|
+
const EMPTY_FIELD_LABEL = /(?:^|[^\p{L}])\p{Lu}{2,}$/u;
|
|
20
|
+
|
|
21
|
+
/** 欄の名前を探す字数。どの欄の名前よりも長い。 */
|
|
22
|
+
const LABEL_REACH = 16;
|
|
23
|
+
|
|
24
|
+
const isEmptyField = (text: string, space: number, references: readonly Span[]): boolean =>
|
|
25
|
+
text.charAt(space + 1) === "," &&
|
|
26
|
+
references.some((span) => span.start <= space && space < span.end) &&
|
|
27
|
+
EMPTY_FIELD_LABEL.test(text.slice(Math.max(0, space - LABEL_REACH), space));
|
|
28
|
+
|
|
17
29
|
/**
|
|
18
30
|
* 本文(prose)の中の、句読点の前の空白の位置。prose はコード・URL・強調の印を空白で覆うので、覆ってできた空白("*word* ." の "*")は
|
|
19
31
|
* 書き手が打った空白ではない。source の同じ位置も空白のときだけ数える。
|
|
20
32
|
*/
|
|
21
|
-
export const spacesBeforePunctuation = (prose: string, source: string): number[] =>
|
|
22
|
-
[...prose.matchAll(SPACED_MARK)]
|
|
33
|
+
export const spacesBeforePunctuation = (prose: string, source: string, references: readonly Span[] = []): number[] =>
|
|
34
|
+
[...prose.matchAll(SPACED_MARK)]
|
|
35
|
+
.map((match) => match.index)
|
|
36
|
+
.filter((space) => source.charAt(space) === " " && !isSpacedEllipsis(prose, space) && !isEmptyField(prose, space, references));
|
|
37
|
+
|
|
38
|
+
const referencesOf = (source: string, headingWords: readonly { readonly pattern: string }[] | undefined): Span[] =>
|
|
39
|
+
referenceListSpans(
|
|
40
|
+
source,
|
|
41
|
+
(headingWords ?? []).map((entry) => entry.pattern),
|
|
42
|
+
);
|
|
23
43
|
|
|
24
44
|
export const spaceBeforePunctuation: Detector = (doc): Finding[] =>
|
|
25
|
-
spacesBeforePunctuation(doc.prose ?? doc.source, doc.source).map((space) => ({
|
|
45
|
+
spacesBeforePunctuation(doc.prose ?? doc.source, doc.source, referencesOf(doc.source, doc.lexicons["reference-list-heading"])).map((space) => ({
|
|
26
46
|
rule: "",
|
|
27
47
|
severity: "warning",
|
|
28
48
|
line: 0,
|
|
@@ -3,7 +3,7 @@ import { minorityStyle } from "../orthography.ts";
|
|
|
3
3
|
import { isClosed } from "../sentence-shape.ts";
|
|
4
4
|
import { phraseJoints, type Joint, type JointKind } from "../stray-space.ts";
|
|
5
5
|
|
|
6
|
-
const KINDS: readonly JointKind[] = ["between-phrases", "inside-phrase"];
|
|
6
|
+
const KINDS: readonly JointKind[] = ["between-phrases", "inside-phrase", "inside-word"];
|
|
7
7
|
|
|
8
8
|
type Quoted = Joint & { readonly quote: string };
|
|
9
9
|
|
|
@@ -7,6 +7,7 @@ import { weekdayMismatches } from "../structure/weekday.ts";
|
|
|
7
7
|
import { revisionAnchors } from "./revision-date.ts";
|
|
8
8
|
import { documentDateOf } from "./document-date.ts";
|
|
9
9
|
import { dateOrderBreaks } from "../structure/date-order.ts";
|
|
10
|
+
import { scheduledPoints } from "../structure/due-column.ts";
|
|
10
11
|
import { totalMismatches, type Amount } from "../structure/total.ts";
|
|
11
12
|
import { isListedTotal, isPeriodTotalLine, isTotalLikeLine, isTotalLine } from "../structure/total-line.ts";
|
|
12
13
|
import { proseTotalMismatches } from "../structure/prose-total.ts";
|
|
@@ -174,15 +175,17 @@ export const datedPoints = (tree: NonNullable<ProseDocument["structure"]>): { of
|
|
|
174
175
|
export const dateOrder: Detector = (doc): Finding[] =>
|
|
175
176
|
doc.structure === undefined
|
|
176
177
|
? []
|
|
177
|
-
: dateOrderBreaks(doc.source, datedPoints(doc.structure), doc.markup?.headings ?? []).map(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
: dateOrderBreaks(doc.source, scheduledPoints(doc.source, datedPoints(doc.structure), patternsOf(doc, "action-due-label")), doc.markup?.headings ?? []).map(
|
|
179
|
+
(issue) => ({
|
|
180
|
+
rule: "date-order",
|
|
181
|
+
severity: "warning",
|
|
182
|
+
line: 0,
|
|
183
|
+
column: 0,
|
|
184
|
+
quote: quoteAt(doc.source, issue.offset),
|
|
185
|
+
values: { ...withReadableDates(issue.values, ["date", "previous", "next"], readableDates(doc)), offset: issue.offset },
|
|
186
|
+
...("next" in issue.values ? { variant: "first" } : {}),
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
186
189
|
|
|
187
190
|
/** 木の数量を、原文の位置と一緒に並べる。 */
|
|
188
191
|
export const amountsOf = (tree: NonNullable<ProseDocument["structure"]>): Amount[] =>
|
|
@@ -5,7 +5,7 @@ import { dateStampIndexes, stampCandidates } from "../date-stamp.ts";
|
|
|
5
5
|
import { inDocumentOrder } from "../structure/issues.ts";
|
|
6
6
|
import { preambleParagraphs } from "../preamble-paragraphs.ts";
|
|
7
7
|
import { isTooLongParagraph, labelledBlocks, lostLineBreaks, opensWithFusedHeading } from "../paragraph-length.ts";
|
|
8
|
-
import { bodySectionOf } from "../body-section.ts";
|
|
8
|
+
import { bodySectionOf, hasOnlyMatterHeadings } from "../body-section.ts";
|
|
9
9
|
import { threeShare } from "../rule-of-three.ts";
|
|
10
10
|
import { isInterview, sectionLevels } from "../section-levels.ts";
|
|
11
11
|
|
|
@@ -171,10 +171,13 @@ const withoutDateStamps = (doc: ProseDocument, paragraphs: readonly Paragraph[])
|
|
|
171
171
|
/**
|
|
172
172
|
* 本題に入るまでが長い。業務文書では、読み手は結論を探しに来ている。
|
|
173
173
|
* 「本題」は最初の中見出し。中見出しが無い文書では、rule が requires の headings で動かず、動かなかった理由が出る。
|
|
174
|
+
* 見出しが末尾の問い合わせ先や参考文献だけの文書(手紙の形の諮問)も、本題の見出しが無いので測らない。
|
|
174
175
|
*/
|
|
175
176
|
export const preambleLength: Detector = (doc, options): Finding[] => {
|
|
176
177
|
const body = bodySectionOf(doc.sections);
|
|
177
178
|
if (body === undefined) return [];
|
|
179
|
+
const matter = (doc.lexicons["unnumbered-heading"] ?? []).map((entry) => entry.pattern.toLowerCase());
|
|
180
|
+
if (hasOnlyMatterHeadings(doc.sections, body, matter)) return [];
|
|
178
181
|
const noteMarks = (doc.lexicons["note-mark"] ?? []).map((entry) => entry.pattern);
|
|
179
182
|
const all = preambleParagraphs(doc.paragraphs, body.span.start, doc.source, noteMarks);
|
|
180
183
|
if (all.length <= options.limit) return [];
|
|
@@ -14,6 +14,8 @@ export type Context = {
|
|
|
14
14
|
readonly parts: Lexicon;
|
|
15
15
|
/** 前に名指した名詞の代わりに立つ語(one・ones)。 */
|
|
16
16
|
readonly proForms: Lexicon;
|
|
17
|
+
/** 仮定を開く語(if・もし)。 */
|
|
18
|
+
readonly conditions: Lexicon;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
/** 語彙表の語が最上級まで届く語の数。これより離れた動詞は、間に別の目的語や節がある。 */
|
|
@@ -36,6 +38,7 @@ export const contextOf = (lexicons: Readonly<Record<string, Lexicon>>): Context
|
|
|
36
38
|
viewpoints: lexicons["superlative-viewpoint"] ?? [],
|
|
37
39
|
parts: lexicons["superlative-part"] ?? [],
|
|
38
40
|
proForms: lexicons["superlative-pro-form"] ?? [],
|
|
41
|
+
conditions: lexicons["superlative-condition"] ?? [],
|
|
39
42
|
});
|
|
40
43
|
|
|
41
44
|
const isPunct = (token: Token | undefined): boolean => token === undefined || token.pos === "PUNCT";
|
|
@@ -61,6 +64,13 @@ export const sought = (sentence: Sentence, range: TokenRange, goals: Lexicon): b
|
|
|
61
64
|
return goals.some((entry) => (entry.position === "after" ? after(sentence, range, entry) : endsBefore(tokens, range, entry, GOAL_REACH)));
|
|
62
65
|
};
|
|
63
66
|
|
|
67
|
+
/**
|
|
68
|
+
* 最上級が、同じ節の前で開いた仮定の中にあるか(If spreadsheet formulas are the most prolific government code, …・もし最も速い
|
|
69
|
+
* 案が通るなら)。仮に置いたもので、何かが一番だという主張ではない。
|
|
70
|
+
*/
|
|
71
|
+
export const supposed = (tokens: readonly Token[], range: TokenRange, conditions: Lexicon): boolean =>
|
|
72
|
+
conditions.some((entry) => endsBefore(tokens, range, entry, range.start));
|
|
73
|
+
|
|
64
74
|
const isWord = (token: Token | undefined, words: Lexicon): boolean =>
|
|
65
75
|
token !== undefined && words.some((entry) => entry.pattern.toLowerCase() === token.surface.toLowerCase());
|
|
66
76
|
|
|
@@ -7,6 +7,7 @@ import { opensAsNounPhrase } from "./nominal-step.ts";
|
|
|
7
7
|
import { quoteAt } from "./structure-tree.ts";
|
|
8
8
|
import { escapeRegExp } from "../orthography.ts";
|
|
9
9
|
import { isFormatTemplate } from "../format-template.ts";
|
|
10
|
+
import { afterOutputLeadIn } from "./output-lead-in.ts";
|
|
10
11
|
import type { Detector, Finding, ProseDocument, Span, Token } from "../plugin.ts";
|
|
11
12
|
|
|
12
13
|
const patternsOf = (doc: ProseDocument, id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
@@ -37,11 +38,12 @@ export const untaggedFewer = (fences: readonly CodeFence[], limit: number): read
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
export const codeFenceLanguage: Detector = (doc, options): Finding[] => {
|
|
41
|
+
const outputWords = patternsOf(doc, "output-lead-in");
|
|
40
42
|
const fences = codeFences(doc.source).filter(wantsLanguage);
|
|
41
43
|
const tagged = fences.filter((fence) => fence.language !== "").length;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
44
|
+
// A block of plain output (after "we'd expect to see:") is in no language: it still counts, but is not pointed at.
|
|
45
|
+
const reported = untaggedFewer(fences, options.limit).filter((fence) => !afterOutputLeadIn(doc.source, fence.start, outputWords));
|
|
46
|
+
return reported.map((fence) => finding(doc, "code-fence-language-mix", fence.start, { tagged, untagged: fences.length - tagged }));
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
export type PromptStyle = "prompt" | "bare" | undefined;
|
|
@@ -2,11 +2,13 @@ import { hasParticle, isClosed, lastContent } from "../sentence-shape.ts";
|
|
|
2
2
|
import { isWithinAny, quotedIn } from "../quoted-span.ts";
|
|
3
3
|
import { chronologyRows } from "../chronology-rows.ts";
|
|
4
4
|
import { externalLinkTitleSpans } from "../link-title.ts";
|
|
5
|
-
import type { Detector, Finding, Span, Token } from "../plugin.ts";
|
|
5
|
+
import type { Detector, Finding, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
|
|
6
6
|
import { countedTokens, uncountedWordsOf, type UncountedWords } from "../uncounted-particles.ts";
|
|
7
7
|
import { boundWordParticles } from "../bound-word-particles.ts";
|
|
8
8
|
import { setPhraseParticles } from "../set-phrase-particles.ts";
|
|
9
9
|
import { noteSentences } from "../note-paragraphs.ts";
|
|
10
|
+
import { labelledNoteSentences } from "../labelled-note-paragraphs.ts";
|
|
11
|
+
import { listLeadSentences } from "../list-lead-sentence.ts";
|
|
10
12
|
import { documentNameSpans } from "./particle-run-names.ts";
|
|
11
13
|
import { namedLongForms } from "./particle-run-long-forms.ts";
|
|
12
14
|
import { quotedNameSpans, quotedNames } from "./particle-run-quoted-names.ts";
|
|
@@ -24,11 +26,24 @@ const isDependent = (token: Token): boolean => token.features?.["NounType"] ===
|
|
|
24
26
|
|
|
25
27
|
const inside = (span: Span, spans: readonly Span[]): boolean => spans.some((other) => span.start >= other.start && span.start < other.end);
|
|
26
28
|
|
|
29
|
+
/** 表や図の注の段落の頭の語((注1)の「注」)。 */
|
|
30
|
+
const NOTE_LABEL_LEXICON = "note-paragraph-label";
|
|
31
|
+
|
|
32
|
+
/** 名詞で止めるのが書き方の文: 年表の行、注や文献の一覧、(注1)で始まる表の注、箇条書きへ渡す文(以下のとおり説明。)。 */
|
|
33
|
+
const clippedByForm = (doc: ProseDocument): ReadonlySet<Sentence> => {
|
|
34
|
+
const patterns = (id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
35
|
+
return new Set([
|
|
36
|
+
...chronologyRows(doc),
|
|
37
|
+
...noteSentences(doc.source, doc.paragraphs),
|
|
38
|
+
...labelledNoteSentences(doc.source, doc.paragraphs, patterns(NOTE_LABEL_LEXICON), patterns("note-mark")),
|
|
39
|
+
...listLeadSentences(doc.sentences, doc.lists, doc.source),
|
|
40
|
+
]);
|
|
41
|
+
};
|
|
42
|
+
|
|
27
43
|
export const nounEnding: Detector = (doc, options): Finding[] => {
|
|
28
|
-
const
|
|
29
|
-
const notes = noteSentences(doc.source, doc.paragraphs);
|
|
44
|
+
const clipped = clippedByForm(doc);
|
|
30
45
|
const ended = doc.sentences.filter((sentence) => {
|
|
31
|
-
if (inside(sentence.span, doc.listSpans) ||
|
|
46
|
+
if (inside(sentence.span, doc.listSpans) || clipped.has(sentence) || !isClosed(sentence) || !hasParticle(sentence)) return false;
|
|
32
47
|
const last = lastContent(sentence);
|
|
33
48
|
return last !== undefined && NOMINAL.has(last.pos) && !isDependent(last);
|
|
34
49
|
});
|
|
@@ -16,6 +16,7 @@ type Bracket = { readonly open: string; readonly close: string; readonly family:
|
|
|
16
16
|
|
|
17
17
|
const BRACKETS: readonly Bracket[] = [
|
|
18
18
|
{ open: "「", close: "」", family: "kagi" },
|
|
19
|
+
{ open: "「", close: "」", family: "kagi" },
|
|
19
20
|
{ open: "『", close: "』", family: "double-kagi" },
|
|
20
21
|
{ open: "(", close: ")", family: "round" },
|
|
21
22
|
{ open: "(", close: ")", family: "round" },
|
|
@@ -51,6 +52,12 @@ export type BracketProblem = {
|
|
|
51
52
|
type Open = { readonly bracket: Bracket; readonly offset: number };
|
|
52
53
|
type Scan = { readonly open: Open[]; readonly problems: BracketProblem[] };
|
|
53
54
|
|
|
55
|
+
/** 半角の「「」」。幅の違いは hankaku-kana が指すので、全角と組んでも幅の違いとしては指さない。 */
|
|
56
|
+
const HALFWIDTH_KAGI: ReadonlySet<string> = new Set(["「", "」"]);
|
|
57
|
+
|
|
58
|
+
const isWidthSlip = (opened: Bracket, closing: Bracket): boolean =>
|
|
59
|
+
opened !== closing && !HALFWIDTH_KAGI.has(opened.open) && !HALFWIDTH_KAGI.has(closing.close);
|
|
60
|
+
|
|
54
61
|
const unclosedOf = (entry: Open): BracketProblem => ({ kind: "unclosed", offset: entry.offset, mark: entry.bracket.open });
|
|
55
62
|
|
|
56
63
|
const closeWith = (scan: Scan, text: string, bracket: Bracket, offset: number): void => {
|
|
@@ -69,7 +76,8 @@ const closeWith = (scan: Scan, text: string, bracket: Bracket, offset: number):
|
|
|
69
76
|
.slice(1)
|
|
70
77
|
.filter((inner) => !(QUOTATIONS.has(bracket.family) && inner.offset === offset - 1))
|
|
71
78
|
.forEach((inner) => scan.problems.push(unclosedOf(inner)));
|
|
72
|
-
if (opened !== undefined && opened.bracket
|
|
79
|
+
if (opened !== undefined && isWidthSlip(opened.bracket, bracket))
|
|
80
|
+
scan.problems.push({ kind: "mismatch", offset, mark: bracket.close, partner: opened.bracket.open });
|
|
73
81
|
};
|
|
74
82
|
|
|
75
83
|
/** 段落(空行で区切った塊)の最初の字。 */
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// marks a word as one of its terms; a term with that prefix and no definition leaves the reader asking what it is.
|
|
4
4
|
// Only the document's own references (本条, 本契約: self-reference-noun and document-kind) are left. Pure; the parts of
|
|
5
5
|
// speech decide where a prefix is a prefix (本 in 本成果物) and not part of a word (本人, 本日).
|
|
6
|
+
import { isRunTogether } from "./run-together.ts";
|
|
6
7
|
import { definedTerms } from "../structure/definition-use.ts";
|
|
7
8
|
import { prefixGroupsOf, prefixVariants } from "../structure/term-prefix.ts";
|
|
8
9
|
import { quoteAt } from "./structure-tree.ts";
|
|
@@ -193,5 +194,8 @@ export const undefinedTerm: Detector = (doc): Finding[] => {
|
|
|
193
194
|
groupSuffixes: patternsOf(doc, "defined-term-group-suffix"),
|
|
194
195
|
inheritsDefinitions: patternsOf(doc, "definitions-inherited").some((phrase) => phrase !== "" && doc.source.includes(phrase)),
|
|
195
196
|
});
|
|
196
|
-
|
|
197
|
+
const dictionary = doc.dictionary?.() ?? new Set<string>();
|
|
198
|
+
// A term holding a run-together word (Space Includingspecified Description) is text a conversion joined, not a term.
|
|
199
|
+
const capitalised = capitalisedUses(doc, sentences, definitions).filter((use) => !use.term.split(/\s+/u).some((word) => isRunTogether(word, dictionary)));
|
|
200
|
+
return [...prefixed, ...capitalised].map((use) => findingOf(doc, use));
|
|
197
201
|
};
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
// a word inside a longer one ("timely" in "in a timely manner") is that longer word, and a word inside a term of art of the
|
|
3
3
|
// document's genre ("reasonably" in a contract, "adequately compensate" as the test for an injunction) is not vague
|
|
4
4
|
// there. The rule speaks once per sentence, about the document's density. Pure: the words come from the language's
|
|
5
|
-
// lexicons vague-word and vague-word-term-of-art, the genre from the options.
|
|
5
|
+
// lexicons vague-word and vague-word-term-of-art, the genre from the options. The lines of a table of contents are the
|
|
6
|
+
// sections' names, not the writer's sentences, and are not read.
|
|
6
7
|
import { entriesForGenre } from "../lexicon-genres.ts";
|
|
8
|
+
import { contentsLineNumbers } from "../structure/contents-lines.ts";
|
|
9
|
+
import { lineNumberAt, linesOf } from "../structure/lines.ts";
|
|
7
10
|
import { escapeRegExp } from "../orthography.ts";
|
|
8
|
-
import type { Detector, Finding, Lexicon, LexiconEntry, Sentence } from "../plugin.ts";
|
|
11
|
+
import type { Detector, Finding, Lexicon, LexiconEntry, ProseDocument, Sentence } from "../plugin.ts";
|
|
9
12
|
import { comparableText, comparableWords, entryRanges } from "./lexicon-match.ts";
|
|
10
13
|
import { rateOver } from "./lexicon.ts";
|
|
11
14
|
import { specifiedByBracket } from "./bracket-specified.ts";
|
|
@@ -64,10 +67,20 @@ export const vagueWordsIn = (sentence: Sentence, vague: Lexicon, termsOfArt: Lex
|
|
|
64
67
|
|
|
65
68
|
type SentenceHits = { readonly sentence: Sentence; readonly words: readonly string[] };
|
|
66
69
|
|
|
70
|
+
/** The sentences on a line of a table of contents (the items under a 目次 / Contents heading). */
|
|
71
|
+
const contentsSentences = (doc: ProseDocument): ReadonlySet<Sentence> => {
|
|
72
|
+
const lines = linesOf(doc.source);
|
|
73
|
+
const tocWords = (doc.lexicons["toc-heading"] ?? []).map((entry) => entry.pattern);
|
|
74
|
+
const numbers = contentsLineNumbers(lines, doc.markup?.headings ?? [], tocWords);
|
|
75
|
+
return new Set(doc.sentences.filter((sentence) => numbers.has(lineNumberAt(lines, sentence.span.start) ?? 0)));
|
|
76
|
+
};
|
|
77
|
+
|
|
67
78
|
export const vagueDensity: Detector = (doc, options): Finding[] => {
|
|
68
79
|
const termsOfArt = entriesForGenre(doc.lexicons[TERMS_OF_ART] ?? [], options.genre);
|
|
69
80
|
const nameMarkers = (doc.lexicons[NAME_MARKERS] ?? []).map((entry) => entry.pattern);
|
|
81
|
+
const contents = contentsSentences(doc);
|
|
70
82
|
const hits: SentenceHits[] = doc.sentences
|
|
83
|
+
.filter((sentence) => !contents.has(sentence))
|
|
71
84
|
.map((sentence) => ({ sentence, words: vagueWordsIn(sentence, options.lexicon ?? [], termsOfArt, nameMarkers) }))
|
|
72
85
|
.filter((hit) => hit.words.length > 0);
|
|
73
86
|
const count = hits.reduce((sum, hit) => sum + hit.words.length, 0);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** YAML の 1 行の値。行末のコメントと、値を囲む引用符を外す。 */
|
|
2
|
+
const scalarOf = (raw: string): string => {
|
|
3
|
+
const comment = raw.search(/\s#/u);
|
|
4
|
+
const value = (comment === -1 ? raw : raw.slice(0, comment)).trim();
|
|
5
|
+
return /^(["'])(.*)\1$/u.exec(value)?.[2] ?? value;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const valuesOf = (block: string, key: string): string[] => [...block.matchAll(new RegExp(`^${key}:(.*)$`, "gmu"))].map((line) => scalarOf(line[1] ?? ""));
|
|
9
|
+
|
|
10
|
+
/** front matter の 1 つの欄に書かれた値。front matter が無ければ空。 */
|
|
11
|
+
export const frontMatterValues = (source: string, key: string): string[] => {
|
|
12
|
+
const block = /^---\n([\s\S]*?)\n---/u.exec(source)?.[1];
|
|
13
|
+
return block === undefined ? [] : valuesOf(block, key);
|
|
14
|
+
};
|
package/src/genre-check.ts
CHANGED