chaffjs 0.48.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -0
- package/README.md +1 -0
- package/dist/announced-count.d.ts.map +1 -1
- package/dist/announced-count.js +18 -1
- package/dist/announced-count.js.map +1 -1
- package/dist/announced-list.d.ts.map +1 -1
- package/dist/announced-list.js +6 -1
- package/dist/announced-list.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/composite-signals.d.ts +3 -1
- package/dist/composite-signals.d.ts.map +1 -1
- package/dist/composite-signals.js +7 -0
- package/dist/composite-signals.js.map +1 -1
- package/dist/detectors/acronym-name.d.ts +2 -2
- package/dist/detectors/acronym-name.d.ts.map +1 -1
- package/dist/detectors/acronym-name.js +3 -3
- package/dist/detectors/acronym-name.js.map +1 -1
- package/dist/detectors/agentless-passive.d.ts.map +1 -1
- package/dist/detectors/agentless-passive.js +39 -4
- package/dist/detectors/agentless-passive.js.map +1 -1
- package/dist/detectors/agreement-slip.d.ts +2 -0
- package/dist/detectors/agreement-slip.d.ts.map +1 -1
- package/dist/detectors/agreement-slip.js +10 -3
- package/dist/detectors/agreement-slip.js.map +1 -1
- package/dist/detectors/amount-scale.js +2 -2
- package/dist/detectors/amount-scale.js.map +1 -1
- package/dist/detectors/char-shape.d.ts.map +1 -1
- package/dist/detectors/char-shape.js +11 -4
- package/dist/detectors/char-shape.js.map +1 -1
- package/dist/detectors/chat-citation.d.ts +2 -6
- package/dist/detectors/chat-citation.d.ts.map +1 -1
- package/dist/detectors/chat-citation.js +4 -2
- package/dist/detectors/chat-citation.js.map +1 -1
- package/dist/detectors/chat-mark-extent.d.ts +11 -0
- package/dist/detectors/chat-mark-extent.d.ts.map +1 -0
- package/dist/detectors/chat-mark-extent.js +53 -0
- package/dist/detectors/chat-mark-extent.js.map +1 -0
- package/dist/detectors/concrete-evidence-density.js +2 -2
- package/dist/detectors/concrete-evidence.d.ts +7 -0
- package/dist/detectors/concrete-evidence.d.ts.map +1 -1
- package/dist/detectors/concrete-evidence.js +20 -0
- package/dist/detectors/concrete-evidence.js.map +1 -1
- package/dist/detectors/conjugated-entry.d.ts +2 -2
- package/dist/detectors/conjugated-entry.d.ts.map +1 -1
- package/dist/detectors/conjugated-entry.js +3 -5
- package/dist/detectors/conjugated-entry.js.map +1 -1
- package/dist/detectors/contrast-frame.d.ts.map +1 -1
- package/dist/detectors/contrast-frame.js +34 -1
- package/dist/detectors/contrast-frame.js.map +1 -1
- package/dist/detectors/currency-notation.js +2 -2
- package/dist/detectors/currency-notation.js.map +1 -1
- package/dist/detectors/defined-term-form.d.ts.map +1 -1
- package/dist/detectors/defined-term-form.js +15 -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 +5 -1
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/ellipsis.js +2 -2
- package/dist/detectors/ellipsis.js.map +1 -1
- package/dist/detectors/email-letter.d.ts +2 -0
- package/dist/detectors/email-letter.d.ts.map +1 -1
- package/dist/detectors/email-letter.js +1 -1
- package/dist/detectors/email-letter.js.map +1 -1
- package/dist/detectors/en-shape.d.ts +1 -0
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +41 -9
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/gram-furniture.d.ts +1 -0
- package/dist/detectors/gram-furniture.d.ts.map +1 -1
- package/dist/detectors/gram-furniture.js +6 -0
- package/dist/detectors/gram-furniture.js.map +1 -1
- package/dist/detectors/gram-repetition.d.ts.map +1 -1
- package/dist/detectors/gram-repetition.js +8 -2
- package/dist/detectors/gram-repetition.js.map +1 -1
- package/dist/detectors/heading-case.d.ts +1 -0
- package/dist/detectors/heading-case.d.ts.map +1 -1
- package/dist/detectors/heading-case.js +10 -3
- package/dist/detectors/heading-case.js.map +1 -1
- package/dist/detectors/kanji-name-edge.d.ts +10 -0
- package/dist/detectors/kanji-name-edge.d.ts.map +1 -1
- package/dist/detectors/kanji-name-edge.js +23 -0
- package/dist/detectors/kanji-name-edge.js.map +1 -1
- package/dist/detectors/kutoten-consistency.d.ts.map +1 -1
- package/dist/detectors/kutoten-consistency.js +27 -6
- package/dist/detectors/kutoten-consistency.js.map +1 -1
- package/dist/detectors/lexicon-match.d.ts +2 -0
- package/dist/detectors/lexicon-match.d.ts.map +1 -1
- package/dist/detectors/lexicon-match.js +14 -3
- package/dist/detectors/lexicon-match.js.map +1 -1
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +8 -1
- package/dist/detectors/lexicon.js.map +1 -1
- package/dist/detectors/list-item-clause.d.ts +4 -0
- package/dist/detectors/list-item-clause.d.ts.map +1 -0
- package/dist/detectors/list-item-clause.js +8 -0
- package/dist/detectors/list-item-clause.js.map +1 -0
- package/dist/detectors/list-parallel.d.ts.map +1 -1
- package/dist/detectors/list-parallel.js +6 -2
- package/dist/detectors/list-parallel.js.map +1 -1
- package/dist/detectors/list-sentence.d.ts +2 -0
- package/dist/detectors/list-sentence.d.ts.map +1 -1
- package/dist/detectors/list-sentence.js.map +1 -1
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +28 -8
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/missing-final-period.d.ts.map +1 -1
- package/dist/detectors/missing-final-period.js +10 -1
- package/dist/detectors/missing-final-period.js.map +1 -1
- package/dist/detectors/name-variant-two-things.d.ts +1 -1
- package/dist/detectors/name-variant-two-things.d.ts.map +1 -1
- package/dist/detectors/name-variant-two-things.js +16 -4
- package/dist/detectors/name-variant-two-things.js.map +1 -1
- package/dist/detectors/nominalization.d.ts.map +1 -1
- package/dist/detectors/nominalization.js +11 -4
- package/dist/detectors/nominalization.js.map +1 -1
- package/dist/detectors/ordinal-suffix.js +2 -2
- package/dist/detectors/ordinal-suffix.js.map +1 -1
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +30 -6
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +13 -7
- package/dist/detectors/orthography.js.map +1 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +15 -1
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/paragraph-run.js +2 -2
- package/dist/detectors/paragraph-run.js.map +1 -1
- package/dist/detectors/phone-number-variant.d.ts.map +1 -1
- package/dist/detectors/phone-number-variant.js +2 -1
- package/dist/detectors/phone-number-variant.js.map +1 -1
- package/dist/detectors/phrase-context.d.ts +6 -0
- package/dist/detectors/phrase-context.d.ts.map +1 -0
- package/dist/detectors/phrase-context.js +12 -0
- package/dist/detectors/phrase-context.js.map +1 -0
- package/dist/detectors/phrase-match-all.d.ts +3 -0
- package/dist/detectors/phrase-match-all.d.ts.map +1 -0
- package/dist/detectors/phrase-match-all.js +47 -0
- package/dist/detectors/phrase-match-all.js.map +1 -0
- package/dist/detectors/phrase-match.d.ts +2 -1
- package/dist/detectors/phrase-match.d.ts.map +1 -1
- package/dist/detectors/phrase-match.js +25 -6
- package/dist/detectors/phrase-match.js.map +1 -1
- package/dist/detectors/placeholder-text.d.ts.map +1 -1
- package/dist/detectors/placeholder-text.js +14 -2
- package/dist/detectors/placeholder-text.js.map +1 -1
- package/dist/detectors/proper-noun-density.d.ts.map +1 -1
- package/dist/detectors/proper-noun-density.js +10 -6
- package/dist/detectors/proper-noun-density.js.map +1 -1
- package/dist/detectors/quote-around.d.ts +3 -0
- package/dist/detectors/quote-around.d.ts.map +1 -1
- package/dist/detectors/quote-around.js +2 -0
- package/dist/detectors/quote-around.js.map +1 -1
- package/dist/detectors/range-notation.js +2 -2
- package/dist/detectors/range-notation.js.map +1 -1
- package/dist/detectors/reference-entry.d.ts.map +1 -1
- package/dist/detectors/reference-entry.js +35 -5
- package/dist/detectors/reference-entry.js.map +1 -1
- package/dist/detectors/register-set-apart.d.ts +1 -1
- package/dist/detectors/register-set-apart.js +4 -4
- package/dist/detectors/register-set-apart.js.map +1 -1
- package/dist/detectors/register-voice.d.ts +5 -0
- package/dist/detectors/register-voice.d.ts.map +1 -1
- package/dist/detectors/register-voice.js +17 -0
- package/dist/detectors/register-voice.js.map +1 -1
- package/dist/detectors/registry/phrase-match-all.d.ts +3 -0
- package/dist/detectors/registry/phrase-match-all.d.ts.map +1 -0
- package/dist/detectors/registry/phrase-match-all.js +3 -0
- package/dist/detectors/registry/phrase-match-all.js.map +1 -0
- package/dist/detectors/requirement-lists.d.ts.map +1 -1
- package/dist/detectors/requirement-lists.js +2 -0
- package/dist/detectors/requirement-lists.js.map +1 -1
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +7 -4
- package/dist/detectors/sentence-counts.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts +2 -2
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +3 -1
- package/dist/detectors/sentence-ending.js.map +1 -1
- package/dist/detectors/sentence-length.d.ts.map +1 -1
- package/dist/detectors/sentence-length.js +12 -4
- package/dist/detectors/sentence-length.js.map +1 -1
- package/dist/detectors/sentence-parts.d.ts +6 -3
- package/dist/detectors/sentence-parts.d.ts.map +1 -1
- package/dist/detectors/sentence-parts.js +15 -7
- package/dist/detectors/sentence-parts.js.map +1 -1
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +6 -1
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/speaker-turns.d.ts +4 -0
- package/dist/detectors/speaker-turns.d.ts.map +1 -0
- package/dist/detectors/speaker-turns.js +28 -0
- package/dist/detectors/speaker-turns.js.map +1 -0
- package/dist/detectors/team.d.ts.map +1 -1
- package/dist/detectors/team.js +42 -9
- package/dist/detectors/team.js.map +1 -1
- package/dist/detectors/unit-spacing.js +2 -2
- package/dist/detectors/unit-spacing.js.map +1 -1
- package/dist/detectors/vague-deadline.d.ts.map +1 -1
- package/dist/detectors/vague-deadline.js +2 -1
- package/dist/detectors/vague-deadline.js.map +1 -1
- package/dist/levels.d.ts +14 -0
- package/dist/levels.d.ts.map +1 -1
- package/dist/levels.js +8 -3
- package/dist/levels.js.map +1 -1
- package/dist/name-variant-shapes.d.ts +10 -0
- package/dist/name-variant-shapes.d.ts.map +1 -1
- package/dist/name-variant-shapes.js +24 -0
- package/dist/name-variant-shapes.js.map +1 -1
- package/dist/phone-numbers.d.ts +5 -2
- package/dist/phone-numbers.d.ts.map +1 -1
- package/dist/phone-numbers.js +17 -3
- package/dist/phone-numbers.js.map +1 -1
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/render/explain.d.ts +2 -0
- package/dist/render/explain.d.ts.map +1 -1
- package/dist/render/explain.js +38 -14
- package/dist/render/explain.js.map +1 -1
- package/dist/render/options.d.ts.map +1 -1
- package/dist/render/options.js +11 -6
- package/dist/render/options.js.map +1 -1
- package/dist/render/text.d.ts.map +1 -1
- package/dist/render/text.js +14 -4
- package/dist/render/text.js.map +1 -1
- package/dist/run.d.ts +3 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +20 -13
- package/dist/run.js.map +1 -1
- package/dist/set-phrase-particles.js +2 -2
- package/dist/set-phrase-particles.js.map +1 -1
- package/dist/structure/deadline-after-event.d.ts +1 -1
- package/dist/structure/deadline-after-event.d.ts.map +1 -1
- package/dist/structure/deadline-after-event.js +36 -9
- package/dist/structure/deadline-after-event.js.map +1 -1
- package/dist/structure/definition-use.d.ts +10 -1
- package/dist/structure/definition-use.d.ts.map +1 -1
- package/dist/structure/definition-use.js +4 -4
- package/dist/structure/definition-use.js.map +1 -1
- package/dist/structure/leg-times.d.ts.map +1 -1
- package/dist/structure/leg-times.js +10 -2
- package/dist/structure/leg-times.js.map +1 -1
- package/dist/structure/requirement-lists.d.ts +3 -0
- package/dist/structure/requirement-lists.d.ts.map +1 -1
- package/dist/structure/requirement-lists.js +8 -2
- package/dist/structure/requirement-lists.js.map +1 -1
- package/dist/structure/time-marks.d.ts +10 -0
- package/dist/structure/time-marks.d.ts.map +1 -1
- package/dist/structure/time-marks.js +21 -0
- package/dist/structure/time-marks.js.map +1 -1
- package/dist/topic-clause.d.ts.map +1 -1
- package/dist/topic-clause.js +12 -5
- package/dist/topic-clause.js.map +1 -1
- package/package.json +3 -3
- package/rules/abstract-length.yaml +1 -1
- package/rules/adverb-overuse.yaml +1 -1
- package/rules/agentless-passive.yaml +3 -3
- package/rules/agreement-slip.yaml +5 -4
- package/rules/ai-generated-composite.yaml +3 -3
- package/rules/ai-structure.yaml +1 -1
- package/rules/all-caps-shouting.yaml +1 -1
- package/rules/announced-count-mismatch.yaml +2 -2
- package/rules/announcing-opener.yaml +1 -1
- package/rules/arrival-before-departure.yaml +1 -1
- package/rules/article-sound.yaml +1 -1
- package/rules/baito-keigo.yaml +1 -1
- package/rules/bold-density.yaml +1 -1
- package/rules/bold-emphasis.yaml +1 -1
- package/rules/bold-label-list.yaml +1 -1
- package/rules/bracket-width-consistency.yaml +1 -1
- package/rules/chat-citation-residue.yaml +1 -1
- package/rules/citation-style-mix.yaml +1 -1
- package/rules/clause-chain.yaml +1 -1
- package/rules/cliche.yaml +4 -4
- package/rules/closing-cliche.yaml +1 -1
- package/rules/closing-exhortation.yaml +1 -1
- package/rules/cold-open.yaml +1 -1
- package/rules/colloquial-opener.yaml +1 -1
- package/rules/concrete-evidence-density.yaml +3 -3
- package/rules/contraction-consistency.yaml +1 -1
- package/rules/cross-doc-term-variant.yaml +2 -2
- package/rules/cushion-phrase-density.yaml +1 -1
- package/rules/deadline-after-event.yaml +2 -2
- package/rules/demonstrative-opener-run.yaml +1 -1
- package/rules/double-keigo.yaml +1 -1
- package/rules/double-negative.yaml +11 -2
- package/rules/doubled-nado.yaml +1 -1
- package/rules/email-stock-courtesy.yaml +1 -1
- package/rules/email-subject-length.yaml +1 -1
- package/rules/emoji-heading.yaml +1 -1
- package/rules/empty-intensifier.yaml +1 -1
- package/rules/excessive-hedging.yaml +1 -1
- package/rules/exclamation-width-consistency.yaml +1 -1
- package/rules/expletive-construction.yaml +5 -5
- package/rules/figurative-density.yaml +3 -3
- package/rules/hiragana-fukushi.yaml +1 -1
- package/rules/homophone-slip.yaml +3 -3
- package/rules/honesty-marker.yaml +1 -1
- package/rules/humble-for-others.yaml +1 -1
- package/rules/hyphen-as-dash.yaml +1 -1
- package/rules/idiom-misuse.yaml +1 -1
- package/rules/internal-jargon.yaml +1 -1
- package/rules/kana-function-word.yaml +1 -1
- package/rules/katakana-long-vowel.yaml +1 -1
- package/rules/kutoten-consistency.yaml +7 -3
- package/rules/latin-abbreviation-form.yaml +1 -1
- package/rules/latin-spacing.yaml +1 -1
- package/rules/max-kanji-continuous.yaml +5 -3
- package/rules/max-paragraph-length.yaml +1 -1
- package/rules/max-sentence-length.yaml +1 -1
- package/rules/max-ten.yaml +1 -1
- package/rules/misconversion.yaml +2 -2
- package/rules/name-variant.yaml +2 -2
- package/rules/ngram-repetition.yaml +3 -3
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/no-em-dash.yaml +3 -3
- package/rules/no-mixed-desumasu.yaml +4 -3
- package/rules/no-nakaguro-parallel.yaml +1 -1
- package/rules/nominalization.yaml +1 -1
- package/rules/nonstandard-word.yaml +2 -2
- package/rules/numbered-generic-heading.yaml +1 -1
- package/rules/numbering-gap.yaml +2 -2
- package/rules/one-sentence-paragraph-run.yaml +1 -1
- package/rules/orthographic-variant.yaml +2 -2
- package/rules/over-general-claim.yaml +1 -1
- package/rules/oxford-comma-consistency.yaml +4 -3
- package/rules/padded-intro.yaml +1 -1
- package/rules/phone-number-variant.yaml +1 -1
- package/rules/preamble-length.yaml +1 -1
- package/rules/preferred-term.yaml +1 -1
- package/rules/proper-noun-density.yaml +1 -1
- package/rules/q-fragment-answer.yaml +1 -1
- package/rules/quote-style-consistency.yaml +1 -1
- package/rules/quote-without-source.yaml +1 -1
- package/rules/redundant-expression.yaml +1 -1
- package/rules/repeated-conjunction.yaml +1 -1
- package/rules/repeated-sentence-ending.yaml +1 -1
- package/rules/repeated-sentence-head.yaml +5 -5
- package/rules/required-listed-as-preferred.yaml +2 -2
- package/rules/required-sections.yaml +1 -1
- package/rules/sasete-itadaku.yaml +1 -1
- package/rules/sentence-initial-conjunction-run.yaml +1 -1
- package/rules/sentence-initial-so.yaml +1 -1
- package/rules/sentence-spacing-consistency.yaml +1 -1
- package/rules/shell-prompt-mix.yaml +1 -1
- package/rules/stock-transition.yaml +1 -1
- package/rules/stray-space.yaml +1 -1
- package/rules/taigen-dome-in-prose.yaml +1 -1
- package/rules/teki-overuse.yaml +1 -1
- package/rules/title-case-consistency.yaml +1 -1
- package/rules/title-length.yaml +1 -1
- package/rules/topic-predicate-distance.yaml +3 -3
- package/rules/translationese-density.yaml +1 -1
- package/rules/uncomparable-graded.yaml +1 -1
- package/rules/undefined-acronym.yaml +3 -3
- package/rules/unfilled-placeholder.yaml +4 -4
- package/rules/unqualified-superlative.yaml +1 -1
- package/rules/use-before-definition.yaml +2 -2
- package/rules/vague-word-density.yaml +3 -3
- package/rules/weasel-word.yaml +1 -1
- package/rules/which-that-consistency.yaml +1 -1
- package/rules/wordy-phrase.yaml +1 -1
- package/skills/chaff/SKILL.md +3 -1
- package/src/announced-count.ts +22 -1
- package/src/announced-list.ts +7 -1
- package/src/cli.ts +4 -2
- package/src/composite-signals.ts +10 -1
- package/src/detectors/acronym-name.ts +6 -3
- package/src/detectors/agentless-passive.ts +49 -5
- package/src/detectors/agreement-slip.ts +11 -3
- package/src/detectors/amount-scale.ts +2 -2
- package/src/detectors/char-shape.ts +18 -3
- package/src/detectors/chat-citation.ts +4 -5
- package/src/detectors/chat-mark-extent.ts +63 -0
- package/src/detectors/concrete-evidence-density.ts +2 -2
- package/src/detectors/concrete-evidence.ts +27 -0
- package/src/detectors/conjugated-entry.ts +3 -5
- package/src/detectors/contrast-frame.ts +37 -2
- package/src/detectors/currency-notation.ts +2 -2
- package/src/detectors/defined-term-form.ts +15 -4
- package/src/detectors/definition-use.ts +5 -8
- package/src/detectors/ellipsis.ts +2 -2
- package/src/detectors/email-letter.ts +1 -1
- package/src/detectors/en-shape.ts +50 -9
- package/src/detectors/gram-furniture.ts +8 -0
- package/src/detectors/gram-repetition.ts +8 -1
- package/src/detectors/heading-case.ts +11 -3
- package/src/detectors/kanji-name-edge.ts +27 -0
- package/src/detectors/kutoten-consistency.ts +37 -6
- package/src/detectors/lexicon-match.ts +17 -3
- package/src/detectors/lexicon.ts +10 -4
- package/src/detectors/list-item-clause.ts +9 -0
- package/src/detectors/list-parallel.ts +5 -2
- package/src/detectors/list-sentence.ts +2 -0
- package/src/detectors/mark-shape.ts +36 -8
- package/src/detectors/missing-final-period.ts +11 -1
- package/src/detectors/name-variant-two-things.ts +28 -3
- package/src/detectors/nominalization.ts +14 -4
- package/src/detectors/ordinal-suffix.ts +2 -2
- package/src/detectors/orthographic-variant.ts +44 -8
- package/src/detectors/orthography.ts +19 -9
- package/src/detectors/oxford-comma.ts +15 -1
- package/src/detectors/paragraph-run.ts +2 -2
- package/src/detectors/phone-number-variant.ts +2 -1
- package/src/detectors/phrase-context.ts +19 -0
- package/src/detectors/phrase-match-all.ts +57 -0
- package/src/detectors/phrase-match.ts +31 -6
- package/src/detectors/placeholder-text.ts +19 -3
- package/src/detectors/proper-noun-density.ts +14 -6
- package/src/detectors/quote-around.ts +6 -0
- package/src/detectors/range-notation.ts +2 -2
- package/src/detectors/reference-entry.ts +36 -6
- package/src/detectors/register-set-apart.ts +4 -4
- package/src/detectors/register-voice.ts +19 -0
- package/src/detectors/registry/phrase-match-all.ts +4 -0
- package/src/detectors/requirement-lists.ts +2 -0
- package/src/detectors/sentence-counts.ts +9 -5
- package/src/detectors/sentence-ending.ts +8 -4
- package/src/detectors/sentence-length.ts +18 -6
- package/src/detectors/sentence-parts.ts +21 -9
- package/src/detectors/signals.ts +10 -1
- package/src/detectors/speaker-turns.ts +37 -0
- package/src/detectors/team.ts +50 -12
- package/src/detectors/unit-spacing.ts +2 -2
- package/src/detectors/vague-deadline.ts +2 -1
- package/src/levels.ts +9 -3
- package/src/name-variant-shapes.ts +29 -0
- package/src/phone-numbers.ts +19 -3
- package/src/plugin.ts +2 -0
- package/src/render/explain.ts +46 -16
- package/src/render/options.ts +12 -6
- package/src/render/text.ts +20 -7
- package/src/run.ts +32 -8
- package/src/set-phrase-particles.ts +2 -2
- package/src/structure/deadline-after-event.ts +49 -10
- package/src/structure/definition-use.ts +15 -5
- package/src/structure/leg-times.ts +16 -1
- package/src/structure/requirement-lists.ts +14 -2
- package/src/structure/time-marks.ts +25 -0
- package/src/topic-clause.ts +17 -5
- package/dist/honorific-group.d.ts +0 -8
- package/dist/honorific-group.d.ts.map +0 -1
- package/dist/honorific-group.js +0 -15
- package/dist/honorific-group.js.map +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Detector, Finding, Lexicon, Sentence } from "../plugin.ts";
|
|
2
|
+
import { entryEnds } from "./lexicon-match.ts";
|
|
3
|
+
import { quotedPattern } from "./quoted-pattern.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* phrase-match の、文の中の違う言い回しをみな名指す版。指摘は phrase-match と同じく文ごとに一つで、位置も文の頭。
|
|
7
|
+
* 一つの文に「ないわけではありません」と「ないとは限りません」があれば、一つ目だけを言うと二つ目を直し忘れる。
|
|
8
|
+
* 重なる二つの語が同じ位置で終われば一回で、名指すのは語彙表で先に書いた語。並びは文の中で終わる順。
|
|
9
|
+
*/
|
|
10
|
+
type Named = { readonly sentence: Sentence; readonly phrases: readonly string[] };
|
|
11
|
+
|
|
12
|
+
const firstEnds = (sentence: Sentence, lexicon: Lexicon): { readonly phrase: string; readonly end: number }[] =>
|
|
13
|
+
lexicon.flatMap((entry) => {
|
|
14
|
+
const ends = entryEnds(sentence, entry);
|
|
15
|
+
return ends.length === 0 ? [] : [{ phrase: quotedPattern(entry.pattern), end: Math.min(...ends) }];
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const phrasesIn = (sentence: Sentence, lexicon: Lexicon): string[] => {
|
|
19
|
+
const byEnd = new Map<number, string>();
|
|
20
|
+
firstEnds(sentence, lexicon).forEach(({ phrase, end }) => {
|
|
21
|
+
if (!byEnd.has(end)) byEnd.set(end, phrase);
|
|
22
|
+
});
|
|
23
|
+
const ordered = [...byEnd].toSorted(([left], [right]) => left - right).map(([, phrase]) => phrase);
|
|
24
|
+
return [...new Set(ordered)];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** 違う言い回しが二つなら both、三つ以上なら many の文言。 */
|
|
28
|
+
const variantOf = (kinds: number): Pick<Finding, "variant"> => {
|
|
29
|
+
if (kinds === 2) return { variant: "both" };
|
|
30
|
+
return kinds > 2 ? { variant: "many" } : {};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const findingOf = ({ sentence, phrases }: Named, count: number, limit: number): Finding => ({
|
|
34
|
+
rule: "",
|
|
35
|
+
severity: "warning",
|
|
36
|
+
line: 0,
|
|
37
|
+
column: 0,
|
|
38
|
+
quote: sentence.text.trim(),
|
|
39
|
+
...variantOf(phrases.length),
|
|
40
|
+
values: {
|
|
41
|
+
matched: phrases[0] ?? "",
|
|
42
|
+
...(phrases.length > 1 ? { other: phrases[1] ?? "", kinds: phrases.length } : {}),
|
|
43
|
+
count,
|
|
44
|
+
limit,
|
|
45
|
+
offset: sentence.span.start,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const phraseMatchAll: Detector = (doc, options): Finding[] => {
|
|
50
|
+
const lexicon = options.lexicon ?? [];
|
|
51
|
+
if (lexicon.length === 0) return [];
|
|
52
|
+
const named = doc.sentences.flatMap((sentence) => {
|
|
53
|
+
const phrases = phrasesIn(sentence, lexicon);
|
|
54
|
+
return phrases.length === 0 ? [] : [{ sentence, phrases }];
|
|
55
|
+
});
|
|
56
|
+
return named.length < options.limit ? [] : named.map((item) => findingOf(item, named.length, options.limit));
|
|
57
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Detector, DetectorOptions, Finding, Lexicon, LexiconEntry, ProseDocument, Sentence } from "../plugin.ts";
|
|
2
|
-
import { entryEnds, entryIn, entryOpens } from "./lexicon-match.ts";
|
|
2
|
+
import { entryEnds, entryIn, entryOpens, entryRanges, entryWrittenIn } from "./lexicon-match.ts";
|
|
3
3
|
import { externalLinkTitleSpans } from "../link-title.ts";
|
|
4
|
+
import { referenceListSpans } from "../reference-lists.ts";
|
|
4
5
|
import { mentionCuesOf, onlyInTitles, onlyMentioned } from "./mentioned-phrase.ts";
|
|
6
|
+
import { inFigurativeContext, phraseContextsOf } from "./phrase-context.ts";
|
|
5
7
|
import { closingSentences } from "../closing-paragraph.ts";
|
|
6
8
|
import { quotedPattern } from "./quoted-pattern.ts";
|
|
7
9
|
|
|
@@ -23,12 +25,28 @@ type Hit = { readonly sentence: Sentence; readonly matched: string };
|
|
|
23
25
|
/** Whether the entry's words in the sentence count as a use. phrase-match counts every one. */
|
|
24
26
|
type IsUsed = (sentence: Sentence, entry: LexiconEntry) => boolean;
|
|
25
27
|
|
|
28
|
+
/** Some place of the entry in the sentence is not followed by a word of a part of speech the entry names in not_before_pos. Without tokens every place counts. */
|
|
29
|
+
const freeOfNextWord = (sentence: Sentence, entry: LexiconEntry): boolean => {
|
|
30
|
+
const blocked = entry.not_before_pos;
|
|
31
|
+
const tokens = sentence.tokens;
|
|
32
|
+
const ranges = entryRanges(sentence, entry);
|
|
33
|
+
if (blocked === undefined || tokens === undefined || ranges.length === 0) return true;
|
|
34
|
+
return ranges.some((range) => !blocked.includes(tokens[range.end]?.pos ?? ""));
|
|
35
|
+
};
|
|
36
|
+
|
|
26
37
|
/** An entry marked opens counts only at the head of the sentence: 「近年、」 opens a stock opening, 「その後、近年の」 is a plain word. */
|
|
27
|
-
const writtenIn = (sentence: Sentence, entry: LexiconEntry): boolean =>
|
|
38
|
+
const writtenIn = (sentence: Sentence, entry: LexiconEntry): boolean =>
|
|
39
|
+
(entry.opens === true ? entryOpens(sentence, entry) : entryIn(sentence, entry)) && freeOfNextWord(sentence, entry);
|
|
40
|
+
|
|
41
|
+
/** The entry the sentence holds; one written in the very form (reverted back) wins over one met through its base form (revert back). */
|
|
42
|
+
const entryHeldBy = (sentence: Sentence, lexicon: Lexicon, isUsed: IsUsed): LexiconEntry | undefined => {
|
|
43
|
+
const held = lexicon.filter((entry) => writtenIn(sentence, entry) && isUsed(sentence, entry));
|
|
44
|
+
return held.find((entry) => entryWrittenIn(sentence, entry)) ?? held[0];
|
|
45
|
+
};
|
|
28
46
|
|
|
29
47
|
const hitsIn = (sentences: readonly Sentence[], lexicon: Lexicon, isUsed: IsUsed = () => true): Hit[] =>
|
|
30
48
|
sentences.flatMap((sentence) => {
|
|
31
|
-
const matched =
|
|
49
|
+
const matched = entryHeldBy(sentence, lexicon, isUsed);
|
|
32
50
|
return matched === undefined ? [] : [{ sentence, matched: quotedPattern(matched.pattern) }];
|
|
33
51
|
});
|
|
34
52
|
|
|
@@ -64,12 +82,19 @@ export const phraseMatchWhere = (doc: ProseDocument, options: DetectorOptions, i
|
|
|
64
82
|
|
|
65
83
|
/**
|
|
66
84
|
* phrase-match の、言葉として名指しただけの言い回し(the phrase "…", 「…」という言い方)を数えない版(mentioned-phrase.ts)。
|
|
67
|
-
* 参考文献のリンクに写した外のページの題名([文章の極意は…](https://…)
|
|
85
|
+
* 参考文献のリンクに写した外のページの題名([文章の極意は…](https://…))と、文献一覧に写した著作の題の言い回しも、書き手の言葉ではないので数えない。
|
|
86
|
+
* 字どおりの意味にも読める言い回し(at the end of the day)は、cliche-figurative が言う比喩の文脈の文だけで数える(phrase-context.ts)。
|
|
68
87
|
*/
|
|
69
88
|
export const phraseInUse: Detector = (doc, options): Finding[] => {
|
|
70
89
|
const cues = mentionCuesOf(doc.lexicons["mention-cue"] ?? []);
|
|
71
|
-
const
|
|
72
|
-
const
|
|
90
|
+
const headings = (doc.lexicons["reference-list-heading"] ?? []).map((entry) => entry.pattern);
|
|
91
|
+
const titles = [...externalLinkTitleSpans(doc.source, doc.links), ...referenceListSpans(doc.source, headings)];
|
|
92
|
+
const figurative = phraseContextsOf(doc.lexicons["cliche-figurative"] ?? []);
|
|
93
|
+
const hits = phraseHits(
|
|
94
|
+
doc,
|
|
95
|
+
options,
|
|
96
|
+
(sentence, entry) => !onlyMentioned(sentence, entry, cues) && !onlyInTitles(sentence, entry, titles) && inFigurativeContext(sentence, entry, figurative),
|
|
97
|
+
);
|
|
73
98
|
return hits.length < options.limit ? [] : findingsOf(hits, options.limit);
|
|
74
99
|
};
|
|
75
100
|
|
|
@@ -31,6 +31,7 @@ const withoutClosers = (text: string): string => {
|
|
|
31
31
|
const MARKER = "marker";
|
|
32
32
|
const INSTRUCTION = "instruction";
|
|
33
33
|
const LABEL = "label";
|
|
34
|
+
const CLOSING = "closing";
|
|
34
35
|
|
|
35
36
|
const innerOf = (match: RegExpExecArray): string => (match[1] ?? match[2] ?? match[3] ?? "").trim().toLowerCase();
|
|
36
37
|
|
|
@@ -41,13 +42,27 @@ const holdsWord = (inner: string, words: Lexicon): boolean =>
|
|
|
41
42
|
return inner === pattern || (inner.startsWith(pattern) && /^[\s'’]/u.test(inner.slice(pattern.length)));
|
|
42
43
|
});
|
|
43
44
|
|
|
45
|
+
/** A bracket a closing word ends: two to four words, each opening with a capital ([Candidate Name], [Start Date]). */
|
|
46
|
+
const TITLED_BLANK = /^(?:\p{Lu}[\p{L}'’-]*\s+){1,3}\p{Lu}\p{L}*$/u;
|
|
47
|
+
|
|
48
|
+
const rawInnerOf = (match: RegExpExecArray): string => (match[1] ?? match[2] ?? match[3] ?? "").trim();
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 括弧の中身が、語彙表の closing の語で終わる、語の頭がみな大文字の二語から四語か([Candidate Name]、[Start Date])。
|
|
52
|
+
* 小文字の語を挟む編者の補い([the defendant's name])や一語の注記([sic])は空欄ではない。
|
|
53
|
+
*/
|
|
54
|
+
const endsWithWord = (inner: string, words: Lexicon): boolean =>
|
|
55
|
+
TITLED_BLANK.test(inner) && words.some((word) => inner.toLowerCase().endsWith(` ${word.pattern.toLowerCase()}`));
|
|
56
|
+
|
|
44
57
|
/** 括弧の中身が指示の書き出しで始まるか(ここに会社名を書く)。 */
|
|
45
58
|
const opensWith = (inner: string, words: Lexicon): boolean => words.some((word) => inner.startsWith(word.pattern.toLowerCase()));
|
|
46
59
|
|
|
47
60
|
const spanOf = (match: RegExpExecArray): Span => ({ start: match.index, end: match.index + match[0].length });
|
|
48
61
|
|
|
49
|
-
const bracketedSpans = (text: string, pattern: RegExp, holds: (inner: string) => boolean): Span[] =>
|
|
50
|
-
[...text.matchAll(pattern)]
|
|
62
|
+
const bracketedSpans = (text: string, pattern: RegExp, holds: (inner: string, raw: string) => boolean): Span[] =>
|
|
63
|
+
[...text.matchAll(pattern)]
|
|
64
|
+
.filter((match) => !FILLED_AFTER.test(text.slice(match.index + match[0].length)) && holds(innerOf(match), rawInnerOf(match)))
|
|
65
|
+
.map(spanOf);
|
|
51
66
|
|
|
52
67
|
/**
|
|
53
68
|
* A value left as a marker: the whole text is the marker ("TBD", 「未定」), or the marker opens it before a colon
|
|
@@ -163,13 +178,14 @@ export const placeholderSpans = (text: string, words: Lexicon): Span[] => {
|
|
|
163
178
|
const instructions = words.filter((word) => word.group === INSTRUCTION);
|
|
164
179
|
const markers = words.filter((word) => word.group === MARKER);
|
|
165
180
|
const labels = words.filter((word) => word.group === LABEL);
|
|
181
|
+
const closings = words.filter((word) => word.group === CLOSING);
|
|
166
182
|
const blankWords = {
|
|
167
183
|
suffixes: words.filter((word) => word.group === BLANK_SUFFIX),
|
|
168
184
|
prefixes: words.filter((word) => word.group === BLANK_PREFIX),
|
|
169
185
|
units: words.filter((word) => word.group === BLANK_UNIT),
|
|
170
186
|
};
|
|
171
187
|
return [
|
|
172
|
-
...bracketedSpans(text, BRACKETED, (inner) => holdsWord(inner, bracketWords)),
|
|
188
|
+
...bracketedSpans(text, BRACKETED, (inner, raw) => holdsWord(inner, bracketWords) || endsWithWord(raw, closings)),
|
|
173
189
|
...(instructions.length === 0 ? [] : bracketedSpans(text, PARENTHESIZED, (inner) => opensWith(inner, instructions))),
|
|
174
190
|
...lineMarkerSpans(text, markers, labels),
|
|
175
191
|
...blankMarkSpans(text, blankWords),
|
|
@@ -88,22 +88,30 @@ export const namesIn = (sentence: Sentence, listed: readonly string[], everyday:
|
|
|
88
88
|
|
|
89
89
|
const everydayNamesOf = (doc: ProseDocument): string[] => (doc.lexicons[EVERYDAY_NAME] ?? []).map((entry) => entry.pattern);
|
|
90
90
|
|
|
91
|
+
type Named = { readonly sentence: Sentence; readonly names: readonly Token[] };
|
|
92
|
+
|
|
93
|
+
/** The sentence holding the most names, the first of equals: where the reader loses the sentence's shape, not where the first name is. */
|
|
94
|
+
const densest = (named: readonly Named[]): Named | undefined =>
|
|
95
|
+
named.reduce<Named | undefined>((best, entry) => (best === undefined || entry.names.length > best.names.length ? entry : best), undefined);
|
|
96
|
+
|
|
91
97
|
export const properNounDensity: Detector = (doc, options): Finding[] => {
|
|
92
98
|
const prose = doc.sentences.filter(isProse);
|
|
93
99
|
const everyday = everydayNamesOf(doc);
|
|
94
|
-
const
|
|
100
|
+
const named = prose.map((sentence) => ({ sentence, names: namesIn(sentence, doc.names ?? [], everyday) })).filter((entry) => entry.names.length > 0);
|
|
101
|
+
const count = named.reduce((sum, entry) => sum + entry.names.length, 0);
|
|
95
102
|
const length = prose.reduce((sum, sentence) => sum + lengthOf(sentence, doc.lengthUnit), 0);
|
|
96
|
-
const rate = length === 0 ? 0 : Math.round((
|
|
97
|
-
const
|
|
98
|
-
|
|
103
|
+
const rate = length === 0 ? 0 : Math.round((count / length) * PER);
|
|
104
|
+
const at = densest(named);
|
|
105
|
+
const first = at?.names[0];
|
|
106
|
+
if (length < FLOOR[doc.lengthUnit] || at === undefined || first === undefined || rate <= options.limit) return [];
|
|
99
107
|
return [
|
|
100
108
|
{
|
|
101
109
|
rule: "proper-noun-density",
|
|
102
110
|
severity: "info",
|
|
103
111
|
line: 0,
|
|
104
112
|
column: 0,
|
|
105
|
-
quote: proseText(
|
|
106
|
-
values: { count
|
|
113
|
+
quote: proseText(at.sentence),
|
|
114
|
+
values: { count, density: rate, limit: options.limit, offset: first.span.start },
|
|
107
115
|
},
|
|
108
116
|
];
|
|
109
117
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Sentence } from "../plugin.ts";
|
|
2
|
+
|
|
1
3
|
/** 見せる前後の字数。記号 1 つの指摘は、周りの言葉が無いとどこか分からない。 */
|
|
2
4
|
const QUOTE_REACH = 20;
|
|
3
5
|
|
|
@@ -7,3 +9,7 @@ export const quoteAround = (text: string, start: number, end: number = start + 1
|
|
|
7
9
|
.slice(Math.max(0, start - QUOTE_REACH), end + QUOTE_REACH)
|
|
8
10
|
.replace(/\s+/gu, " ")
|
|
9
11
|
.trim();
|
|
12
|
+
|
|
13
|
+
/** The sentence holding offset, trimmed: a reader sees whole words, as for the rules that quote their sentence. undefined outside every sentence. */
|
|
14
|
+
export const sentenceQuoteAt = (sentences: readonly Sentence[], offset: number): string | undefined =>
|
|
15
|
+
sentences.find((sentence) => sentence.span.start <= offset && offset < sentence.span.end)?.text.trim();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Detector, Finding } from "../plugin.ts";
|
|
2
2
|
import { escapeRegExp } from "../orthography.ts";
|
|
3
3
|
import { formMinority } from "./form-minority.ts";
|
|
4
|
-
import { quoteAround } from "./quote-around.ts";
|
|
4
|
+
import { quoteAround, sentenceQuoteAt } from "./quote-around.ts";
|
|
5
5
|
|
|
6
6
|
// 一つの文書で、数の範囲を二通りの記号で書いた所(10〜20 と 10-20、10–20 と 10-20)。どちらが正しいかは決めず、少ないほうを指す。
|
|
7
7
|
// 範囲の記号は語彙表 range-notation が言う。
|
|
@@ -90,7 +90,7 @@ export const rangeNotation: Detector = (doc, options): Finding[] => {
|
|
|
90
90
|
severity: "info",
|
|
91
91
|
line: 0,
|
|
92
92
|
column: 0,
|
|
93
|
-
quote: quoteAround(text, range.offset, range.offset + range.written.length),
|
|
93
|
+
quote: sentenceQuoteAt(doc.sentences, range.offset) ?? quoteAround(text, range.offset, range.offset + range.written.length),
|
|
94
94
|
values: { written: range.written, mark: range.form, usual: minority.usual.written, count: minority.odd.length, of: ranges.length, offset: range.offset },
|
|
95
95
|
}));
|
|
96
96
|
};
|
|
@@ -3,12 +3,26 @@
|
|
|
3
3
|
// [FETCH] WHATWG, "Fetch - Living Standard",
|
|
4
4
|
// <https://fetch.spec.whatwg.org/>.
|
|
5
5
|
//
|
|
6
|
+
// A label too long for its column leaves one space, or stands alone on its line, before the entry's indented lines:
|
|
7
|
+
//
|
|
8
|
+
// [CERT.CVD] Software Engineering Institute, "The CERT Guide to
|
|
9
|
+
// Coordinated Vulnerability Disclosure", August 2017.
|
|
10
|
+
//
|
|
11
|
+
// [ISO.29147.2018]
|
|
12
|
+
// ISO, "Information technology - Security techniques -
|
|
13
|
+
//
|
|
6
14
|
// The entry is written in the cited work's words. Pure.
|
|
7
15
|
|
|
8
16
|
type Span = { readonly start: number; readonly end: number };
|
|
9
17
|
|
|
18
|
+
const LABEL = String.raw`^(?<indent>[ \t]*)\[(?<label>[A-Za-z0-9][\w.:+-]*)\]`;
|
|
10
19
|
/** A label in square brackets opening a line, then a wide gap: two spaces or a tab. A link definition ([x]: url) has a colon. */
|
|
11
|
-
const ENTRY_START =
|
|
20
|
+
const ENTRY_START = new RegExp(String.raw`${LABEL}(?: {2,}|\t)\S`, "u");
|
|
21
|
+
/**
|
|
22
|
+
* A label followed by one space or by the end of its line. Prose opens a line with a bracketed citation too ("[JSON] and XML
|
|
23
|
+
* [XML] document formats"), so this starts an entry only when the next line is indented deeper than the label.
|
|
24
|
+
*/
|
|
25
|
+
const LONG_LABEL_START = new RegExp(String.raw`${LABEL}(?: \S|$)`, "u");
|
|
12
26
|
|
|
13
27
|
type Line = { readonly text: string; readonly start: number };
|
|
14
28
|
|
|
@@ -31,12 +45,26 @@ const entryEnd = (lines: readonly Line[], at: number, indent: number): number =>
|
|
|
31
45
|
return lines.length;
|
|
32
46
|
};
|
|
33
47
|
|
|
48
|
+
type EntryStart = { readonly indent: number; readonly label: string };
|
|
49
|
+
|
|
50
|
+
/** The entry that opens at this line, if one does. */
|
|
51
|
+
const entryStartAt = (lines: readonly Line[], at: number): EntryStart | undefined => {
|
|
52
|
+
const text = lines[at]?.text ?? "";
|
|
53
|
+
const wide = ENTRY_START.exec(text)?.groups;
|
|
54
|
+
if (wide !== undefined) return { indent: (wide["indent"] ?? "").length, label: wide["label"] ?? "" };
|
|
55
|
+
const long = LONG_LABEL_START.exec(text)?.groups;
|
|
56
|
+
if (long === undefined) return undefined;
|
|
57
|
+
const indent = (long["indent"] ?? "").length;
|
|
58
|
+
const next = lines[at + 1]?.text ?? "";
|
|
59
|
+
return next.trim() !== "" && indentOf(next) > indent ? { indent, label: long["label"] ?? "" } : undefined;
|
|
60
|
+
};
|
|
61
|
+
|
|
34
62
|
export const referenceEntrySpans = (source: string): Span[] => {
|
|
35
63
|
const lines = linesOf(source);
|
|
36
64
|
return lines.flatMap((line, at) => {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
const last = lines[entryEnd(lines, at, indent
|
|
65
|
+
const entry = entryStartAt(lines, at);
|
|
66
|
+
if (entry === undefined) return [];
|
|
67
|
+
const last = lines[entryEnd(lines, at, entry.indent) - 1] ?? line;
|
|
40
68
|
return [{ start: line.start, end: last.start + last.text.length }];
|
|
41
69
|
});
|
|
42
70
|
};
|
|
@@ -45,5 +73,7 @@ export const referenceEntrySpans = (source: string): Span[] => {
|
|
|
45
73
|
* The labels of the entries ([UNIX] The Open Group, "The Single UNIX Specification"). The entry says what the label names,
|
|
46
74
|
* so the label written in prose (a UNIX timestamp) is explained by it.
|
|
47
75
|
*/
|
|
48
|
-
export const referenceEntryLabels = (source: string): ReadonlySet<string> =>
|
|
49
|
-
|
|
76
|
+
export const referenceEntryLabels = (source: string): ReadonlySet<string> => {
|
|
77
|
+
const lines = linesOf(source);
|
|
78
|
+
return new Set(lines.flatMap((_, at) => entryStartAt(lines, at)?.label ?? []));
|
|
79
|
+
};
|
|
@@ -3,7 +3,7 @@ import type { LexiconEntry, Paragraph, Sentence, Span } from "../plugin.ts";
|
|
|
3
3
|
|
|
4
4
|
// Sentences that are not the writer's running prose and so are not compared for register: wording quoted under a label
|
|
5
5
|
// (例:…, Q: …, a paragraph under a lone 用例), the value of a field set out under a marked label line (■ 調査目的\n…) and a contact
|
|
6
|
-
// block (a paragraph with a 〒 or 電話: line). A note on a ※ line and a cell of a table laid out as lines are set apart too, but
|
|
6
|
+
// block (a paragraph with a 〒 or 電話: line). A note on a ※ or * line and a cell of a table laid out as lines are set apart too, but
|
|
7
7
|
// stay counted: only some of a table's cells take the shape, and dropping those would leave the rest a smaller minority. Pure.
|
|
8
8
|
|
|
9
9
|
/** A label, a number after it (Q1, 例2), then the mark that ends it. */
|
|
@@ -78,13 +78,13 @@ export const fieldValueSentences = (sentences: readonly Sentence[], source: stri
|
|
|
78
78
|
return new Set(sentences.filter((sentence) => values.some((value) => sentence.span.start >= value.start && sentence.span.start < value.end)));
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
/** A line that opens with a reference mark (※PDF
|
|
82
|
-
const NOTE_LINE = /^[ \t\u3000]
|
|
81
|
+
/** A line that opens with a reference mark, ※ or the full-width asterisk * (※PDFファイルが開けない…, *図は圧縮しているため…): a note set beside the text. */
|
|
82
|
+
const NOTE_LINE = /^[ \t\u3000]*[※*]/u;
|
|
83
83
|
|
|
84
84
|
const lineStartOf = (source: string, offset: number): number => source.lastIndexOf("\n", offset - 1) + 1;
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* The sentences on a line that opens with
|
|
87
|
+
* The sentences on a line that opens with ※ or *. A note (※…の場合はこちらをご覧ください。) is the page's aside to the reader, written in
|
|
88
88
|
* its own register whatever the text around it uses.
|
|
89
89
|
*/
|
|
90
90
|
export const referenceNoteSentences = (sentences: readonly Sentence[], source: string): Set<Sentence> =>
|
|
@@ -70,6 +70,25 @@ export const isTakenUp = (next: Sentence | undefined, between: string, openers:
|
|
|
70
70
|
return openers.some((opener) => opening.has(opener.pattern));
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
/** The particles a sentence closes with, joined (か/な → かな), after its last word and before its marks. */
|
|
74
|
+
const closingParticles = (tokens: readonly Token[]): string => {
|
|
75
|
+
const words = tokens.filter((token) => token.pos !== "PUNCT" && !TRAILING_MARKS.has(token.surface));
|
|
76
|
+
const start = words.findLastIndex((token) => token.pos !== "PART") + 1;
|
|
77
|
+
return words
|
|
78
|
+
.slice(start)
|
|
79
|
+
.map((token) => token.surface)
|
|
80
|
+
.join("");
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A sentence that closes with a particle of address from address-particle (…含まれているよ。…違うんだよ。…のかな?): the writer speaks
|
|
85
|
+
* to the reader on purpose, in a voice a polite page sets among its sentences, not a slip into the plain register.
|
|
86
|
+
*/
|
|
87
|
+
export const isAddressed = (sentence: Sentence, particles: readonly LexiconEntry[]): boolean => {
|
|
88
|
+
const closing = closingParticles(sentence.tokens ?? []);
|
|
89
|
+
return closing !== "" && particles.some((particle) => closing.endsWith(particle.pattern));
|
|
90
|
+
};
|
|
91
|
+
|
|
73
92
|
const EXCLAMATION = /[!!][\s」』))]*$/u;
|
|
74
93
|
|
|
75
94
|
/** A sentence closed by an exclamation mark (わかるかっ!!!): a cry in the writer's voice, said plainly in either register. */
|
|
@@ -16,6 +16,8 @@ const valuedOf = (doc: ProseDocument, lexicon: string, group?: string): ValuedWo
|
|
|
16
16
|
const wordsOf = (doc: ProseDocument): RequirementWords => ({
|
|
17
17
|
required: patternsOf(doc, "requirement-heading", "required"),
|
|
18
18
|
preferred: patternsOf(doc, "requirement-heading", "preferred"),
|
|
19
|
+
subjects: patternsOf(doc, "requirement-heading", "subject"),
|
|
20
|
+
joiners: patternsOf(doc, "requirement-heading", "joiner"),
|
|
19
21
|
units: valuedOf(doc, "requirement-length-unit"),
|
|
20
22
|
before: patternsOf(doc, "requirement-length-word", "before"),
|
|
21
23
|
after: patternsOf(doc, "requirement-length-word", "after"),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Detector, DetectorOptions, Finding, Lexicon, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
|
|
1
|
+
import type { Detector, DetectorOptions, Finding, LengthUnit, Lexicon, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
|
|
2
2
|
import { escapeRegExp } from "../orthography.ts";
|
|
3
3
|
import { isWithinAny, quotedIn } from "../quoted-span.ts";
|
|
4
4
|
import { entryOpens } from "./lexicon-match.ts";
|
|
@@ -163,7 +163,8 @@ export const sentenceCommaCount: Detector = (doc, options): Finding[] => {
|
|
|
163
163
|
return known;
|
|
164
164
|
};
|
|
165
165
|
const counts: TokenTest = (token, at, tokens) => isComma(token) && !separatesItems(at, tokens) && !listedIn(tokens).has(at);
|
|
166
|
-
|
|
166
|
+
const eras = (doc.lexicons["calendar-era"] ?? []).map((entry) => entry.pattern);
|
|
167
|
+
return sentencesOver({ ...doc, sentences: doc.sentences.filter((sentence) => !isFlattenedTable(sentence.text, eras)) }, options.limit, counts);
|
|
167
168
|
};
|
|
168
169
|
|
|
169
170
|
const CONJUNCTIVE = "SCONJ";
|
|
@@ -221,14 +222,17 @@ export const CONTINUING_LEXICON = "demonstrative-continuing";
|
|
|
221
222
|
const runCount = (run: readonly Opened[], continuing: ReadonlySet<string>): number =>
|
|
222
223
|
run.filter((opened, at) => !(opened.opener !== undefined && continuing.has(opened.opener) && run[at - 1]?.opener === opened.opener)).length;
|
|
223
224
|
|
|
224
|
-
|
|
225
|
+
/** Words are set apart by spaces, so sentences quoted together are too (…small purchases. This means …); characters are not. */
|
|
226
|
+
const joinerOf = (unit: LengthUnit): string => (unit === "char" ? "" : " ");
|
|
227
|
+
|
|
228
|
+
const runFinding = (run: readonly Opened[], count: number, options: DetectorOptions, unit: LengthUnit): Finding => {
|
|
225
229
|
const first = run[0];
|
|
226
230
|
return {
|
|
227
231
|
rule: "",
|
|
228
232
|
severity: "info",
|
|
229
233
|
line: 0,
|
|
230
234
|
column: 0,
|
|
231
|
-
quote: run.map(({ sentence }) => sentence.text.trim()).join(
|
|
235
|
+
quote: run.map(({ sentence }) => sentence.text.trim()).join(joinerOf(unit)),
|
|
232
236
|
values: { word: first?.opener ?? "", count, limit: options.limit, offset: first?.sentence.span.start ?? 0 },
|
|
233
237
|
};
|
|
234
238
|
};
|
|
@@ -242,6 +246,6 @@ export const openerRun: Detector = (doc, options): Finding[] => {
|
|
|
242
246
|
openerRuns(paragraph.sentences, lexicon, notOpeners)
|
|
243
247
|
.map((run) => ({ run, count: runCount(run, continuing) }))
|
|
244
248
|
.filter(({ count }) => count > options.limit)
|
|
245
|
-
.map(({ run, count }) => runFinding(run, count, options)),
|
|
249
|
+
.map(({ run, count }) => runFinding(run, count, options, doc.lengthUnit)),
|
|
246
250
|
);
|
|
247
251
|
};
|
|
@@ -11,7 +11,7 @@ import { chronologyRows } from "../chronology-rows.ts";
|
|
|
11
11
|
import { isNeutralPlainShape } from "./register-neutral-shape.ts";
|
|
12
12
|
import { spokenAnswerSentences } from "./register-interview.ts";
|
|
13
13
|
import { contactBlockSentences, fieldValueSentences, labelledQuoteSentences, referenceNoteSentences, tableCellSentences } from "./register-set-apart.ts";
|
|
14
|
-
import { endsInSetGreeting, isDeclaration, isExclamation, isTakenUp } from "./register-voice.ts";
|
|
14
|
+
import { endsInSetGreeting, isAddressed, isDeclaration, isExclamation, isTakenUp } from "./register-voice.ts";
|
|
15
15
|
import { entriesForGenre } from "../lexicon-genres.ts";
|
|
16
16
|
import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
|
|
17
17
|
|
|
@@ -34,15 +34,16 @@ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span, To
|
|
|
34
34
|
/**
|
|
35
35
|
* quiet: 常体と読めるが、願い・問い・言いさしの形(register-neutral-shape.ts)の文。どちらの調子の文書にも現れるので指さない。
|
|
36
36
|
* 丁寧な形でしか言わない挨拶(お疲れ様でした。)、演説の決意の言い切り(二度と繰り返さない。)、
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* 次の文が「そんな」「これだけ」で受ける場面の書き出し、「!」で終わる叫び(わかるかっ!)、読み手に呼びかける終助詞で終わる文(…いるよ。)も quiet(register-voice.ts)。
|
|
38
|
+
* ※や*で始まる行の注記と、行に並べ直した表のセル(制限なし。)は、どちらの調子でも quiet(register-set-apart.ts)。
|
|
39
39
|
* インタビューの答え(聞き手の「――」の後の段落)は話した言葉なので quiet(register-interview.ts)。
|
|
40
40
|
* 数には入れる。数から外すと、常体を何度も使う文書(演説)で少数派が閾値を下回り、残りの常体の文が新たに指されてしまう。
|
|
41
41
|
*/
|
|
42
42
|
type Entry = { readonly sentence: Sentence; readonly register: Register; readonly group: number | undefined; readonly quiet: boolean };
|
|
43
43
|
|
|
44
44
|
/** 文の調子と quiet を決める語彙表。polite は polite-ending、neutral は neutral-ending、requests は neutral-request、wishes は neutral-wish、
|
|
45
|
-
* greetings は set-polite-phrase、declaration と resolves は declaration-particle と declaration-ending を文書の genre で絞ったもの、openers は takeup-opener
|
|
45
|
+
* greetings は set-polite-phrase、declaration と resolves は declaration-particle と declaration-ending を文書の genre で絞ったもの、openers は takeup-opener、
|
|
46
|
+
* address は address-particle。 */
|
|
46
47
|
type EndingWords = {
|
|
47
48
|
readonly polite: readonly LexiconEntry[];
|
|
48
49
|
readonly neutral: readonly LexiconEntry[];
|
|
@@ -52,6 +53,7 @@ type EndingWords = {
|
|
|
52
53
|
readonly declaration: readonly LexiconEntry[];
|
|
53
54
|
readonly resolves: readonly LexiconEntry[];
|
|
54
55
|
readonly openers: readonly LexiconEntry[];
|
|
56
|
+
readonly address: readonly LexiconEntry[];
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
type Read = { readonly register: Register; readonly quiet: boolean };
|
|
@@ -65,6 +67,7 @@ const endingWords = (doc: ProseDocument, polite: readonly LexiconEntry[], genre:
|
|
|
65
67
|
declaration: entriesForGenre(doc.lexicons["declaration-particle"] ?? [], genre),
|
|
66
68
|
resolves: entriesForGenre(doc.lexicons["declaration-ending"] ?? [], genre),
|
|
67
69
|
openers: doc.lexicons["takeup-opener"] ?? [],
|
|
70
|
+
address: doc.lexicons["address-particle"] ?? [],
|
|
68
71
|
});
|
|
69
72
|
|
|
70
73
|
/** 調子を持つ文のうち、指さない形か。next は同じ文書の次の文、between はその間の文字列。 */
|
|
@@ -74,6 +77,7 @@ const isQuiet = (sentence: Sentence, ending: readonly Token[], register: Registe
|
|
|
74
77
|
: isNeutralPlainShape(sentence, ending, words.requests, words.wishes) ||
|
|
75
78
|
isDeclaration(sentence, ending, words.declaration, words.resolves) ||
|
|
76
79
|
isExclamation(sentence) ||
|
|
80
|
+
isAddressed(sentence, words.address) ||
|
|
77
81
|
isTakenUp(next, between, words.openers);
|
|
78
82
|
|
|
79
83
|
const registerOfSentence = (doc: ProseDocument, index: number, words: EndingWords): Read | undefined => {
|
|
@@ -11,10 +11,11 @@ import { isInListItem, isReferenceLine, isTitleLine, quotedTitleWords, remarkAft
|
|
|
11
11
|
|
|
12
12
|
type Measure = { readonly size: number; readonly limit: number; readonly variant?: string };
|
|
13
13
|
|
|
14
|
-
/** The page markers' pattern, the citation signals ("see") and the spans of the list items, read once per document. */
|
|
14
|
+
/** The page markers' pattern, the citation signals ("see"), the era names and the spans of the list items, read once per document. */
|
|
15
15
|
type SentenceWords = {
|
|
16
16
|
readonly markers: RegExp | undefined;
|
|
17
17
|
readonly citationSignals: readonly string[];
|
|
18
|
+
readonly eras: readonly string[];
|
|
18
19
|
readonly listItems: readonly { readonly start: number; readonly end: number }[];
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -27,6 +28,16 @@ type SentenceWords = {
|
|
|
27
28
|
const unwrittenWords = (sentence: Sentence, text: string, listItems: SentenceWords["listItems"]): number =>
|
|
28
29
|
termSeriesSaving(text) + authorListSaving(text) + (isInListItem(sentence.span, listItems) || isReferenceLine(text) ? quotedTitleWords(text) : 0);
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A comma or a stop typed with one space before it ("the same brick , and"). It is no word of its own. One space only:
|
|
33
|
+
* the spaces that hide markup ("**TITLE**.", "[link](url),") are left counted, as the measure has always read them.
|
|
34
|
+
*/
|
|
35
|
+
const TYPED_LOOSE_STOP = /(?<=[\p{L}\p{N}]) [,.;:!?]+(?=\s|$)/gu;
|
|
36
|
+
|
|
37
|
+
/** A sentence's length; where words are the unit, a typed loose comma or stop is not counted. */
|
|
38
|
+
const sentenceSize = (sentence: Sentence, unit: LengthUnit): number =>
|
|
39
|
+
lengthOf(sentence, unit) - (unit === "word" ? [...sentence.text.matchAll(TYPED_LOOSE_STOP)].length : 0);
|
|
40
|
+
|
|
30
41
|
const sizeOf = (text: string, unit: LengthUnit): number =>
|
|
31
42
|
unit === "word" ? text.split(/\s+/u).filter((word) => word.length > 0).length : text.replace(/\s+/gu, "").length;
|
|
32
43
|
|
|
@@ -47,7 +58,7 @@ const measureOf = (sentence: Sentence, unit: LengthUnit, options: DetectorOption
|
|
|
47
58
|
const embedded = sentence.embeddedLanguage;
|
|
48
59
|
const limit = embedded === undefined ? undefined : options.embeddedLimits?.[embedded.id];
|
|
49
60
|
if (embedded === undefined || limit === undefined) return { size: ownSize(sentence, unit, words), limit: options.limit };
|
|
50
|
-
return { size:
|
|
61
|
+
return { size: sentenceSize(sentence, embedded.lengthUnit), limit, variant: `embedded-${embedded.id}` };
|
|
51
62
|
};
|
|
52
63
|
|
|
53
64
|
/** Code or a citation string: nothing in it is the writer's sentence. A title line too, where words are the unit. */
|
|
@@ -55,8 +66,8 @@ const isUnwritten = (sentence: Sentence, text: string, unit: LengthUnit, words:
|
|
|
55
66
|
isGrammarBlock(sentence.text) || isCitationString(text, words.citationSignals) || (unit === "word" && isTitleLine(text));
|
|
56
67
|
|
|
57
68
|
/** The parts measured one by one when the splitter ran several things into one sentence (label lines, table cells, a quotation). */
|
|
58
|
-
const partsOf = (sentence: Sentence, text: string): readonly string[] | undefined =>
|
|
59
|
-
labelLineParts(sentence.text) ?? flattenedTableParts(text) ?? colonQuotationParts(text) ?? parentheticalSentenceParts(text);
|
|
69
|
+
const partsOf = (sentence: Sentence, text: string, eras: readonly string[]): readonly string[] | undefined =>
|
|
70
|
+
labelLineParts(sentence.text) ?? flattenedTableParts(text, eras) ?? colonQuotationParts(text) ?? parentheticalSentenceParts(text);
|
|
60
71
|
|
|
61
72
|
/** The length of a sentence in the document's language, without what the writer did not write as one. */
|
|
62
73
|
const ownSize = (sentence: Sentence, unit: LengthUnit, words: SentenceWords): number => {
|
|
@@ -64,12 +75,12 @@ const ownSize = (sentence: Sentence, unit: LengthUnit, words: SentenceWords): nu
|
|
|
64
75
|
if (isUnwritten(sentence, text, unit, words)) return 0;
|
|
65
76
|
const aroundCitation = unit === "word" ? wordsAroundCitation(text, words.citationSignals) : undefined;
|
|
66
77
|
if (aroundCitation !== undefined) return sizeOf(aroundCitation, unit);
|
|
67
|
-
const parts = partsOf(sentence, text);
|
|
78
|
+
const parts = partsOf(sentence, text, words.eras);
|
|
68
79
|
if (parts !== undefined) return Math.max(0, ...parts.map((part) => sizeOf(part, unit) - pageMarkerSize(part, words.markers, unit)));
|
|
69
80
|
const remark = unit === "word" ? remarkAfterTitle(text) : undefined;
|
|
70
81
|
if (remark !== undefined) return sizeOf(remark, unit);
|
|
71
82
|
const unwritten = unit === "word" ? unwrittenWords(sentence, text, words.listItems) : 0;
|
|
72
|
-
const size =
|
|
83
|
+
const size = sentenceSize(sentence, unit) - pageMarkerSize(text, words.markers, unit) - unwritten;
|
|
73
84
|
return unit === "char" ? longestQuotedPart(text, size, words.markers) : size;
|
|
74
85
|
};
|
|
75
86
|
|
|
@@ -77,6 +88,7 @@ export const sentenceLength: Detector = (doc, options): Finding[] => {
|
|
|
77
88
|
const words: SentenceWords = {
|
|
78
89
|
markers: pageMarkerPattern((options.lexicon ?? []).map((entry) => entry.pattern)),
|
|
79
90
|
citationSignals: (doc.lexicons["citation-signal"] ?? []).map((entry) => entry.pattern),
|
|
91
|
+
eras: (doc.lexicons["calendar-era"] ?? []).map((entry) => entry.pattern),
|
|
80
92
|
listItems: doc.lists.flatMap((list) => list.itemSpans),
|
|
81
93
|
};
|
|
82
94
|
const long = doc.sentences
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// a converter ran together (…設立1945年7月日染興業…, 39,0439,677…), and a quotation the writer introduces with a colon.
|
|
4
4
|
// Each is measured part by part, or not at all. Pure: the text in, the parts out.
|
|
5
5
|
|
|
6
|
+
import { escapeRegExp } from "../orthography.ts";
|
|
6
7
|
import type { Span } from "../plugin.ts";
|
|
7
8
|
|
|
8
9
|
const LINE_BREAK = /\n/u;
|
|
@@ -46,11 +47,19 @@ const GLUED_NUMBER = /\d[,,]\d{4}|\d(?:[..]\d+){4}/u;
|
|
|
46
47
|
/** A run of numbers, signs and empty-cell dashes (39,0439,6773,503…△0.6); it is cut out when it holds glued cells. */
|
|
47
48
|
const NUMBER_RUN = /[\d,,..△▲-−%%-]+/gu;
|
|
48
49
|
const CUT = "\n";
|
|
49
|
-
/**
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
/** The year of a date that opens a row: four digits, or an era name and its year (昭和59年, 令和元年). */
|
|
51
|
+
const rowYear = (eras: readonly string[]): string =>
|
|
52
|
+
eras.length === 0 ? "[0-90-9]{4}" : `(?:[0-90-9]{4}|(?:${eras.map(escapeRegExp).join("|")})(?:[0-90-9]{1,2}|元))`;
|
|
53
|
+
/** A date that opens a row, run into the cell before it and the cell after it (…設立1945年7月日染興業…, …を開始昭和59年4月東京…). */
|
|
54
|
+
const gluedDate = (eras: readonly string[]): RegExp =>
|
|
55
|
+
new RegExp(
|
|
56
|
+
`(?<=[\\p{Script=Han}\\p{Script=Katakana}\\p{Script=Hiragana}ー])(?=${rowYear(eras)}年[0-90-9]{1,2}月[\\p{Script=Han}\\p{Script=Katakana}\\p{L}])`,
|
|
57
|
+
"gu",
|
|
58
|
+
);
|
|
52
59
|
/** Fewer glued dates than this are a sentence that names a date or two, not the rows of a chronology. */
|
|
53
60
|
const MIN_GLUED_DATES = 3;
|
|
61
|
+
/** A space between Japanese words inside a flattened table: where the converter kept a cell apart (…に開設 (注)1.…). */
|
|
62
|
+
const CELL_SPACE = /(?<=[\p{Script=Han}\p{Script=Katakana}\p{Script=Hiragana}ー)」])\s+(?=[\p{Script=Han}\p{Script=Katakana}\p{Script=Hiragana}(「])/u;
|
|
54
63
|
|
|
55
64
|
const nonEmpty = (parts: readonly string[]): string[] => parts.map((part) => part.trim()).filter((part) => part !== "");
|
|
56
65
|
|
|
@@ -61,11 +70,14 @@ export const hasGluedNumbers = (text: string): boolean => GLUED_NUMBER.test(text
|
|
|
61
70
|
export const gluedNumberSpans = (text: string): Span[] =>
|
|
62
71
|
[...text.matchAll(NUMBER_RUN)].filter((run) => GLUED_NUMBER.test(run[0])).map((run) => ({ start: run.index, end: run.index + run[0].length }));
|
|
63
72
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
73
|
+
/**
|
|
74
|
+
* The cells of a table a converter flattened into one sentence, cut at the glued numbers or at each row's date. eras are
|
|
75
|
+
* the era names a row's year may be written with (the calendar-era lexicon).
|
|
76
|
+
*/
|
|
77
|
+
export const flattenedTableParts = (text: string, eras: readonly string[] = []): readonly string[] | undefined => {
|
|
66
78
|
if (hasGluedNumbers(text)) return nonEmpty(text.replace(NUMBER_RUN, (run) => (GLUED_NUMBER.test(run) ? CUT : run)).split(CUT));
|
|
67
|
-
const rows = text.split(
|
|
68
|
-
return rows.length > MIN_GLUED_DATES ? nonEmpty(rows) : undefined;
|
|
79
|
+
const rows = text.split(gluedDate(eras));
|
|
80
|
+
return rows.length > MIN_GLUED_DATES ? nonEmpty(rows.flatMap((row) => row.split(CELL_SPACE))) : undefined;
|
|
69
81
|
};
|
|
70
82
|
|
|
71
83
|
/** A quotation the writer opens after a colon (has observed: "The credibility of money …"), in straight or curly quotes. */
|
|
@@ -102,8 +114,8 @@ const DITTO_CELLS = /〃\s*〃/u;
|
|
|
102
114
|
* Whether a sentence is a table a converter flattened: glued numbers, rows opened by dates, a header row of cells closed by
|
|
103
115
|
* units, or ditto cells.
|
|
104
116
|
*/
|
|
105
|
-
export const isFlattenedTable = (text: string): boolean =>
|
|
106
|
-
flattenedTableParts(text) !== undefined || (text.match(UNIT_HEADER)?.length ?? 0) >= MIN_UNIT_HEADERS || DITTO_CELLS.test(text);
|
|
117
|
+
export const isFlattenedTable = (text: string, eras: readonly string[] = []): boolean =>
|
|
118
|
+
flattenedTableParts(text, eras) !== undefined || (text.match(UNIT_HEADER)?.length ?? 0) >= MIN_UNIT_HEADERS || DITTO_CELLS.test(text);
|
|
107
119
|
|
|
108
120
|
/** A decimal cell run in between a bracketed cell and the next cell's word ((日本)100.0自動車関連): where one row's cells meet. */
|
|
109
121
|
const GLUED_DECIMAL_CELL = /[))]\d{1,3}\.\d+(?=\p{L})/gu;
|