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
package/src/detectors/signals.ts
CHANGED
|
@@ -322,12 +322,21 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
|
|
|
322
322
|
return alone.map(([acronym, hit]) => acronymFinding(acronym, hit, alone.length, options.limit));
|
|
323
323
|
};
|
|
324
324
|
|
|
325
|
+
/** 二つ重ねて一本に組むダッシュ(——、――)。重ねた二つ目からは、同じ一本の続き。 */
|
|
326
|
+
const DOUBLED_DASH = /[—―]/u;
|
|
327
|
+
const continuesDash = (source: string, offset: number): boolean => DOUBLED_DASH.test(source[offset] ?? "") && DOUBLED_DASH.test(source[offset - 1] ?? "");
|
|
328
|
+
|
|
329
|
+
/** 重ねたダッシュの最後の字の位置。段落の終わりで箇条を導くかは、そこから後ろで見る。 */
|
|
330
|
+
const dashEnd = (source: string, offset: number): number => (continuesDash(source, offset + 1) ? dashEnd(source, offset + 1) : offset);
|
|
331
|
+
|
|
325
332
|
/**
|
|
326
333
|
* ダッシュの多用。英語では正当な用法が多いが、2026 年時点で最も知られた生成文のシグナルでもある。
|
|
327
334
|
* 日本語の組版ではそもそも扱いが難しい。どちらが正しいかは severity の言語別指定で分ける。spec §12.4。
|
|
328
335
|
*/
|
|
329
336
|
export const dashDensity: Detector = (doc, options): Finding[] => {
|
|
330
|
-
const hits = findIn(doc, DASH).filter(
|
|
337
|
+
const hits = findIn(doc, DASH).filter(
|
|
338
|
+
(hit) => !continuesDash(doc.source, hit.offset) && !introducesList(doc.source, dashEnd(doc.source, hit.offset)) && !opensLine(doc.source, hit.offset),
|
|
339
|
+
);
|
|
331
340
|
const first = hits[0];
|
|
332
341
|
const rate = density(doc, hits.length);
|
|
333
342
|
if (wordsOf(doc) < MIN_DOCUMENT_LENGTH[doc.lengthUnit] || first === undefined || rate <= options.limit) return [];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The paragraphs of near-verbatim minutes that open with a speaker's name ("Mara: There's some history ..."). What
|
|
2
|
+
// follows the name is that person's own phrasing as the note-taker recorded it, not the writer's. Pure.
|
|
3
|
+
import type { Span } from "../plugin.ts";
|
|
4
|
+
|
|
5
|
+
/** How many names must each open MIN_TURNS paragraphs: one or two repeated labels are fields (Status:, Comments:). */
|
|
6
|
+
const MIN_SPEAKERS = 3;
|
|
7
|
+
const MIN_TURNS = 3;
|
|
8
|
+
/** The share of the paragraphs the names must open, so a few labelled lines in a report do not make it minutes. */
|
|
9
|
+
const MIN_TURN_SHARE = 0.2;
|
|
10
|
+
|
|
11
|
+
/** A name of up to three words, written at the very start of the paragraph, a colon, then the words said. */
|
|
12
|
+
const TURN = /^(?<name>\p{L}[\p{L}'’.-]*(?: \p{Lu}[\p{L}'’.-]*){0,2}): +\S/u;
|
|
13
|
+
const BLANK_LINES = /\n[ \t\r]*(?:\n[ \t\r]*)+/gu;
|
|
14
|
+
|
|
15
|
+
type Paragraph = { readonly span: Span; readonly name: string | undefined };
|
|
16
|
+
|
|
17
|
+
const paragraphsOf = (source: string): Paragraph[] => {
|
|
18
|
+
const breaks = [...source.matchAll(BLANK_LINES)];
|
|
19
|
+
const starts = [0, ...breaks.map((found) => found.index + found[0].length)];
|
|
20
|
+
const ends = [...breaks.map((found) => found.index), source.length];
|
|
21
|
+
return starts
|
|
22
|
+
.map((start, index) => ({ start, end: ends[index] ?? source.length }))
|
|
23
|
+
.filter(({ start, end }) => source.slice(start, end).trim() !== "")
|
|
24
|
+
.map((span) => ({ span, name: TURN.exec(source.slice(span.start, span.end))?.groups?.["name"] }));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const turnCounts = (paragraphs: readonly Paragraph[]): Map<string, number> =>
|
|
28
|
+
paragraphs.reduce((counts, { name }) => (name === undefined ? counts : counts.set(name, (counts.get(name) ?? 0) + 1)), new Map<string, number>());
|
|
29
|
+
|
|
30
|
+
/** The spans of the paragraphs a speaker's name opens, when the document reads as minutes of who said what; else none. */
|
|
31
|
+
export const speakerTurns = (source: string): Span[] => {
|
|
32
|
+
const paragraphs = paragraphsOf(source);
|
|
33
|
+
const turns = paragraphs.filter((paragraph) => paragraph.name !== undefined);
|
|
34
|
+
const speakers = [...turnCounts(turns).values()].filter((count) => count >= MIN_TURNS).length;
|
|
35
|
+
if (speakers < MIN_SPEAKERS || turns.length < paragraphs.length * MIN_TURN_SHARE) return [];
|
|
36
|
+
return turns.map((turn) => turn.span);
|
|
37
|
+
};
|
package/src/detectors/team.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { joinWords } from "./word-list.ts";
|
|
2
2
|
import { conjugatedSpans } from "./conjugated-entry.ts";
|
|
3
|
-
import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence } from "../plugin.ts";
|
|
3
|
+
import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span } from "../plugin.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* チームの言葉。社内でしか通じない語を、チームが chaff.yaml に自分で並べる。
|
|
@@ -13,23 +13,56 @@ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence } from ".
|
|
|
13
13
|
* 複合動詞(「巻き取る」)は語に割れるので、語の並びで原形に照らす(「巻き取ります」)。
|
|
14
14
|
* 品詞解析があれば原形で当たり、無くても表層で当たる。要求はしない。
|
|
15
15
|
*/
|
|
16
|
-
const
|
|
16
|
+
const textSpans = (sentence: Sentence, wanted: string): Span[] => {
|
|
17
|
+
const at = sentence.text.toLowerCase().indexOf(wanted);
|
|
18
|
+
return at < 0 ? [] : [{ start: at, end: at + wanted.length }];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const lemmaSpans = (sentence: Sentence, wanted: string): Span[] =>
|
|
22
|
+
(sentence.tokens ?? [])
|
|
23
|
+
.filter((token) => token.lemma?.toLowerCase() === wanted)
|
|
24
|
+
.map((token) => ({ start: token.span.start - sentence.span.start, end: token.span.end - sentence.span.start }));
|
|
25
|
+
|
|
26
|
+
/** 活用した形の後ろに詰めて付く語(握っ|た・巻き取り|ます)。指摘には本文に書いた形を引く。 */
|
|
27
|
+
const ENDING_POS = new Set(["AUX", "SCONJ"]);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 当たった範囲を、本文に書いた形まで伸ばす。語の途中で終われば語の終わりまで(巻き取 → 巻き取り)、
|
|
31
|
+
* 詰めて付いた助動詞まで(握っ → 握った)。語の間に空白がある英語は、後ろの語まで伸ばさない。
|
|
32
|
+
*/
|
|
33
|
+
const writtenSpan = (sentence: Sentence, span: Span): Span => {
|
|
34
|
+
const end = sentence.span.start + span.end;
|
|
35
|
+
const tokens = sentence.tokens ?? [];
|
|
36
|
+
const inside = tokens.find((token) => token.span.start < end && end < token.span.end);
|
|
37
|
+
const next = tokens.find((token) => token.span.start === end && ENDING_POS.has(token.pos));
|
|
38
|
+
const reach = inside ?? next;
|
|
39
|
+
return reach === undefined ? span : writtenSpan(sentence, { start: span.start, end: reach.span.end - sentence.span.start });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** 並べた語が文のどこに出たか(文の中の字の範囲)。表層、原形、複合動詞の活用した形の順に、最初の 1 か所。 */
|
|
43
|
+
const firstSpan = (sentence: Sentence, entry: LexiconEntry): Span | undefined => {
|
|
17
44
|
// 大文字小文字は区別しない。英語の文頭の「Circle back」も「circle back」として当てる。
|
|
18
45
|
const wanted = entry.pattern.toLowerCase();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
46
|
+
const found = [...textSpans(sentence, wanted), ...lemmaSpans(sentence, wanted), ...conjugatedSpans(sentence, entry)][0];
|
|
47
|
+
return found === undefined ? undefined : writtenSpan(sentence, found);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const covers = (outer: Span, inner: Span): boolean => outer !== inner && outer.start <= inner.start && inner.end <= outer.end;
|
|
51
|
+
|
|
52
|
+
/** 文に出た、並べた語のそれぞれ。並べた語どうしが重なれば(握る・握っておく)、長い方だけ。 */
|
|
53
|
+
const sentenceHits = (sentence: Sentence, entries: readonly LexiconEntry[]): Span[] => {
|
|
54
|
+
const spans = entries.flatMap((entry) => {
|
|
55
|
+
const span = firstSpan(sentence, entry);
|
|
56
|
+
return span === undefined ? [] : [span];
|
|
57
|
+
});
|
|
58
|
+
const distinct = spans.filter((span, index) => spans.findIndex((other) => other.start === span.start && other.end === span.end) === index);
|
|
59
|
+
return distinct.filter((span) => !distinct.some((other) => covers(other, span))).toSorted((left, right) => left.start - right.start);
|
|
24
60
|
};
|
|
25
61
|
|
|
26
62
|
export const internalJargon: Detector = (doc, options): Finding[] => {
|
|
27
63
|
const entries = options.lexicon ?? [];
|
|
28
64
|
if (entries.length === 0) return [];
|
|
29
|
-
const hits = doc.sentences.flatMap((sentence) => {
|
|
30
|
-
const matched = entries.find((entry) => matches(sentence, entry))?.pattern;
|
|
31
|
-
return matched === undefined ? [] : [{ sentence, matched }];
|
|
32
|
-
});
|
|
65
|
+
const hits = doc.sentences.flatMap((sentence) => sentenceHits(sentence, entries).map((span) => ({ sentence, span })));
|
|
33
66
|
if (hits.length < options.limit) return [];
|
|
34
67
|
return hits.map((hit) => ({
|
|
35
68
|
rule: "internal-jargon",
|
|
@@ -37,7 +70,12 @@ export const internalJargon: Detector = (doc, options): Finding[] => {
|
|
|
37
70
|
line: 0,
|
|
38
71
|
column: 0,
|
|
39
72
|
quote: hit.sentence.text.trim(),
|
|
40
|
-
values: {
|
|
73
|
+
values: {
|
|
74
|
+
matched: hit.sentence.text.slice(hit.span.start, hit.span.end),
|
|
75
|
+
count: hits.length,
|
|
76
|
+
limit: options.limit,
|
|
77
|
+
offset: hit.sentence.span.start + hit.span.start,
|
|
78
|
+
},
|
|
41
79
|
}));
|
|
42
80
|
};
|
|
43
81
|
|
|
@@ -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
|
// One document writing a number and a unit symbol both with a space between them ("5 GB") and without ("5GB"). Neither is
|
|
7
7
|
// called right; per unit, the less common way is reported. The symbols come from each language's lexicon "unit-symbol".
|
|
@@ -65,7 +65,7 @@ export const unitSpacing: Detector = (doc, options): Finding[] => {
|
|
|
65
65
|
severity: "info",
|
|
66
66
|
line: 0,
|
|
67
67
|
column: 0,
|
|
68
|
-
quote: quoteAround(text, odd.offset, odd.offset + odd.written.length),
|
|
68
|
+
quote: sentenceQuoteAt(doc.sentences, odd.offset) ?? quoteAround(text, odd.offset, odd.offset + odd.written.length),
|
|
69
69
|
values: { written: odd.written, usual, count, of, offset: odd.offset },
|
|
70
70
|
}));
|
|
71
71
|
};
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// promptly suspend, 速やかに解除することができる) sets no deadline. The words come from the language package's word
|
|
6
6
|
// lists: vague-deadline, concrete-deadline (a stated limit: 日以内, "within … days") and deadline-permission. Pure.
|
|
7
7
|
import { quoteAt } from "./structure-tree.ts";
|
|
8
|
+
import { sentenceQuoteAt } from "./quote-around.ts";
|
|
8
9
|
import type { Detector, Finding, LexiconEntry, ProseDocument } from "../plugin.ts";
|
|
9
10
|
|
|
10
11
|
export type VagueDeadline = { readonly offset: number; readonly word: string };
|
|
@@ -127,6 +128,6 @@ export const vagueDeadline: Detector = (doc): Finding[] =>
|
|
|
127
128
|
severity: "info",
|
|
128
129
|
line: 0,
|
|
129
130
|
column: 0,
|
|
130
|
-
quote: quoteAt(doc.source, hit.offset),
|
|
131
|
+
quote: sentenceQuoteAt(doc.sentences, hit.offset) ?? quoteAt(doc.source, hit.offset),
|
|
131
132
|
values: { word: hit.word, offset: hit.offset },
|
|
132
133
|
}));
|
package/src/levels.ts
CHANGED
|
@@ -18,11 +18,17 @@ export type Resolved = { readonly level: Level; readonly limit: number; readonly
|
|
|
18
18
|
* ジャンル別の閾値。"business/email" は "business" より細かいので先に当たる。
|
|
19
19
|
* 仕様書の一文と社内メールに同じ文長を課すと、どちらかが必ず間違う。spec §9。
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/** The by_genre key whose numbers a genre takes, or undefined when it takes the rule's default levels. */
|
|
22
|
+
export const genreKeyFor = (rule: RuleDefinition, genre: string | undefined): string | undefined => {
|
|
23
|
+
if (genre === undefined) return undefined;
|
|
23
24
|
const parts = genre.split("/");
|
|
24
25
|
const keys = parts.map((_, index) => parts.slice(0, parts.length - index).join("/"));
|
|
25
|
-
return keys.
|
|
26
|
+
return keys.find((key) => rule.by_genre[key] !== undefined);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const tableFor = (rule: RuleDefinition, genre: string | undefined): LevelTable => {
|
|
30
|
+
const key = genreKeyFor(rule, genre);
|
|
31
|
+
return (key === undefined ? undefined : rule.by_genre[key]) ?? rule.levels;
|
|
26
32
|
};
|
|
27
33
|
|
|
28
34
|
export const resolve = (rule: RuleDefinition, level: Level, genre?: string): Resolved => {
|
|
@@ -130,3 +130,32 @@ export const isInFileName = (text: string, offset: number, length: number): bool
|
|
|
130
130
|
const run = withoutTrailingMarks(text.slice(start, offset + length + (after < 0 ? rest.length : after)));
|
|
131
131
|
return run.replace(EXTENSION, "").length > length && FILE_OR_URL.test(run);
|
|
132
132
|
};
|
|
133
|
+
|
|
134
|
+
/** The word just before a form, with spaces or an opening quotation mark between (A in “A Coiner). */
|
|
135
|
+
const WORD_BEFORE = /(?<!\p{L})(\p{L}+)[\s"“‘']*$/u;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Whether the one-word form at offset follows an article from the lexicon name-count-article (a, an) and is a dictionary
|
|
139
|
+
* word ("A Coiner, a very good workman" beside Mrs. Coiler): a count noun, not a name.
|
|
140
|
+
*/
|
|
141
|
+
export const isAfterCountArticle = (text: string, offset: number, name: string, articles: readonly string[], isKnown: (word: string) => boolean): boolean => {
|
|
142
|
+
const before = WORD_BEFORE.exec(text.slice(text.lastIndexOf("\n", offset - 1) + 1, offset))?.[1]?.toLowerCase();
|
|
143
|
+
return ONE_WORD.test(name) && before !== undefined && articles.includes(before) && isKnown(name.toLowerCase());
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** What may stand between a wrong mark and the form it marks: spaces, a colon. */
|
|
147
|
+
const MARK_GAP = /[\s::]/u;
|
|
148
|
+
|
|
149
|
+
const withoutTrailingGap = (text: string): string => {
|
|
150
|
+
const chars = [...text];
|
|
151
|
+
return chars.slice(0, chars.findLastIndex((char) => !MARK_GAP.test(char)) + 1).join("");
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Whether the form at offset follows a wrong mark from the lexicon name-wrong-mark on its own line (× Rspec beside ○ RSpec):
|
|
156
|
+
* a list showing a wrong spelling on purpose, not a use of the name.
|
|
157
|
+
*/
|
|
158
|
+
export const isMarkedWrong = (text: string, offset: number, marks: readonly string[]): boolean => {
|
|
159
|
+
const before = withoutTrailingGap(text.slice(text.lastIndexOf("\n", offset - 1) + 1, offset));
|
|
160
|
+
return marks.some((mark) => before.endsWith(mark));
|
|
161
|
+
};
|
package/src/phone-numbers.ts
CHANGED
|
@@ -94,13 +94,29 @@ const withoutUnclosedBracket = (written: string): string => written.replace(UNCL
|
|
|
94
94
|
/** URLs covered with spaces, so neither a path segment (/call/) nor an id in one is read. Offsets stay the same. */
|
|
95
95
|
export const withoutUrls = (text: string): string => text.replaceAll(URL, (url) => " ".repeat(url.length));
|
|
96
96
|
|
|
97
|
-
/**
|
|
98
|
-
|
|
97
|
+
/** Link words (at, on, us) written whole right before a number, as one run: "line at ", "us on ". */
|
|
98
|
+
const linkRunOf = (links: readonly string[]): RegExp | undefined =>
|
|
99
|
+
links.length === 0 ? undefined : new RegExp(String.raw`(?:(?<!\p{L})(?:${links.map(escapeRegExp).join("|")})\s+)+$`, "iu");
|
|
100
|
+
|
|
101
|
+
/** Where a number's label is looked for: before the link words that join it to the number (Call us on, our recall line at). */
|
|
102
|
+
const labelEnd = (text: string, offset: number, linkRun: RegExp | undefined): number => {
|
|
103
|
+
if (linkRun === undefined) return offset;
|
|
104
|
+
const lineStart = text.lastIndexOf("\n", offset - 1) + 1;
|
|
105
|
+
const run = linkRun.exec(text.slice(lineStart, offset));
|
|
106
|
+
return run === null ? offset : offset - run[0].length;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The phone numbers of a text that have a label shortly before them on their line; unlabelled digits and URLs are not read.
|
|
111
|
+
* links are the words that may stand between a label and its number (the language's phone-label-link lexicon).
|
|
112
|
+
*/
|
|
113
|
+
export const labelledPhoneNumbers = (source: string, labels: readonly LexiconEntry[], links: readonly string[] = []): PhoneNumber[] => {
|
|
99
114
|
const text = withoutUrls(source);
|
|
115
|
+
const linkRun = linkRunOf(links);
|
|
100
116
|
const read = (match: RegExpExecArray, spaced: boolean): PhoneNumber[] => {
|
|
101
117
|
const digits = match[0].replaceAll(NOT_DIGIT, "");
|
|
102
118
|
if (digits.length < MIN_DIGITS || digits.length > MAX_DIGITS) return [];
|
|
103
|
-
const label = labelBefore(text, match.index, labels);
|
|
119
|
+
const label = labelBefore(text, labelEnd(text, match.index, linkRun), labels);
|
|
104
120
|
if (label === undefined) return [];
|
|
105
121
|
if (spaced && !COUNTRY_CODE_START.test(match[0]) && !LABEL_TO_NUMBER.test(label.between)) return [];
|
|
106
122
|
const matched = match[0].trim();
|
package/src/plugin.ts
CHANGED
|
@@ -79,6 +79,8 @@ export type LexiconEntry = {
|
|
|
79
79
|
readonly heading_only?: boolean | undefined;
|
|
80
80
|
/** The entry counts only where it opens the sentence (近年、… but not その後、近年の…). phrase-match honours it. */
|
|
81
81
|
readonly opens?: boolean | undefined;
|
|
82
|
+
/** The entry does not count where the next word has one of these parts of speech: "your welcome email" is a welcome email, not "you're welcome". phrase-match honours it when tokens are read. */
|
|
83
|
+
readonly not_before_pos?: readonly string[] | undefined;
|
|
82
84
|
/** pattern を adapter が語に分けたもの。品詞が読めるときだけ core が入れる。語彙表を書く側は書かない。 */
|
|
83
85
|
readonly tokens?: readonly Token[] | undefined;
|
|
84
86
|
};
|
package/src/render/explain.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definedLevels, resolve, severityAt } from "../levels.ts";
|
|
1
|
+
import { definedLevels, genreKeyFor, resolve, severityAt } from "../levels.ts";
|
|
2
2
|
import { fill, localized, readableText } from "./text.ts";
|
|
3
3
|
import { SEVERITY_NAME } from "./severity-name.ts";
|
|
4
4
|
import { uiLanguageOf, type Texts } from "../ui.ts";
|
|
@@ -9,8 +9,10 @@ import { depthMeaning } from "../rewrite-depth.ts";
|
|
|
9
9
|
|
|
10
10
|
const TEXT: Texts<{
|
|
11
11
|
readonly off: string;
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
12
|
+
readonly numbersFor: (key: string | undefined, genre: string | undefined) => string;
|
|
13
|
+
readonly othersOwn: (others: readonly string[]) => string;
|
|
14
|
+
readonly othersDefault: string;
|
|
15
|
+
readonly sentenceGap: string;
|
|
14
16
|
readonly experimental: string;
|
|
15
17
|
readonly alone: (id: string) => string;
|
|
16
18
|
readonly howToFix: string;
|
|
@@ -22,13 +24,19 @@ const TEXT: Texts<{
|
|
|
22
24
|
readonly severities: string;
|
|
23
25
|
readonly now: (level: string) => string;
|
|
24
26
|
readonly nowNumber: (limit: string) => string;
|
|
27
|
+
readonly notRun: (why: string) => string;
|
|
25
28
|
readonly from: (source: string) => string;
|
|
26
29
|
readonly change: (id: string) => string;
|
|
27
30
|
}> = {
|
|
28
31
|
ja: {
|
|
29
32
|
off: "見ない",
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
numbersFor: (key, genre) => {
|
|
34
|
+
const owner = key === undefined ? "既定" : ` ${key} `;
|
|
35
|
+
return genre === undefined || genre === key ? `この数字は${owner}のものです。` : `この数字は${owner}のもので、${genre} はこれを使います。`;
|
|
36
|
+
},
|
|
37
|
+
othersOwn: (others) => `${others.join(" / ")} は別の数字を持っています。`,
|
|
38
|
+
othersDefault: "ほかのジャンルは既定の数字を使います。",
|
|
39
|
+
sentenceGap: "",
|
|
32
40
|
experimental: "このルールはまだ試験中で、既定では動きません(--experimental で動きます)。",
|
|
33
41
|
alone: (id) => `このルールだけを動かす: npx chaffjs enable ${id}(chaff.yaml の rules に ${id}: normal と書くのと同じです)`,
|
|
34
42
|
howToFix: "直しかた",
|
|
@@ -38,17 +46,24 @@ const TEXT: Texts<{
|
|
|
38
46
|
definedIn: (plugin) =>
|
|
39
47
|
plugin === undefined ? "このルールはチームが chaff.yaml の custom_rules で決めたものです。" : `このルールはプラグイン ${plugin} のものです。`,
|
|
40
48
|
values: "設定できる値:",
|
|
41
|
-
times: "回",
|
|
49
|
+
times: "{limit} 回",
|
|
42
50
|
severities: "設定できる値(数える上限は無く、指摘の重さが変わります):",
|
|
43
51
|
now: (level) => `いまは ${level} です。`,
|
|
44
52
|
nowNumber: (limit) => `いまは段階ではなく数です: ${limit}。`,
|
|
53
|
+
notRun: (why) => `いまは動きません(${why})。`,
|
|
45
54
|
from: (source) => `(${source} で決めています)`,
|
|
46
55
|
change: (id) => `変える: npx chaffjs relax ${id} --why "理由"`,
|
|
47
56
|
},
|
|
48
57
|
en: {
|
|
49
58
|
off: "not checked",
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
numbersFor: (key, genre) => {
|
|
60
|
+
if (key === undefined)
|
|
61
|
+
return genre === undefined ? "These numbers are for the default genre." : `These numbers are the default ones, which ${genre} takes.`;
|
|
62
|
+
return genre === key ? `These numbers are for ${key}.` : `These numbers are for ${key}, which ${genre} takes.`;
|
|
63
|
+
},
|
|
64
|
+
othersOwn: (others) => `${others.join(" / ")} ${others.length === 1 ? "has numbers of its own" : "have numbers of their own"}.`,
|
|
65
|
+
othersDefault: "Other genres take the default numbers.",
|
|
66
|
+
sentenceGap: " ",
|
|
52
67
|
experimental: "This rule is still experimental and does not run by default (--experimental runs it).",
|
|
53
68
|
alone: (id) => `Turn on this rule alone: npx chaffjs enable ${id} (the same as rules: { ${id}: normal } in chaff.yaml)`,
|
|
54
69
|
howToFix: "How to fix",
|
|
@@ -57,10 +72,11 @@ const TEXT: Texts<{
|
|
|
57
72
|
definedIn: (plugin) =>
|
|
58
73
|
plugin === undefined ? "The team defined this rule under custom_rules in chaff.yaml." : `This rule comes from the plugin ${plugin}.`,
|
|
59
74
|
values: "Levels:",
|
|
60
|
-
times: "times",
|
|
75
|
+
times: "{limit} {limit|time|times}",
|
|
61
76
|
severities: "Levels (there is no limit to count to; a level sets how a finding is marked):",
|
|
62
77
|
now: (level) => `Now: ${level}.`,
|
|
63
78
|
nowNumber: (limit) => `Now: ${limit}, set as a number rather than a level.`,
|
|
79
|
+
notRun: (why) => `Now: not run (${why}).`,
|
|
64
80
|
from: (source) => ` (set by ${source})`,
|
|
65
81
|
change: (id) => `Change it: npx chaffjs relax ${id} --why "reason"`,
|
|
66
82
|
},
|
|
@@ -72,7 +88,7 @@ const TEXT: Texts<{
|
|
|
72
88
|
*/
|
|
73
89
|
const limitText = (rule: RuleDefinition, limit: number, language: string): string => {
|
|
74
90
|
const meaning = localized(rule.guide?.levelMeaning ?? {}, language);
|
|
75
|
-
return meaning === "" ?
|
|
91
|
+
return fill(meaning === "" ? TEXT[uiLanguageOf(language)].times : meaning, { limit });
|
|
76
92
|
};
|
|
77
93
|
|
|
78
94
|
/** What a level holds: the limit a detector counts to, or the severity a rule with nothing to count gives. */
|
|
@@ -90,9 +106,11 @@ const levelLine = (rule: RuleDefinition, level: Level, current: Level | undefine
|
|
|
90
106
|
|
|
91
107
|
/** ジャンルで数字が変わる rule は、それを言わないと「設定したのに効かない」に見える。 */
|
|
92
108
|
const genreNote = (rule: RuleDefinition, genre: string | undefined, text: (typeof TEXT)["ja"]): string[] => {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
const key = genreKeyFor(rule, genre);
|
|
110
|
+
const others = Object.keys(rule.by_genre).filter((other) => other !== key);
|
|
111
|
+
if (others.length === 0 && key === undefined) return [];
|
|
112
|
+
const othersLine = others.length === 0 ? text.othersDefault : text.othersOwn(others);
|
|
113
|
+
return ["", ` ${text.numbersFor(key, genre)}${text.sentenceGap}${othersLine}`];
|
|
96
114
|
};
|
|
97
115
|
|
|
98
116
|
/** A team's rule shows its example, before and after, and says where it was defined. */
|
|
@@ -117,6 +135,13 @@ export type ExplainSettings = {
|
|
|
117
135
|
readonly limit?: number | undefined;
|
|
118
136
|
/** The rule is off only because it is experimental, so naming it would run it: say how. */
|
|
119
137
|
readonly offOnlyAsExperimental?: boolean;
|
|
138
|
+
/** Why the genre keeps the rule from running, as a run lists it: then no level is current. */
|
|
139
|
+
readonly genreStop?: string | undefined;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const nowLine = (rule: RuleDefinition, current: Level, limit: number | undefined, language: string): string => {
|
|
143
|
+
const text = TEXT[uiLanguageOf(language)];
|
|
144
|
+
return limit === undefined ? text.now(current) : text.nowNumber(limitText(rule, limit, language));
|
|
120
145
|
};
|
|
121
146
|
|
|
122
147
|
/** rule の意図と根拠を読む。指摘に納得できないときの入口。 */
|
|
@@ -124,10 +149,15 @@ export const renderExplain = (rule: RuleDefinition, current: Level, language: st
|
|
|
124
149
|
const { optionLayers = [], levelFrom } = settings;
|
|
125
150
|
// A rule with nothing to count has no number to set; chaff.yaml's number on it is reported as a problem and ignored.
|
|
126
151
|
const limit = rule.level_sets === "severity" ? undefined : settings.limit;
|
|
127
|
-
const
|
|
152
|
+
const { genreStop } = settings;
|
|
153
|
+
const marked = limit === undefined && genreStop === undefined ? current : undefined;
|
|
128
154
|
const text = TEXT[uiLanguageOf(language)];
|
|
129
155
|
const experimental =
|
|
130
|
-
rule.status === "experimental"
|
|
156
|
+
rule.status === "experimental" && genreStop === undefined
|
|
157
|
+
? [` ${text.experimental}`, ...(settings.offOnlyAsExperimental === true ? [` ${text.alone(rule.id)}`] : [])]
|
|
158
|
+
: [];
|
|
159
|
+
const from = levelFrom === undefined ? "" : text.from(levelFrom);
|
|
160
|
+
const now = genreStop === undefined ? `${nowLine(rule, current, limit, language)}${from}` : text.notRun(genreStop);
|
|
131
161
|
return [
|
|
132
162
|
"",
|
|
133
163
|
` ${readableText(rule, rule.name, language)} (${rule.id})`,
|
|
@@ -143,7 +173,7 @@ export const renderExplain = (rule: RuleDefinition, current: Level, language: st
|
|
|
143
173
|
...genreNote(rule, genre, text),
|
|
144
174
|
...optionLines(rule, optionLayers, language),
|
|
145
175
|
"",
|
|
146
|
-
` ${
|
|
176
|
+
` ${now}`,
|
|
147
177
|
...experimental,
|
|
148
178
|
"",
|
|
149
179
|
` ${text.change(rule.id)}`,
|
package/src/render/options.ts
CHANGED
|
@@ -29,18 +29,23 @@ const TEXT: Texts<{ readonly heading: string; readonly byDefault: string; readon
|
|
|
29
29
|
{
|
|
30
30
|
ja: {
|
|
31
31
|
heading: "オプション(chaff.yaml の options で決めます):",
|
|
32
|
-
byDefault: "
|
|
33
|
-
from: (source) =>
|
|
32
|
+
byDefault: "(既定)",
|
|
33
|
+
from: (source) => `(${source} から)`,
|
|
34
34
|
howTo: (id) => `決める: chaff.yaml に options: { ${id}: { <名前>: <値> } } を書く`,
|
|
35
35
|
},
|
|
36
36
|
en: {
|
|
37
37
|
heading: "Options (set under options in chaff.yaml):",
|
|
38
|
-
byDefault: "default",
|
|
39
|
-
from: (source) => `from ${source}`,
|
|
38
|
+
byDefault: "(default)",
|
|
39
|
+
from: (source) => `(from ${source})`,
|
|
40
40
|
howTo: (id) => `Set one: write options: { ${id}: { <name>: <value> } } in chaff.yaml`,
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
/** The narrowest column a choice name is padded to, so short names line up as before. */
|
|
45
|
+
const CHOICE_COLUMN = 11;
|
|
46
|
+
/** The spaces between the longest choice name and its meaning. */
|
|
47
|
+
const CHOICE_GAP = 2;
|
|
48
|
+
|
|
44
49
|
/** A rule's options for explain: each one's value now and where it came from, what it decides, and each choice's meaning. */
|
|
45
50
|
export const optionLines = (rule: RuleDefinition, layers: readonly OptionLayer[], language: string): string[] => {
|
|
46
51
|
if (rule.options === undefined) return [];
|
|
@@ -49,10 +54,11 @@ export const optionLines = (rule: RuleDefinition, layers: readonly OptionLayer[]
|
|
|
49
54
|
const lines = Object.entries(rule.options).flatMap(([name, option]) => {
|
|
50
55
|
const now = settled[name];
|
|
51
56
|
const source = now === undefined || now.from === DEFAULT_SOURCE ? text.byDefault : text.from(now.from);
|
|
57
|
+
const width = Math.max(CHOICE_COLUMN, ...Object.keys(option.choiceNames).map((choice) => choice.length + CHOICE_GAP));
|
|
52
58
|
const choices = Object.entries(option.choiceNames).map(
|
|
53
|
-
([choice, meaning]) => ` ${choice === now?.value ? "→" : " "} ${choice.padEnd(
|
|
59
|
+
([choice, meaning]) => ` ${choice === now?.value ? "→" : " "} ${choice.padEnd(width)}${localized(meaning, language)}`,
|
|
54
60
|
);
|
|
55
|
-
return [` ${name}: ${printed(now?.value ?? option.default)}
|
|
61
|
+
return [` ${name}: ${printed(now?.value ?? option.default)} ${source}`, ` ${localized(option.about, language)}`, ...choices];
|
|
56
62
|
});
|
|
57
63
|
return ["", ` ${text.heading}`, ...lines, "", ` ${text.howTo(rule.id)}`];
|
|
58
64
|
};
|
package/src/render/text.ts
CHANGED
|
@@ -22,16 +22,29 @@ export const templateForReading = (template: string, readings: Readonly<Record<s
|
|
|
22
22
|
/** A rule's text for one finding, with the finding's values in it. */
|
|
23
23
|
export const filledText = (field: Localized, finding: Finding, language: string): string => fill(localized(field, language), finding.values);
|
|
24
24
|
|
|
25
|
+
/** An English reading that opens with a determiner (the word found) describes the value; one that does not (always, N) is a sample of it. */
|
|
26
|
+
const DESCRIBING = /^(?:the|a|an|another|one|how)\s/iu;
|
|
27
|
+
/** A stand-in for the value itself (〇〇), which reads as the word in quotation marks. */
|
|
28
|
+
const STAND_IN = /^〇+$/u;
|
|
29
|
+
const QUOTED_PLACEHOLDER = /([「『“"])\{(\w+)\}([」』”"])/gu;
|
|
30
|
+
const CLOSER: Readonly<Record<string, string>> = { "「": "」", "『": "』", "“": "”", '"': '"' };
|
|
31
|
+
|
|
32
|
+
/** A description in quotation marks reads as if it were the word itself (Change it to 「直した書き方」), so its marks go. */
|
|
33
|
+
const unquoteDescriptions = (template: string, describing: ReadonlySet<string>): string =>
|
|
34
|
+
template.replace(QUOTED_PLACEHOLDER, (whole, open: string, key: string, close: string) =>
|
|
35
|
+
CLOSER[open] === close && describing.has(key) ? `{${key}}` : whole,
|
|
36
|
+
);
|
|
37
|
+
|
|
25
38
|
/** A rule's text where no finding fills it (explain, rules --json, the rule reference): each value as the rule's words for it. */
|
|
26
39
|
export const readableText = (rule: Pick<RuleDefinition, "placeholders">, field: Localized, language: string): string => {
|
|
27
40
|
// The same fallback as the text itself: an English-only rule read in Japanese still gets its English words.
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
34
|
-
return templateForReading(localized(field, language), readings);
|
|
41
|
+
const entries = Object.entries(rule.placeholders ?? {}).flatMap(([key, reading]) => {
|
|
42
|
+
const words = localized(reading, language);
|
|
43
|
+
return words === "" ? [] : [{ key, words, describing: DESCRIBING.test(reading["en"] ?? "") && !STAND_IN.test(words) }];
|
|
44
|
+
});
|
|
45
|
+
const readings = Object.fromEntries(entries.map(({ key, words }) => [key, words]));
|
|
46
|
+
const describing = new Set(entries.filter((entry) => entry.describing).map(({ key }) => key));
|
|
47
|
+
return templateForReading(unquoteDescriptions(localized(field, language), describing), readings);
|
|
35
48
|
};
|
|
36
49
|
|
|
37
50
|
const templateOf = (rule: RuleDefinition, finding: Finding): Localized =>
|
package/src/run.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { PatternTimeout } from "./custom/pattern-timeout.ts";
|
|
|
19
19
|
import { PluginRuleFailure } from "./extension/module-detector.ts";
|
|
20
20
|
import { failureReason } from "./extension/failure-text.ts";
|
|
21
21
|
import { tagCoverage } from "./tag-coverage.ts";
|
|
22
|
-
import { compositeSignals } from "./composite-signals.ts";
|
|
22
|
+
import { compositeSignals, signalNames } from "./composite-signals.ts";
|
|
23
23
|
|
|
24
24
|
export type Skipped = {
|
|
25
25
|
readonly rule: string;
|
|
@@ -157,6 +157,10 @@ const untagged = (rule: RuleDefinition, doc: ProseDocument): string | undefined
|
|
|
157
157
|
|
|
158
158
|
const suitsGenre = (rule: RuleDefinition, genre: string): boolean => rule.use_for.some((target) => genre.startsWith(target));
|
|
159
159
|
|
|
160
|
+
/** Why the genre keeps the rule from running, in a run's words: use_for leaves the genre out, or its preset turns the rule off and chaff.yaml does not name it. */
|
|
161
|
+
export const genreStop = (rule: RuleDefinition, settings: Settings, preset: Settings, genre: string, reasons: Reasons): string | undefined =>
|
|
162
|
+
!suitsGenre(rule, genre) || (settings[rule.id] === undefined && preset[rule.id] === "off") ? reasons.presetOff(genre) : undefined;
|
|
163
|
+
|
|
160
164
|
const forGenre = (rules: readonly RuleDefinition[], genre: string): RuleDefinition[] => rules.filter((rule) => suitsGenre(rule, genre));
|
|
161
165
|
|
|
162
166
|
/** A rule use_for keeps out of the genre. A rule for another language says that first: no genre would run it here. */
|
|
@@ -212,7 +216,10 @@ export const place = (starts: readonly number[], finding: Finding): Finding => {
|
|
|
212
216
|
* 元の指摘は消さない。`padded-intro` のように単独でも正しい指摘が混ざっており、
|
|
213
217
|
* まとめるために消すと本物の指摘が見えなくなる。
|
|
214
218
|
*/
|
|
215
|
-
|
|
219
|
+
type CompositeContext = { readonly starts: readonly number[]; readonly language: string; readonly rules: readonly RuleDefinition[] };
|
|
220
|
+
|
|
221
|
+
const compositeOf = (rule: RuleDefinition, found: readonly Finding[], limit: number, context: CompositeContext): Finding[] => {
|
|
222
|
+
const { starts, language, rules } = context;
|
|
216
223
|
const fired = compositeSignals(rule.from, found);
|
|
217
224
|
if (fired.length < limit) return [];
|
|
218
225
|
// 数えなかった signal も含めて、最初に出た所に置く。同じ形を 1 種に数えても、指摘の位置は動かない。
|
|
@@ -224,7 +231,13 @@ const compositeOf = (rule: RuleDefinition, found: readonly Finding[], limit: num
|
|
|
224
231
|
line: 0,
|
|
225
232
|
column: 0,
|
|
226
233
|
quote: first?.quote ?? "",
|
|
227
|
-
values: {
|
|
234
|
+
values: {
|
|
235
|
+
word: joinWords(fired, language),
|
|
236
|
+
signals: joinWords(signalNames(fired, rules, uiLanguageOf(language)), language),
|
|
237
|
+
count: fired.length,
|
|
238
|
+
limit,
|
|
239
|
+
offset: first === undefined ? 0 : Number(first.values["offset"] ?? 0),
|
|
240
|
+
},
|
|
228
241
|
}),
|
|
229
242
|
];
|
|
230
243
|
};
|
|
@@ -234,6 +247,17 @@ export type Limits = Readonly<Record<string, number>>;
|
|
|
234
247
|
|
|
235
248
|
export const limitFor = (rule: RuleDefinition, level: Level, genre: string, limits: Limits): number => limits[rule.id] ?? resolve(rule, level, genre).limit;
|
|
236
249
|
|
|
250
|
+
type CompositeLevels = {
|
|
251
|
+
readonly levelOf: (rule: RuleDefinition) => Level;
|
|
252
|
+
readonly limitOf: (rule: RuleDefinition, level: Level) => number;
|
|
253
|
+
readonly context: CompositeContext;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const compositesOf = (applicable: readonly RuleDefinition[], found: readonly Finding[], levels: CompositeLevels): Finding[] =>
|
|
257
|
+
applicable
|
|
258
|
+
.filter((rule) => rule.from.length > 0 && levels.levelOf(rule) !== "off")
|
|
259
|
+
.flatMap((rule) => compositeOf(rule, found, levels.limitOf(rule, levels.levelOf(rule)), levels.context));
|
|
260
|
+
|
|
237
261
|
/** 文書と違う言語で書いた文の上限。chaff.yaml の数値は文書の言語の単位で書いたものなので、ここには効かせない。 */
|
|
238
262
|
const embeddedLimitsFor = (rule: RuleDefinition, level: Level, genre: string, embedded: readonly string[]): Record<string, number> =>
|
|
239
263
|
Object.fromEntries(
|
|
@@ -326,11 +350,11 @@ export const runRulesWith = (doc: ProseDocument, rules: readonly RuleDefinition[
|
|
|
326
350
|
},
|
|
327
351
|
{ findings: [], skipped: [] },
|
|
328
352
|
);
|
|
329
|
-
const composites = applicable
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
353
|
+
const composites = compositesOf(applicable, outcome.findings, {
|
|
354
|
+
levelOf: (rule) => levelFor(rule, settings, experimental, preset),
|
|
355
|
+
limitOf: (rule, level) => limitFor(rule, level, genre, limits),
|
|
356
|
+
context: { starts, language: doc.language, rules },
|
|
357
|
+
});
|
|
334
358
|
const all = [...outcome.findings, ...composites];
|
|
335
359
|
return { ...outcome, findings: all.toSorted(byPosition), forcedExperimental: forced, presetExperimental: presetOn };
|
|
336
360
|
};
|
|
@@ -18,13 +18,13 @@ const headBefore = (tokens: readonly Token[], at: number): string => {
|
|
|
18
18
|
.join("");
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
/** Whether the particle at `at`, the words before it and the dictionary form of the word after it spell one of phrases (おそれのある). */
|
|
21
|
+
/** Whether the particle at `at`, the words before it and the dictionary form of the word after it spell one of phrases (おそれのある). A phrase that starts with the particle (のよう) takes any word before it. */
|
|
22
22
|
const isInPhrase = (tokens: readonly Token[], at: number, phrases: readonly string[]): boolean => {
|
|
23
23
|
const [particle, after] = [tokens[at], tokens[at + 1]];
|
|
24
24
|
if (particle === undefined || after === undefined || !touches(particle, after)) return false;
|
|
25
25
|
const tail = `${particle.surface}${after.lemma ?? after.surface}`;
|
|
26
26
|
const head = headBefore(tokens, at);
|
|
27
|
-
return phrases.some((phrase) => phrase.endsWith(tail) &&
|
|
27
|
+
return phrases.some((phrase) => phrase.endsWith(tail) && head.endsWith(phrase.slice(0, -tail.length)));
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
/** The counted particles (particles) of a sentence that stand inside one of phrases, each written whole (おそれのある). */
|