chaffjs 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/announced-count.d.ts +26 -0
- package/dist/announced-count.d.ts.map +1 -0
- package/dist/announced-count.js +104 -0
- package/dist/announced-count.js.map +1 -0
- package/dist/bare-url.d.ts +14 -0
- package/dist/bare-url.d.ts.map +1 -0
- package/dist/bare-url.js +28 -0
- package/dist/bare-url.js.map +1 -0
- package/dist/baseline.d.ts +5 -0
- package/dist/baseline.d.ts.map +1 -1
- package/dist/baseline.js +16 -1
- package/dist/baseline.js.map +1 -1
- package/dist/body-section.d.ts +7 -0
- package/dist/body-section.d.ts.map +1 -0
- package/dist/body-section.js +6 -0
- package/dist/body-section.js.map +1 -0
- package/dist/calendar-number.d.ts +2 -0
- package/dist/calendar-number.d.ts.map +1 -1
- package/dist/calendar-number.js +9 -2
- package/dist/calendar-number.js.map +1 -1
- package/dist/cli-args.d.ts +4 -0
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-text.d.ts.map +1 -1
- package/dist/cli-text.js +8 -4
- package/dist/cli-text.js.map +1 -1
- package/dist/cli.js +33 -30
- package/dist/cli.js.map +1 -1
- package/dist/commands/compare.d.ts +8 -0
- package/dist/commands/compare.d.ts.map +1 -0
- package/dist/commands/compare.js +72 -0
- package/dist/commands/compare.js.map +1 -0
- package/dist/commands/eval.d.ts.map +1 -1
- package/dist/commands/eval.js +17 -9
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/feedback.d.ts +5 -2
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +11 -5
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +2 -4
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/tree.d.ts +13 -0
- package/dist/commands/tree.d.ts.map +1 -1
- package/dist/commands/tree.js +35 -5
- package/dist/commands/tree.js.map +1 -1
- package/dist/compare/atom.d.ts +31 -0
- package/dist/compare/atom.d.ts.map +1 -0
- package/dist/compare/atom.js +4 -0
- package/dist/compare/atom.js.map +1 -0
- package/dist/compare/clock-time.d.ts +8 -0
- package/dist/compare/clock-time.d.ts.map +1 -0
- package/dist/compare/clock-time.js +65 -0
- package/dist/compare/clock-time.js.map +1 -0
- package/dist/compare/extract.d.ts +15 -0
- package/dist/compare/extract.d.ts.map +1 -0
- package/dist/compare/extract.js +58 -0
- package/dist/compare/extract.js.map +1 -0
- package/dist/compare/fact-text.d.ts +23 -0
- package/dist/compare/fact-text.d.ts.map +1 -0
- package/dist/compare/fact-text.js +47 -0
- package/dist/compare/fact-text.js.map +1 -0
- package/dist/compare/markup-atoms.d.ts +11 -0
- package/dist/compare/markup-atoms.d.ts.map +1 -0
- package/dist/compare/markup-atoms.js +23 -0
- package/dist/compare/markup-atoms.js.map +1 -0
- package/dist/compare/match.d.ts +19 -0
- package/dist/compare/match.d.ts.map +1 -0
- package/dist/compare/match.js +84 -0
- package/dist/compare/match.js.map +1 -0
- package/dist/compare/outcome.d.ts +33 -0
- package/dist/compare/outcome.d.ts.map +1 -0
- package/dist/compare/outcome.js +40 -0
- package/dist/compare/outcome.js.map +1 -0
- package/dist/compare/proper-nouns.d.ts +19 -0
- package/dist/compare/proper-nouns.d.ts.map +1 -0
- package/dist/compare/proper-nouns.js +44 -0
- package/dist/compare/proper-nouns.js.map +1 -0
- package/dist/compare/render.d.ts +9 -0
- package/dist/compare/render.d.ts.map +1 -0
- package/dist/compare/render.js +64 -0
- package/dist/compare/render.js.map +1 -0
- package/dist/compare/spans.d.ts +9 -0
- package/dist/compare/spans.d.ts.map +1 -0
- package/dist/compare/spans.js +11 -0
- package/dist/compare/spans.js.map +1 -0
- package/dist/compare/text-atoms.d.ts +24 -0
- package/dist/compare/text-atoms.d.ts.map +1 -0
- package/dist/compare/text-atoms.js +67 -0
- package/dist/compare/text-atoms.js.map +1 -0
- package/dist/compare/text.d.ts +24 -0
- package/dist/compare/text.d.ts.map +1 -0
- package/dist/compare/text.js +90 -0
- package/dist/compare/text.js.map +1 -0
- package/dist/compare/tree-atoms.d.ts +20 -0
- package/dist/compare/tree-atoms.d.ts.map +1 -0
- package/dist/compare/tree-atoms.js +58 -0
- package/dist/compare/tree-atoms.js.map +1 -0
- package/dist/compare/written-names.d.ts +8 -0
- package/dist/compare/written-names.d.ts.map +1 -0
- package/dist/compare/written-names.js +24 -0
- package/dist/compare/written-names.js.map +1 -0
- package/dist/config/load.d.ts +15 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +5 -0
- package/dist/config/load.js.map +1 -1
- package/dist/config/option-problems.d.ts +16 -0
- package/dist/config/option-problems.d.ts.map +1 -0
- package/dist/config/option-problems.js +58 -0
- package/dist/config/option-problems.js.map +1 -0
- package/dist/config/read.d.ts +4 -0
- package/dist/config/read.d.ts.map +1 -0
- package/dist/config/read.js +8 -0
- package/dist/config/read.js.map +1 -0
- package/dist/config/rule-problems.d.ts +2 -4
- package/dist/config/rule-problems.d.ts.map +1 -1
- package/dist/config/rule-problems.js +7 -1
- package/dist/config/rule-problems.js.map +1 -1
- package/dist/config/style.d.ts +16 -0
- package/dist/config/style.d.ts.map +1 -0
- package/dist/config/style.js +36 -0
- package/dist/config/style.js.map +1 -0
- package/dist/config/warnings.d.ts +6 -0
- package/dist/config/warnings.d.ts.map +1 -0
- package/dist/config/warnings.js +10 -0
- package/dist/config/warnings.js.map +1 -0
- package/dist/config/write.d.ts.map +1 -1
- package/dist/config/write.js +17 -4
- package/dist/config/write.js.map +1 -1
- package/dist/custom/bounded-match.d.ts +15 -0
- package/dist/custom/bounded-match.d.ts.map +1 -0
- package/dist/custom/bounded-match.js +43 -0
- package/dist/custom/bounded-match.js.map +1 -0
- package/dist/custom/load.d.ts +8 -0
- package/dist/custom/load.d.ts.map +1 -0
- package/dist/custom/load.js +11 -0
- package/dist/custom/load.js.map +1 -0
- package/dist/custom/parse.d.ts +70 -0
- package/dist/custom/parse.d.ts.map +1 -0
- package/dist/custom/parse.js +215 -0
- package/dist/custom/parse.js.map +1 -0
- package/dist/custom/problems.d.ts +5 -0
- package/dist/custom/problems.d.ts.map +1 -0
- package/dist/custom/problems.js +78 -0
- package/dist/custom/problems.js.map +1 -0
- package/dist/custom/regex-safety.d.ts +11 -0
- package/dist/custom/regex-safety.d.ts.map +1 -0
- package/dist/custom/regex-safety.js +110 -0
- package/dist/custom/regex-safety.js.map +1 -0
- package/dist/custom/token-pattern.d.ts +8 -0
- package/dist/custom/token-pattern.d.ts.map +1 -0
- package/dist/custom/token-pattern.js +75 -0
- package/dist/custom/token-pattern.js.map +1 -0
- package/dist/detect.d.ts.map +1 -1
- package/dist/detect.js +24 -2
- package/dist/detect.js.map +1 -1
- package/dist/detectors/acronym-context.d.ts +2 -0
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +12 -4
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/ai-phrasing.d.ts +20 -0
- package/dist/detectors/ai-phrasing.d.ts.map +1 -0
- package/dist/detectors/ai-phrasing.js +112 -0
- package/dist/detectors/ai-phrasing.js.map +1 -0
- package/dist/detectors/announced-count.d.ts +4 -0
- package/dist/detectors/announced-count.d.ts.map +1 -0
- package/dist/detectors/announced-count.js +20 -0
- package/dist/detectors/announced-count.js.map +1 -0
- package/dist/detectors/broken-link.d.ts +17 -0
- package/dist/detectors/broken-link.d.ts.map +1 -0
- package/dist/detectors/broken-link.js +66 -0
- package/dist/detectors/broken-link.js.map +1 -0
- package/dist/detectors/cited-name.d.ts.map +1 -1
- package/dist/detectors/cited-name.js +4 -4
- package/dist/detectors/cited-name.js.map +1 -1
- package/dist/detectors/cited-title.d.ts +11 -0
- package/dist/detectors/cited-title.d.ts.map +1 -0
- package/dist/detectors/cited-title.js +75 -0
- package/dist/detectors/cited-title.js.map +1 -0
- package/dist/detectors/concrete-evidence.d.ts +1 -1
- package/dist/detectors/concrete-evidence.d.ts.map +1 -1
- package/dist/detectors/concrete-evidence.js +2 -1
- package/dist/detectors/concrete-evidence.js.map +1 -1
- package/dist/detectors/contrast-frame.d.ts +17 -0
- package/dist/detectors/contrast-frame.d.ts.map +1 -0
- package/dist/detectors/contrast-frame.js +32 -0
- package/dist/detectors/contrast-frame.js.map +1 -0
- package/dist/detectors/custom.d.ts +8 -0
- package/dist/detectors/custom.d.ts.map +1 -0
- package/dist/detectors/custom.js +71 -0
- package/dist/detectors/custom.js.map +1 -0
- package/dist/detectors/dangling-figure.d.ts +4 -0
- package/dist/detectors/dangling-figure.d.ts.map +1 -0
- package/dist/detectors/dangling-figure.js +18 -0
- package/dist/detectors/dangling-figure.js.map +1 -0
- package/dist/detectors/doubled-punctuation.d.ts +9 -0
- package/dist/detectors/doubled-punctuation.d.ts.map +1 -0
- package/dist/detectors/doubled-punctuation.js +33 -0
- package/dist/detectors/doubled-punctuation.js.map +1 -0
- package/dist/detectors/doubled-word.d.ts +5 -0
- package/dist/detectors/doubled-word.d.ts.map +1 -1
- package/dist/detectors/doubled-word.js +24 -11
- package/dist/detectors/doubled-word.js.map +1 -1
- package/dist/detectors/enumerated-runs.d.ts +1 -1
- package/dist/detectors/enumerated-runs.d.ts.map +1 -1
- package/dist/detectors/enumerated-runs.js +15 -4
- package/dist/detectors/enumerated-runs.js.map +1 -1
- package/dist/detectors/gram-furniture.d.ts +6 -0
- package/dist/detectors/gram-furniture.d.ts.map +1 -0
- package/dist/detectors/gram-furniture.js +21 -0
- package/dist/detectors/gram-furniture.js.map +1 -0
- package/dist/detectors/gram-place.d.ts +2 -0
- package/dist/detectors/gram-place.d.ts.map +1 -1
- package/dist/detectors/gram-place.js +9 -7
- package/dist/detectors/gram-place.js.map +1 -1
- package/dist/detectors/gram-windows.d.ts +9 -0
- package/dist/detectors/gram-windows.d.ts.map +1 -0
- package/dist/detectors/gram-windows.js +27 -0
- package/dist/detectors/gram-windows.js.map +1 -0
- package/dist/detectors/heading-case.d.ts +2 -0
- package/dist/detectors/heading-case.d.ts.map +1 -1
- package/dist/detectors/heading-case.js +29 -2
- package/dist/detectors/heading-case.js.map +1 -1
- package/dist/detectors/heading-code-words.d.ts +6 -0
- package/dist/detectors/heading-code-words.d.ts.map +1 -0
- package/dist/detectors/heading-code-words.js +29 -0
- package/dist/detectors/heading-code-words.js.map +1 -0
- package/dist/detectors/heading-echo.d.ts.map +1 -1
- package/dist/detectors/heading-echo.js +7 -4
- package/dist/detectors/heading-echo.js.map +1 -1
- package/dist/detectors/heading-level-skip.d.ts +12 -0
- package/dist/detectors/heading-level-skip.d.ts.map +1 -0
- package/dist/detectors/heading-level-skip.js +11 -0
- package/dist/detectors/heading-level-skip.js.map +1 -0
- package/dist/detectors/image-alt-text.d.ts +3 -0
- package/dist/detectors/image-alt-text.d.ts.map +1 -0
- package/dist/detectors/image-alt-text.js +9 -0
- package/dist/detectors/image-alt-text.js.map +1 -0
- package/dist/detectors/index.d.ts.map +1 -1
- package/dist/detectors/index.js +34 -1
- package/dist/detectors/index.js.map +1 -1
- package/dist/detectors/kutoten-consistency.d.ts +24 -0
- package/dist/detectors/kutoten-consistency.d.ts.map +1 -0
- package/dist/detectors/kutoten-consistency.js +77 -0
- package/dist/detectors/kutoten-consistency.js.map +1 -0
- package/dist/detectors/lead-in.d.ts +1 -0
- package/dist/detectors/lead-in.d.ts.map +1 -1
- package/dist/detectors/lead-in.js +2 -1
- package/dist/detectors/lead-in.js.map +1 -1
- package/dist/detectors/lexicon-match.d.ts +4 -0
- package/dist/detectors/lexicon-match.d.ts.map +1 -1
- package/dist/detectors/lexicon-match.js +7 -2
- package/dist/detectors/lexicon-match.js.map +1 -1
- package/dist/detectors/list-item.d.ts +45 -0
- package/dist/detectors/list-item.d.ts.map +1 -0
- package/dist/detectors/list-item.js +88 -0
- package/dist/detectors/list-item.js.map +1 -0
- package/dist/detectors/list-items.d.ts +31 -0
- package/dist/detectors/list-items.d.ts.map +1 -0
- package/dist/detectors/list-items.js +113 -0
- package/dist/detectors/list-items.js.map +1 -0
- package/dist/detectors/list-lead-in.d.ts +7 -0
- package/dist/detectors/list-lead-in.d.ts.map +1 -0
- package/dist/detectors/list-lead-in.js +28 -0
- package/dist/detectors/list-lead-in.js.map +1 -0
- package/dist/detectors/list-sentence.d.ts +65 -0
- package/dist/detectors/list-sentence.d.ts.map +1 -0
- package/dist/detectors/list-sentence.js +105 -0
- package/dist/detectors/list-sentence.js.map +1 -0
- package/dist/detectors/list-view.d.ts +34 -0
- package/dist/detectors/list-view.d.ts.map +1 -0
- package/dist/detectors/list-view.js +137 -0
- package/dist/detectors/list-view.js.map +1 -0
- package/dist/detectors/long-vowel.d.ts +7 -0
- package/dist/detectors/long-vowel.d.ts.map +1 -0
- package/dist/detectors/long-vowel.js +57 -0
- package/dist/detectors/long-vowel.js.map +1 -0
- package/dist/detectors/markup-finding.d.ts +6 -0
- package/dist/detectors/markup-finding.d.ts.map +1 -0
- package/dist/detectors/markup-finding.js +19 -0
- package/dist/detectors/markup-finding.js.map +1 -0
- package/dist/detectors/name-numeral.d.ts +1 -1
- package/dist/detectors/name-numeral.d.ts.map +1 -1
- package/dist/detectors/name-numeral.js +2 -7
- package/dist/detectors/name-numeral.js.map +1 -1
- package/dist/detectors/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +14 -10
- package/dist/detectors/orthography.js.map +1 -1
- package/dist/detectors/oxford-comma.d.ts +7 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +135 -229
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/place-run.d.ts.map +1 -1
- package/dist/detectors/place-run.js +10 -6
- package/dist/detectors/place-run.js.map +1 -1
- package/dist/detectors/placeholder-text.d.ts +9 -0
- package/dist/detectors/placeholder-text.d.ts.map +1 -0
- package/dist/detectors/placeholder-text.js +18 -0
- package/dist/detectors/placeholder-text.js.map +1 -0
- package/dist/detectors/quote-around.d.ts +3 -0
- package/dist/detectors/quote-around.d.ts.map +1 -0
- package/dist/detectors/quote-around.js +8 -0
- package/dist/detectors/quote-around.js.map +1 -0
- package/dist/detectors/register.d.ts +11 -3
- package/dist/detectors/register.d.ts.map +1 -1
- package/dist/detectors/register.js +28 -9
- package/dist/detectors/register.js.map +1 -1
- package/dist/detectors/roman-numeral.d.ts +2 -0
- package/dist/detectors/roman-numeral.d.ts.map +1 -1
- package/dist/detectors/roman-numeral.js +2 -0
- package/dist/detectors/roman-numeral.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts +17 -1
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +13 -7
- 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 +13 -4
- package/dist/detectors/sentence-length.js.map +1 -1
- package/dist/detectors/signals.d.ts +8 -0
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +67 -46
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/structure-tree.d.ts +6 -0
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +37 -1
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/structure.d.ts +1 -3
- package/dist/detectors/structure.d.ts.map +1 -1
- package/dist/detectors/structure.js +3 -4
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/superlative-name.d.ts.map +1 -1
- package/dist/detectors/superlative-name.js +8 -5
- package/dist/detectors/superlative-name.js.map +1 -1
- package/dist/detectors/superlative-scope.d.ts.map +1 -1
- package/dist/detectors/superlative-scope.js +9 -4
- package/dist/detectors/superlative-scope.js.map +1 -1
- package/dist/detectors/token-column.d.ts +46 -0
- package/dist/detectors/token-column.d.ts.map +1 -0
- package/dist/detectors/token-column.js +95 -0
- package/dist/detectors/token-column.js.map +1 -0
- package/dist/detectors/unbalanced-bracket.d.ts +22 -0
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -0
- package/dist/detectors/unbalanced-bracket.js +119 -0
- package/dist/detectors/unbalanced-bracket.js.map +1 -0
- package/dist/detectors/url-run-on.d.ts +9 -0
- package/dist/detectors/url-run-on.d.ts.map +1 -0
- package/dist/detectors/url-run-on.js +19 -0
- package/dist/detectors/url-run-on.js.map +1 -0
- package/dist/document-sections.d.ts +13 -0
- package/dist/document-sections.d.ts.map +1 -0
- package/dist/document-sections.js +32 -0
- package/dist/document-sections.js.map +1 -0
- package/dist/document.d.ts +11 -4
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +90 -98
- package/dist/document.js.map +1 -1
- package/dist/email-parts.d.ts +28 -0
- package/dist/email-parts.d.ts.map +1 -0
- package/dist/email-parts.js +230 -0
- package/dist/email-parts.js.map +1 -0
- package/dist/eval.d.ts +2 -1
- package/dist/eval.d.ts.map +1 -1
- package/dist/eval.js +16 -4
- package/dist/eval.js.map +1 -1
- package/dist/figure-references.d.ts +30 -0
- package/dist/figure-references.d.ts.map +1 -0
- package/dist/figure-references.js +76 -0
- package/dist/figure-references.js.map +1 -0
- package/dist/files.d.ts +2 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +4 -0
- package/dist/files.js.map +1 -1
- package/dist/heading-label.d.ts +22 -0
- package/dist/heading-label.d.ts.map +1 -0
- package/dist/heading-label.js +50 -0
- package/dist/heading-label.js.map +1 -0
- package/dist/in-page-nav.d.ts +4 -1
- package/dist/in-page-nav.d.ts.map +1 -1
- package/dist/in-page-nav.js +53 -18
- package/dist/in-page-nav.js.map +1 -1
- package/dist/joined-view.d.ts.map +1 -1
- package/dist/joined-view.js +1 -0
- package/dist/joined-view.js.map +1 -1
- package/dist/levels.d.ts +5 -1
- package/dist/levels.d.ts.map +1 -1
- package/dist/levels.js +9 -0
- package/dist/levels.js.map +1 -1
- package/dist/line-paragraphs.d.ts +8 -0
- package/dist/line-paragraphs.d.ts.map +1 -1
- package/dist/line-paragraphs.js +33 -10
- package/dist/line-paragraphs.js.map +1 -1
- package/dist/long-vowel.d.ts +35 -0
- package/dist/long-vowel.d.ts.map +1 -0
- package/dist/long-vowel.js +71 -0
- package/dist/long-vowel.js.map +1 -0
- package/dist/markdown-node.d.ts +19 -0
- package/dist/markdown-node.d.ts.map +1 -0
- package/dist/markdown-node.js +6 -0
- package/dist/markdown-node.js.map +1 -0
- package/dist/markdown-read.d.ts +17 -0
- package/dist/markdown-read.d.ts.map +1 -0
- package/dist/markdown-read.js +37 -0
- package/dist/markdown-read.js.map +1 -0
- package/dist/markup.d.ts +22 -0
- package/dist/markup.d.ts.map +1 -0
- package/dist/markup.js +180 -0
- package/dist/markup.js.map +1 -0
- package/dist/mask.js +8 -5
- package/dist/mask.js.map +1 -1
- package/dist/number-name.d.ts +21 -5
- package/dist/number-name.d.ts.map +1 -1
- package/dist/number-name.js +119 -17
- package/dist/number-name.js.map +1 -1
- package/dist/orthography.d.ts +2 -0
- package/dist/orthography.d.ts.map +1 -1
- package/dist/orthography.js +9 -4
- package/dist/orthography.js.map +1 -1
- package/dist/page-furniture.d.ts +5 -2
- package/dist/page-furniture.d.ts.map +1 -1
- package/dist/page-furniture.js +8 -2
- package/dist/page-furniture.js.map +1 -1
- package/dist/plain-source.d.ts +1 -0
- package/dist/plain-source.d.ts.map +1 -1
- package/dist/plain-source.js +2 -1
- package/dist/plain-source.js.map +1 -1
- package/dist/plugin.d.ts +115 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/profile/for-file.d.ts.map +1 -1
- package/dist/profile/for-file.js +3 -1
- package/dist/profile/for-file.js.map +1 -1
- package/dist/quoted-span.d.ts.map +1 -1
- package/dist/quoted-span.js +8 -3
- package/dist/quoted-span.js.map +1 -1
- package/dist/reasons.d.ts +3 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +6 -0
- package/dist/reasons.js.map +1 -1
- package/dist/reference-lists.d.ts +3 -0
- package/dist/reference-lists.d.ts.map +1 -0
- package/dist/reference-lists.js +75 -0
- package/dist/reference-lists.js.map +1 -0
- package/dist/render/explain.d.ts +7 -1
- package/dist/render/explain.d.ts.map +1 -1
- package/dist/render/explain.js +36 -12
- package/dist/render/explain.js.map +1 -1
- package/dist/render/friendly.d.ts.map +1 -1
- package/dist/render/friendly.js +19 -9
- package/dist/render/friendly.js.map +1 -1
- package/dist/render/options.d.ts +7 -0
- package/dist/render/options.d.ts.map +1 -0
- package/dist/render/options.js +50 -0
- package/dist/render/options.js.map +1 -0
- package/dist/render/rules-json.d.ts +4 -1
- package/dist/render/rules-json.d.ts.map +1 -1
- package/dist/render/rules-json.js +102 -12
- package/dist/render/rules-json.js.map +1 -1
- package/dist/render/rules-table.d.ts +4 -0
- package/dist/render/rules-table.d.ts.map +1 -0
- package/dist/render/rules-table.js +70 -0
- package/dist/render/rules-table.js.map +1 -0
- package/dist/render/sarif.js +4 -4
- package/dist/render/sarif.js.map +1 -1
- package/dist/render/semantic.js +3 -3
- package/dist/render/semantic.js.map +1 -1
- package/dist/render/severity-name.d.ts +6 -0
- package/dist/render/severity-name.d.ts.map +1 -0
- package/dist/render/severity-name.js +7 -0
- package/dist/render/severity-name.js.map +1 -0
- package/dist/render/text.d.ts +7 -2
- package/dist/render/text.d.ts.map +1 -1
- package/dist/render/text.js +15 -4
- package/dist/render/text.js.map +1 -1
- package/dist/resolve-genre.d.ts +1 -1
- package/dist/resolve-genre.d.ts.map +1 -1
- package/dist/resolve-genre.js +4 -1
- package/dist/resolve-genre.js.map +1 -1
- package/dist/rule-genres.d.ts +24 -0
- package/dist/rule-genres.d.ts.map +1 -0
- package/dist/rule-genres.js +11 -0
- package/dist/rule-genres.js.map +1 -0
- package/dist/rule-guide.d.ts +54 -0
- package/dist/rule-guide.d.ts.map +1 -0
- package/dist/rule-guide.js +81 -0
- package/dist/rule-guide.js.map +1 -0
- package/dist/rule-load.d.ts.map +1 -1
- package/dist/rule-load.js +87 -33
- package/dist/rule-load.js.map +1 -1
- package/dist/rule-options.d.ts +50 -0
- package/dist/rule-options.d.ts.map +1 -0
- package/dist/rule-options.js +106 -0
- package/dist/rule-options.js.map +1 -0
- package/dist/run.d.ts +13 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +54 -10
- package/dist/run.js.map +1 -1
- package/dist/sentence-shape.d.ts.map +1 -1
- package/dist/sentence-shape.js +4 -4
- package/dist/sentence-shape.js.map +1 -1
- package/dist/setting-problems.d.ts +2 -1
- package/dist/setting-problems.d.ts.map +1 -1
- package/dist/setting-problems.js +6 -1
- package/dist/setting-problems.js.map +1 -1
- package/dist/span-cut.d.ts +6 -0
- package/dist/span-cut.d.ts.map +1 -0
- package/dist/span-cut.js +22 -0
- package/dist/span-cut.js.map +1 -0
- package/dist/structure/aside-depth.d.ts +21 -0
- package/dist/structure/aside-depth.d.ts.map +1 -0
- package/dist/structure/aside-depth.js +65 -0
- package/dist/structure/aside-depth.js.map +1 -0
- package/dist/structure/build.d.ts +5 -1
- package/dist/structure/build.d.ts.map +1 -1
- package/dist/structure/build.js +29 -17
- package/dist/structure/build.js.map +1 -1
- package/dist/structure/closed-pairs.d.ts +8 -0
- package/dist/structure/closed-pairs.d.ts.map +1 -0
- package/dist/structure/closed-pairs.js +22 -0
- package/dist/structure/closed-pairs.js.map +1 -0
- package/dist/structure/date-range.d.ts +21 -0
- package/dist/structure/date-range.d.ts.map +1 -0
- package/dist/structure/date-range.js +45 -0
- package/dist/structure/date-range.js.map +1 -0
- package/dist/structure/known-mentions.d.ts +18 -0
- package/dist/structure/known-mentions.d.ts.map +1 -0
- package/dist/structure/known-mentions.js +78 -0
- package/dist/structure/known-mentions.js.map +1 -0
- package/dist/structure/numbering.d.ts +1 -0
- package/dist/structure/numbering.d.ts.map +1 -1
- package/dist/structure/numbering.js +11 -6
- package/dist/structure/numbering.js.map +1 -1
- package/dist/structure/of.d.ts +3 -1
- package/dist/structure/of.d.ts.map +1 -1
- package/dist/structure/of.js +5 -1
- package/dist/structure/of.js.map +1 -1
- package/dist/structure/percent-sum.d.ts +16 -0
- package/dist/structure/percent-sum.d.ts.map +1 -0
- package/dist/structure/percent-sum.js +104 -0
- package/dist/structure/percent-sum.js.map +1 -0
- package/dist/structure/quoted-number.d.ts +8 -0
- package/dist/structure/quoted-number.d.ts.map +1 -0
- package/dist/structure/quoted-number.js +34 -0
- package/dist/structure/quoted-number.js.map +1 -0
- package/dist/structure/relative-find.d.ts.map +1 -1
- package/dist/structure/relative-find.js +34 -46
- package/dist/structure/relative-find.js.map +1 -1
- package/dist/structure/relative-resolve.d.ts.map +1 -1
- package/dist/structure/relative-resolve.js +76 -30
- package/dist/structure/relative-resolve.js.map +1 -1
- package/dist/structure/runs.d.ts +2 -0
- package/dist/structure/runs.d.ts.map +1 -1
- package/dist/structure/runs.js +2 -2
- package/dist/structure/runs.js.map +1 -1
- package/dist/structure/sexp.d.ts +1 -1
- package/dist/structure/sexp.d.ts.map +1 -1
- package/dist/structure/sexp.js +18 -6
- package/dist/structure/sexp.js.map +1 -1
- package/dist/structure/total.d.ts +3 -0
- package/dist/structure/total.d.ts.map +1 -1
- package/dist/structure/total.js +2 -2
- package/dist/structure/total.js.map +1 -1
- package/dist/structure/universal.d.ts +14 -2
- package/dist/structure/universal.d.ts.map +1 -1
- package/dist/structure/universal.js +17 -2
- package/dist/structure/universal.js.map +1 -1
- package/dist/structure/wrapped-tail.d.ts +14 -7
- package/dist/structure/wrapped-tail.d.ts.map +1 -1
- package/dist/structure/wrapped-tail.js +33 -8
- package/dist/structure/wrapped-tail.js.map +1 -1
- package/dist/style-load.d.ts +4 -0
- package/dist/style-load.d.ts.map +1 -0
- package/dist/style-load.js +28 -0
- package/dist/style-load.js.map +1 -0
- package/dist/style-parse.d.ts +19 -0
- package/dist/style-parse.d.ts.map +1 -0
- package/dist/style-parse.js +60 -0
- package/dist/style-parse.js.map +1 -0
- package/dist/subheading-line.d.ts +6 -0
- package/dist/subheading-line.d.ts.map +1 -0
- package/dist/subheading-line.js +57 -0
- package/dist/subheading-line.js.map +1 -0
- package/dist/template-syntax.d.ts +17 -0
- package/dist/template-syntax.d.ts.map +1 -0
- package/dist/template-syntax.js +140 -0
- package/dist/template-syntax.js.map +1 -0
- package/dist/text-above.d.ts +19 -0
- package/dist/text-above.d.ts.map +1 -0
- package/dist/text-above.js +43 -0
- package/dist/text-above.js.map +1 -0
- package/dist/text-figures.d.ts +10 -0
- package/dist/text-figures.d.ts.map +1 -0
- package/dist/text-figures.js +131 -0
- package/dist/text-figures.js.map +1 -0
- package/dist/trailing-aside.d.ts +2 -0
- package/dist/trailing-aside.d.ts.map +1 -0
- package/dist/trailing-aside.js +53 -0
- package/dist/trailing-aside.js.map +1 -0
- package/dist/tree-walk.d.ts +18 -0
- package/dist/tree-walk.d.ts.map +1 -0
- package/dist/tree-walk.js +45 -0
- package/dist/tree-walk.js.map +1 -0
- package/genres.yaml +26 -0
- package/package.json +5 -3
- package/reference-headings.yaml +17 -0
- package/rules/adverb-overuse.yaml +19 -0
- package/rules/agentless-passive.yaml +19 -0
- package/rules/agreement-slip.yaml +14 -1
- package/rules/ai-generated-composite.yaml +102 -0
- package/rules/ai-tell.yaml +23 -0
- package/rules/announced-count-mismatch.yaml +57 -0
- package/rules/announcing-opener.yaml +51 -0
- package/rules/assistant-residue.yaml +52 -0
- package/rules/bold-density.yaml +31 -0
- package/rules/broken-link.yaml +65 -0
- package/rules/closing-cliche.yaml +33 -0
- package/rules/colon-lead-in.yaml +59 -0
- package/rules/concrete-evidence-density.yaml +41 -0
- package/rules/contraction-consistency.yaml +18 -0
- package/rules/contrast-framing.yaml +57 -0
- package/rules/cushion-phrase-density.yaml +25 -0
- package/rules/dangling-figure-reference.yaml +61 -0
- package/rules/dangling-reference.yaml +53 -1
- package/rules/date-order.yaml +33 -1
- package/rules/date-range-reversed.yaml +46 -0
- package/rules/date-weekday-mismatch.yaml +17 -1
- package/rules/double-keigo.yaml +16 -0
- package/rules/doubled-punctuation.yaml +45 -0
- package/rules/doubled-word.yaml +17 -1
- package/rules/duplicate-definition.yaml +59 -1
- package/rules/emoji-density.yaml +25 -0
- package/rules/empty-conclusion.yaml +28 -0
- package/rules/empty-intensifier.yaml +19 -0
- package/rules/excessive-hedging.yaml +19 -0
- package/rules/expletive-construction.yaml +19 -0
- package/rules/heading-echo.yaml +31 -0
- package/rules/heading-level-skip.yaml +78 -0
- package/rules/hiragana-fukushi.yaml +16 -0
- package/rules/image-alt-text.yaml +54 -0
- package/rules/internal-jargon.yaml +21 -0
- package/rules/katakana-long-vowel.yaml +98 -0
- package/rules/kutoten-consistency.yaml +53 -0
- package/rules/latin-spacing.yaml +23 -4
- package/rules/max-kanji-continuous.yaml +16 -0
- package/rules/max-paragraph-length.yaml +33 -0
- package/rules/max-sentence-length.yaml +32 -0
- package/rules/ngram-repetition.yaml +29 -2
- package/rules/no-doubled-joshi.yaml +16 -0
- package/rules/no-em-dash.yaml +25 -0
- package/rules/no-mixed-desumasu.yaml +27 -2
- package/rules/no-nakaguro-parallel.yaml +20 -0
- package/rules/numbering-gap.yaml +53 -1
- package/rules/oxford-comma-consistency.yaml +18 -0
- package/rules/padded-intro.yaml +19 -0
- package/rules/paragraph-length-variance.yaml +49 -0
- package/rules/percent-sum-mismatch.yaml +58 -0
- package/rules/preamble-length.yaml +56 -0
- package/rules/preferred-term.yaml +27 -0
- package/rules/proper-noun-density.yaml +26 -0
- package/rules/repeated-conjunction.yaml +47 -0
- package/rules/repeated-sentence-head.yaml +23 -0
- package/rules/required-sections.yaml +49 -0
- package/rules/risk-disclosure.yaml +22 -0
- package/rules/rule-of-three.yaml +97 -0
- package/rules/sasete-itadaku.yaml +18 -0
- package/rules/section-length-uniformity.yaml +89 -0
- package/rules/sentence-initial-conjunction-run.yaml +18 -0
- package/rules/sentence-rhythm.yaml +25 -0
- package/rules/stock-transition.yaml +55 -0
- package/rules/stray-space.yaml +18 -0
- package/rules/taigen-dome-in-prose.yaml +19 -0
- package/rules/title-case-consistency.yaml +42 -0
- package/rules/total-mismatch.yaml +37 -1
- package/rules/unbalanced-bracket.yaml +56 -0
- package/rules/undefined-acronym.yaml +22 -0
- package/rules/unfilled-placeholder.yaml +50 -0
- package/rules/unqualified-superlative.yaml +19 -0
- package/rules/unsourced-number.yaml +16 -0
- package/rules/url-run-on.yaml +45 -0
- package/skills/chaff/SKILL.md +70 -0
- package/src/announced-count.ts +148 -0
- package/src/bare-url.ts +35 -0
- package/src/baseline.ts +17 -1
- package/src/body-section.ts +7 -0
- package/src/calendar-number.ts +18 -4
- package/src/cli-args.ts +6 -0
- package/src/cli-text.ts +8 -4
- package/src/cli.ts +37 -37
- package/src/commands/compare.ts +80 -0
- package/src/commands/eval.ts +19 -8
- package/src/commands/feedback.ts +12 -6
- package/src/commands/test.ts +2 -4
- package/src/commands/tree.ts +41 -5
- package/src/compare/atom.ts +33 -0
- package/src/compare/clock-time.ts +86 -0
- package/src/compare/extract.ts +78 -0
- package/src/compare/fact-text.ts +68 -0
- package/src/compare/markup-atoms.ts +29 -0
- package/src/compare/match.ts +105 -0
- package/src/compare/outcome.ts +70 -0
- package/src/compare/proper-nouns.ts +65 -0
- package/src/compare/render.ts +102 -0
- package/src/compare/spans.ts +17 -0
- package/src/compare/text-atoms.ts +95 -0
- package/src/compare/text.ts +120 -0
- package/src/compare/tree-atoms.ts +80 -0
- package/src/compare/written-names.ts +26 -0
- package/src/config/load.ts +21 -0
- package/src/config/option-problems.ts +70 -0
- package/src/config/read.ts +8 -0
- package/src/config/rule-problems.ts +12 -2
- package/src/config/style.ts +42 -0
- package/src/config/warnings.ts +13 -0
- package/src/config/write.ts +18 -4
- package/src/custom/bounded-match.ts +58 -0
- package/src/custom/load.ts +15 -0
- package/src/custom/parse.ts +274 -0
- package/src/custom/problems.ts +89 -0
- package/src/custom/regex-safety.ts +118 -0
- package/src/custom/token-pattern.ts +84 -0
- package/src/detect.ts +28 -2
- package/src/detectors/acronym-context.ts +16 -4
- package/src/detectors/ai-phrasing.ts +137 -0
- package/src/detectors/announced-count.ts +25 -0
- package/src/detectors/broken-link.ts +90 -0
- package/src/detectors/cited-name.ts +6 -5
- package/src/detectors/cited-title.ts +96 -0
- package/src/detectors/concrete-evidence.ts +3 -2
- package/src/detectors/contrast-frame.ts +54 -0
- package/src/detectors/custom.ts +89 -0
- package/src/detectors/dangling-figure.ts +22 -0
- package/src/detectors/doubled-punctuation.ts +49 -0
- package/src/detectors/doubled-word.ts +19 -4
- package/src/detectors/enumerated-runs.ts +13 -4
- package/src/detectors/gram-furniture.ts +30 -0
- package/src/detectors/gram-place.ts +9 -5
- package/src/detectors/gram-windows.ts +31 -0
- package/src/detectors/heading-case.ts +30 -2
- package/src/detectors/heading-code-words.ts +35 -0
- package/src/detectors/heading-echo.ts +8 -4
- package/src/detectors/heading-level-skip.ts +19 -0
- package/src/detectors/image-alt-text.ts +11 -0
- package/src/detectors/index.ts +43 -1
- package/src/detectors/kutoten-consistency.ts +96 -0
- package/src/detectors/lead-in.ts +3 -1
- package/src/detectors/lexicon-match.ts +9 -2
- package/src/detectors/list-item.ts +122 -0
- package/src/detectors/list-items.ts +163 -0
- package/src/detectors/list-lead-in.ts +33 -0
- package/src/detectors/list-sentence.ts +157 -0
- package/src/detectors/list-view.ts +157 -0
- package/src/detectors/long-vowel.ts +66 -0
- package/src/detectors/markup-finding.ts +24 -0
- package/src/detectors/name-numeral.ts +4 -2
- package/src/detectors/orthography.ts +23 -17
- package/src/detectors/oxford-comma.ts +178 -283
- package/src/detectors/place-run.ts +7 -4
- package/src/detectors/placeholder-text.ts +27 -0
- package/src/detectors/quote-around.ts +9 -0
- package/src/detectors/register.ts +37 -10
- package/src/detectors/roman-numeral.ts +3 -0
- package/src/detectors/sentence-ending.ts +14 -7
- package/src/detectors/sentence-length.ts +16 -5
- package/src/detectors/signals.ts +80 -46
- package/src/detectors/structure-tree.ts +45 -1
- package/src/detectors/structure.ts +3 -4
- package/src/detectors/superlative-name.ts +7 -4
- package/src/detectors/superlative-scope.ts +8 -3
- package/src/detectors/token-column.ts +149 -0
- package/src/detectors/unbalanced-bracket.ts +153 -0
- package/src/detectors/url-run-on.ts +27 -0
- package/src/document-sections.ts +46 -0
- package/src/document.ts +106 -138
- package/src/email-parts.ts +269 -0
- package/src/eval.ts +14 -4
- package/src/figure-references.ts +112 -0
- package/src/files.ts +5 -0
- package/src/heading-label.ts +55 -0
- package/src/in-page-nav.ts +48 -19
- package/src/joined-view.ts +1 -0
- package/src/levels.ts +14 -1
- package/src/line-paragraphs.ts +52 -9
- package/src/long-vowel.ts +99 -0
- package/src/markdown-node.ts +19 -0
- package/src/markdown-read.ts +44 -0
- package/src/markup.ts +210 -0
- package/src/mask.ts +8 -8
- package/src/number-name.ts +151 -24
- package/src/orthography.ts +10 -3
- package/src/page-furniture.ts +11 -2
- package/src/plain-source.ts +2 -1
- package/src/plugin.ts +101 -1
- package/src/profile/for-file.ts +3 -1
- package/src/quoted-span.ts +9 -3
- package/src/reasons.ts +9 -0
- package/src/reference-lists.ts +91 -0
- package/src/render/explain.ts +47 -13
- package/src/render/friendly.ts +20 -9
- package/src/render/options.ts +58 -0
- package/src/render/rules-json.ts +130 -14
- package/src/render/rules-table.ts +91 -0
- package/src/render/sarif.ts +4 -4
- package/src/render/semantic.ts +3 -3
- package/src/render/severity-name.ts +10 -0
- package/src/render/text.ts +21 -7
- package/src/resolve-genre.ts +4 -1
- package/src/rule-genres.ts +25 -0
- package/src/rule-guide.ts +135 -0
- package/src/rule-load.ts +91 -34
- package/src/rule-options.ts +131 -0
- package/src/run.ts +74 -11
- package/src/sentence-shape.ts +4 -5
- package/src/setting-problems.ts +7 -1
- package/src/span-cut.ts +28 -0
- package/src/structure/aside-depth.ts +67 -0
- package/src/structure/build.ts +38 -19
- package/src/structure/closed-pairs.ts +20 -0
- package/src/structure/date-range.ts +69 -0
- package/src/structure/known-mentions.ts +96 -0
- package/src/structure/numbering.ts +9 -5
- package/src/structure/of.ts +11 -3
- package/src/structure/percent-sum.ts +135 -0
- package/src/structure/quoted-number.ts +36 -0
- package/src/structure/relative-find.ts +34 -47
- package/src/structure/relative-resolve.ts +77 -30
- package/src/structure/runs.ts +2 -2
- package/src/structure/sexp.ts +17 -5
- package/src/structure/total.ts +2 -2
- package/src/structure/universal.ts +24 -4
- package/src/structure/wrapped-tail.ts +38 -13
- package/src/style-load.ts +28 -0
- package/src/style-parse.ts +77 -0
- package/src/subheading-line.ts +68 -0
- package/src/template-syntax.ts +164 -0
- package/src/text-above.ts +49 -0
- package/src/text-figures.ts +147 -0
- package/src/trailing-aside.ts +50 -0
- package/src/tree-walk.ts +48 -0
- package/styles/bunkacho.yaml +25 -0
- package/styles/ieice.yaml +29 -0
- package/styles/jis-z8301-2011.yaml +25 -0
|
@@ -15,21 +15,32 @@ const chainAtEnd = (preceding: readonly Token[]): readonly Token[] => {
|
|
|
15
15
|
return preceding.slice(Math.max(head, 0));
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
/** 語彙表 neutral-ending の語(「こと」)か。書いた形か原形で照らす。 */
|
|
19
|
+
const isNeutralWord = (token: Token | undefined, neutral: readonly LexiconEntry[]): boolean =>
|
|
20
|
+
token !== undefined && neutral.some((entry) => token.surface === entry.pattern || token.lemma === entry.pattern);
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
23
|
+
* 非自立名詞で終わる文末は、手前の述語の連なりまで見る。「使っているのかな?」は手前の述語が調子を持つ。
|
|
24
|
+
* 「以下のとおり。」は手前も述語でないので、調子を持たないまま。
|
|
25
|
+
* 語彙表 neutral-ending の語(「こと」)で終わる文末は手前を見ない。「〜を保持すること。」は体言止めで、要件や規程の箇条書きは
|
|
26
|
+
* ですます調の文書でもである調の文書でもこの形で書く。
|
|
21
27
|
*/
|
|
22
|
-
const withPreceding = (ending: readonly Token[], preceding: readonly Token[]): readonly Token[] =>
|
|
23
|
-
isDependent(ending[0]) ? [...chainAtEnd(preceding), ...ending] : ending;
|
|
28
|
+
const withPreceding = (ending: readonly Token[], preceding: readonly Token[], neutral: readonly LexiconEntry[]): readonly Token[] =>
|
|
29
|
+
isDependent(ending[0]) && !isNeutralWord(ending[0], neutral) ? [...chainAtEnd(preceding), ...ending] : ending;
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
|
-
* 文末の語の調子。preceding は文末の語より前の語。
|
|
32
|
+
* 文末の語の調子。preceding は文末の語より前の語。neutral は調子を持たない文末の語(語彙表 neutral-ending)。
|
|
27
33
|
* 文末に述語(動詞・形容詞・助動詞)が無ければ、ですます調でもである調でもないので undefined。
|
|
28
34
|
* 「以下の通り。」「円錐形の麦わら帽子。」のような名詞で終わる文を数えると、そのままである調の少数派になっていた。
|
|
29
35
|
* 書いた形でも原形でも読みでも当てる(polite-word.ts)。「ください」の原形は「くださる」で、原形だけを見ると丁寧な文末を見落とす。
|
|
30
36
|
*/
|
|
31
|
-
export const registerOf = (
|
|
32
|
-
|
|
37
|
+
export const registerOf = (
|
|
38
|
+
ending: readonly Token[],
|
|
39
|
+
preceding: readonly Token[],
|
|
40
|
+
polite: readonly LexiconEntry[],
|
|
41
|
+
neutral: readonly LexiconEntry[] = [],
|
|
42
|
+
): Register | undefined => {
|
|
43
|
+
const judged = withPreceding(ending, preceding, neutral);
|
|
33
44
|
if (!judged.some(isPredicate)) return undefined;
|
|
34
45
|
return judged.some((token) => isPoliteWord(token, polite)) ? "polite" : "plain";
|
|
35
46
|
};
|
|
@@ -56,21 +67,36 @@ export const groupOf = (offset: number, lists: readonly Span[], runs: readonly S
|
|
|
56
67
|
/** group: 文が入っているまとまり(groupOf の値)。本文なら undefined。 */
|
|
57
68
|
export type Judged = { readonly register: Register; readonly group: number | undefined };
|
|
58
69
|
|
|
59
|
-
/**
|
|
70
|
+
/** 混ざった文と、その文が属するまとまり(本文、または箇条書き 1 つ)の中の少数派の数。文書全体の数ではない。 */
|
|
60
71
|
export type Slip<T extends Judged> = { readonly entry: T; readonly count: number };
|
|
61
72
|
|
|
62
73
|
const countIn = (judged: readonly Judged[], register: Register): number => judged.filter((entry) => entry.register === register).length;
|
|
63
74
|
|
|
75
|
+
/** 多いほう。同数なら undefined。 */
|
|
76
|
+
export const majorityOf = (judged: readonly Judged[]): Register | undefined => {
|
|
77
|
+
const difference = countIn(judged, "polite") - countIn(judged, "plain");
|
|
78
|
+
if (difference === 0) return undefined;
|
|
79
|
+
return difference > 0 ? "polite" : "plain";
|
|
80
|
+
};
|
|
81
|
+
|
|
64
82
|
/** 少ないほう。同数なら文書全体で少ないほう、それも同数なら丁寧体。 */
|
|
65
83
|
const minorityOf = (group: readonly Judged[], whole: readonly Judged[]): Register => {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
84
|
+
const majority = majorityOf(group);
|
|
85
|
+
if (majority !== undefined) return majority === "polite" ? "plain" : "polite";
|
|
68
86
|
return countIn(whole, "polite") <= countIn(whole, "plain") ? "polite" : "plain";
|
|
69
87
|
};
|
|
70
88
|
|
|
89
|
+
/**
|
|
90
|
+
* 箇条書きの中の少数派が、文書全体では多数派か。それなら箇条書きの中で文書の調子に寄せた側なので、直す側ではない。
|
|
91
|
+
* 常体の多い箇条書きにですます調の文が混ざっても、ですます調の文書なら「多いほうに揃えて」は文書の少数派へ揃えることになる。
|
|
92
|
+
*/
|
|
93
|
+
export const followsDocument = (group: number | undefined, minority: Register, whole: readonly Judged[]): boolean =>
|
|
94
|
+
group !== undefined && majorityOf(whole) === minority;
|
|
95
|
+
|
|
71
96
|
const slipsInGroup = <T extends Judged>(judged: readonly T[], group: number | undefined, limit: number): Slip<T>[] => {
|
|
72
97
|
const members = judged.filter((entry) => entry.group === group);
|
|
73
98
|
const minority = minorityOf(members, judged);
|
|
99
|
+
if (followsDocument(group, minority, judged)) return [];
|
|
74
100
|
const slips = members.filter((entry) => entry.register === minority);
|
|
75
101
|
// 片方しか無ければ揃っている。少数派が閾値を超えて多ければ、混在ではなく別の文体。
|
|
76
102
|
if (slips.length === 0 || slips.length > limit) return [];
|
|
@@ -80,6 +106,7 @@ const slipsInGroup = <T extends Judged>(judged: readonly T[], group: number | un
|
|
|
80
106
|
/**
|
|
81
107
|
* 調子が混ざった文を、judged の順で。本文は本文どうし、箇条書きと番号で始まる段落の並びは 1 つずつ、その中で揃っているかを見る。
|
|
82
108
|
* ですます調の本文に常体の箇条書きを置くのはよくある書き方で、箇条書きが丸ごと揃っていれば混在ではない。
|
|
109
|
+
* 箇条書きの中で混ざっていても、少数派が文書全体の多数派なら指さない(followsDocument)。
|
|
83
110
|
*/
|
|
84
111
|
export const slipsOf = <T extends Judged>(judged: readonly T[], limit: number): Slip<T>[] => {
|
|
85
112
|
const slips = [...new Set(judged.map((entry) => entry.group))].flatMap((group) => slipsInGroup(judged, group, limit));
|
|
@@ -3,3 +3,6 @@
|
|
|
3
3
|
* 各桁が省けるので空文字にも当たる。1 文字目があることを先読みで求める。
|
|
4
4
|
*/
|
|
5
5
|
export const ROMAN_NUMERAL = "(?=[MDCLXVI])M{0,4}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})";
|
|
6
|
+
|
|
7
|
+
/** ハイフンかダッシュで繋いだ数字の範囲(II-VI、I–III)も、一つの番号として読む。 */
|
|
8
|
+
export const romanRangeOf = (numeral: string): string => `${numeral}(?:[-–]${numeral})?`;
|
|
@@ -12,11 +12,11 @@ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span } f
|
|
|
12
12
|
*/
|
|
13
13
|
type Entry = { readonly sentence: Sentence; readonly register: Register; readonly group: number | undefined };
|
|
14
14
|
|
|
15
|
-
const registerOfSentence = (sentence: Sentence, polite: readonly LexiconEntry[]): Register | undefined => {
|
|
15
|
+
const registerOfSentence = (sentence: Sentence, polite: readonly LexiconEntry[], neutral: readonly LexiconEntry[]): Register | undefined => {
|
|
16
16
|
const ending = endingTokens(sentence);
|
|
17
17
|
const tokens = sentence.tokens ?? [];
|
|
18
18
|
const head = ending[0] === undefined ? -1 : tokens.indexOf(ending[0]);
|
|
19
|
-
return registerOf(ending, head > 0 ? tokens.slice(0, head) : [], polite);
|
|
19
|
+
return registerOf(ending, head > 0 ? tokens.slice(0, head) : [], polite, neutral);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
/** 番号で始まる段落の並び。木を組むのは高いので、調子が一つだけの文書(混ざりようがない)では組まない。 */
|
|
@@ -30,25 +30,32 @@ const runsOf = (doc: ProseDocument, registers: readonly Register[]): Span[] => {
|
|
|
30
30
|
);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
/** 調子を持つ文と、比べ合うまとまり(groupOf)。polite は語彙表 polite-ending。 */
|
|
34
|
+
export const judgedSentences = (doc: ProseDocument, polite: readonly LexiconEntry[]): Entry[] => {
|
|
35
|
+
const neutral = doc.lexicons["neutral-ending"] ?? [];
|
|
35
36
|
const lists = doc.lists.map((list) => list.span);
|
|
36
37
|
const found = doc.sentences.flatMap((sentence, index): { sentence: Sentence; register: Register }[] => {
|
|
37
38
|
if (!isClosed(sentence) || continuesInto(sentence, doc.sentences[index + 1])) return [];
|
|
38
|
-
const register = registerOfSentence(sentence, polite);
|
|
39
|
+
const register = registerOfSentence(sentence, polite, neutral);
|
|
39
40
|
return register === undefined ? [] : [{ sentence, register }];
|
|
40
41
|
});
|
|
41
42
|
const runs = runsOf(
|
|
42
43
|
doc,
|
|
43
44
|
found.map((entry) => entry.register),
|
|
44
45
|
);
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
return found.map((entry): Entry => ({ ...entry, group: groupOf(entry.sentence.span.start, lists, runs) }));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const sentenceEnding: Detector = (doc, options): Finding[] => {
|
|
50
|
+
const judged = judgedSentences(doc, options.lexicon ?? []);
|
|
51
|
+
// 数えたのは文が属するまとまりの中なので、文言もそのまとまりを名指す(本文の中で / この箇条書きの中で)。
|
|
52
|
+
return slipsOf(judged, options.limit).map(({ entry: { sentence, group }, count }) => ({
|
|
47
53
|
rule: "no-mixed-desumasu",
|
|
48
54
|
severity: "warning",
|
|
49
55
|
line: 0,
|
|
50
56
|
column: 0,
|
|
51
57
|
quote: sentence.text.trim(),
|
|
58
|
+
...(group === undefined ? {} : { variant: "list" }),
|
|
52
59
|
values: { count, limit: options.limit, offset: sentence.span.start },
|
|
53
60
|
}));
|
|
54
61
|
};
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { lengthOf, proseText } from "../measure.ts";
|
|
2
|
-
import type { Detector, Finding } from "../plugin.ts";
|
|
2
|
+
import type { Detector, DetectorOptions, Finding, LengthUnit, Sentence } from "../plugin.ts";
|
|
3
|
+
|
|
4
|
+
type Measure = { readonly size: number; readonly limit: number; readonly variant?: string };
|
|
5
|
+
|
|
6
|
+
/** 文書と違う言語の文(和文の中の英文)は、その言語の単位と上限で測る。rule がその言語の段を持たなければ文書のもので。 */
|
|
7
|
+
const measureOf = (sentence: Sentence, unit: LengthUnit, options: DetectorOptions): Measure => {
|
|
8
|
+
const embedded = sentence.embeddedLanguage;
|
|
9
|
+
const limit = embedded === undefined ? undefined : options.embeddedLimits?.[embedded.id];
|
|
10
|
+
if (embedded === undefined || limit === undefined) return { size: lengthOf(sentence, unit), limit: options.limit };
|
|
11
|
+
return { size: lengthOf(sentence, embedded.lengthUnit), limit, variant: `embedded-${embedded.id}` };
|
|
12
|
+
};
|
|
3
13
|
|
|
4
14
|
export const sentenceLength: Detector = (doc, options): Finding[] =>
|
|
5
15
|
doc.sentences
|
|
6
|
-
.map((sentence) => ({ sentence,
|
|
7
|
-
.filter(({
|
|
8
|
-
.map(({ sentence,
|
|
16
|
+
.map((sentence) => ({ sentence, measure: measureOf(sentence, doc.lengthUnit, options) }))
|
|
17
|
+
.filter(({ measure }) => measure.size > measure.limit)
|
|
18
|
+
.map(({ sentence, measure }) => ({
|
|
9
19
|
rule: "max-sentence-length",
|
|
10
20
|
severity: "warning",
|
|
11
21
|
line: 0,
|
|
12
22
|
column: 0,
|
|
13
23
|
quote: proseText(sentence),
|
|
14
|
-
values: { count: size, limit:
|
|
24
|
+
values: { count: measure.size, limit: measure.limit, offset: sentence.span.start },
|
|
25
|
+
...(measure.variant === undefined ? {} : { variant: measure.variant }),
|
|
15
26
|
}));
|
package/src/detectors/signals.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { proseText } from "../measure.ts";
|
|
2
2
|
import { dateSpans, wordsOf } from "./structure.ts";
|
|
3
|
-
import { compacted,
|
|
3
|
+
import { compacted, placeAt, type Compacted } from "./gram-place.ts";
|
|
4
|
+
import { charWindows, wordWindows } from "./gram-windows.ts";
|
|
5
|
+
import { furnitureMask, isFurniture } from "./gram-furniture.ts";
|
|
4
6
|
import { notAcronymSpansOf, type NotAcronymSpans } from "./acronym-context.ts";
|
|
5
|
-
import { expansionAt, termEntryAcronyms, type ExpandedAt } from "./acronym-expansion.ts";
|
|
7
|
+
import { abbreviates, expansionAt, termEntryAcronyms, type ExpandedAt } from "./acronym-expansion.ts";
|
|
6
8
|
import { isExplained } from "./acronym-compound.ts";
|
|
7
9
|
import { conjugatedForms } from "./conjugated-form.ts";
|
|
8
10
|
import { evidenceSpans, hasNumeral, startsWithin } from "./concrete-evidence.ts";
|
|
@@ -17,7 +19,7 @@ const PER = 1000;
|
|
|
17
19
|
* これより短い文書では密度が暴れる。1 個で「1000 あたり 100」になる。
|
|
18
20
|
* 単位は言語で違うので、床も分ける。英語の 200 語と日本語の 200 文字では長さが桁で違う。
|
|
19
21
|
*/
|
|
20
|
-
const
|
|
22
|
+
export const MIN_DOCUMENT_LENGTH = { word: 200, char: 500 };
|
|
21
23
|
|
|
22
24
|
const bodyOf = (doc: ProseDocument): string => doc.sentences.map(proseText).join(" ");
|
|
23
25
|
|
|
@@ -41,7 +43,7 @@ export const emojiDensity: Detector = (doc, options): Finding[] => {
|
|
|
41
43
|
const hits = findIn(doc, EMOJI);
|
|
42
44
|
const first = hits[0];
|
|
43
45
|
const rate = density(doc, hits.length);
|
|
44
|
-
if (wordsOf(doc) <
|
|
46
|
+
if (wordsOf(doc) < MIN_DOCUMENT_LENGTH[doc.lengthUnit] || first === undefined || rate <= options.limit) return [];
|
|
45
47
|
return [
|
|
46
48
|
{
|
|
47
49
|
rule: "emoji-density",
|
|
@@ -55,26 +57,17 @@ export const emojiDensity: Detector = (doc, options): Finding[] => {
|
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
60
|
+
* 同じ言い回しの繰り返し。文字の並びで見るので、adapter の語の区切り(wordSplit)が要らない。英語の窓は空白で語の切れ目にそろえる。
|
|
59
61
|
* spec §10 が n-gram を選んだのはこのためで、新しい言語でそのまま動く。
|
|
60
62
|
*/
|
|
61
63
|
/**
|
|
62
64
|
* 窓の幅は単位で分ける。同じ 8 文字でも、日本語では 4〜5 形態素だが英語では 1 語半にしかならない。
|
|
63
|
-
*
|
|
65
|
+
* 英語の窓は語の切れ目にそろえ、18 文字に届くまで語を足す。文字で切ると " generat" のような語の断片が上位に来る。
|
|
66
|
+
* 18 は、文字で切っていた頃の 20 文字の窓から前後の空白を除いた長さ(" juxtaposed to said ")。
|
|
64
67
|
*/
|
|
65
|
-
const GRAM = { char: 8, word:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const countGrams = (text: string, width: number, names: readonly string[]): Map<string, number> => {
|
|
69
|
-
const counts = new Map<string, number>();
|
|
70
|
-
const named = nameSpans(text, names);
|
|
71
|
-
Array.from({ length: Math.max(0, text.length - width + 1) }).forEach((_, index) => {
|
|
72
|
-
if (touchesAny(named, index, index + width)) return;
|
|
73
|
-
const gram = text.slice(index, index + width);
|
|
74
|
-
counts.set(gram, (counts.get(gram) ?? 0) + 1);
|
|
75
|
-
});
|
|
76
|
-
return counts;
|
|
77
|
-
};
|
|
68
|
+
const GRAM = { char: 8, word: 18 };
|
|
69
|
+
|
|
70
|
+
const windowsOf = (text: string, unit: ProseDocument["lengthUnit"]): Span[] => (unit === "char" ? charWindows(text, GRAM.char) : wordWindows(text, GRAM.word));
|
|
78
71
|
|
|
79
72
|
/**
|
|
80
73
|
* 名前ではなく言い回しだけを数える。実文書で測ったら、上位は
|
|
@@ -93,49 +86,80 @@ const CONNECTIVE = { char: /[ぁ-ゖ].*[ぁ-ゖ].*[ぁ-ゖ]/u, word: /\S \S.*\S
|
|
|
93
86
|
|
|
94
87
|
const isPhrasing = (gram: string, unit: ProseDocument["lengthUnit"]): boolean => CONNECTIVE[unit].test(gram);
|
|
95
88
|
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return
|
|
89
|
+
/** 語句が最初に数えられた所。書かれたままの語句と、文と、文の中の範囲(sentence.text の位置)。 */
|
|
90
|
+
type FirstSeen = { readonly gram: string; readonly sentence: Sentence; readonly place: Span };
|
|
91
|
+
|
|
92
|
+
type Tally = { readonly counts: Map<string, number>; readonly first: Map<string, FirstSeen> };
|
|
93
|
+
|
|
94
|
+
/** 詰めた文の index 番目の文字が、リンクの文字か。 */
|
|
95
|
+
const linkedIn = (doc: ProseDocument, sentence: Sentence, source: Compacted): ((index: number) => boolean) => {
|
|
96
|
+
const links = doc.links.filter((link) => link.start < sentence.span.end && sentence.span.start < link.end);
|
|
97
|
+
return (index) => {
|
|
98
|
+
const at = sentence.span.start + (source.offsets[index] ?? -1);
|
|
99
|
+
return links.some((link) => link.start <= at && at < link.end);
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** 英語は大文字と小文字を区別せずに数える。文頭の "Proposals submitted via" も文中の "proposals submitted via" も同じ言い回し。 */
|
|
104
|
+
const keyOf = (gram: string, unit: ProseDocument["lengthUnit"]): string => (unit === "word" ? gram.toLowerCase() : gram);
|
|
105
|
+
|
|
106
|
+
const namesOf = (doc: ProseDocument): readonly string[] =>
|
|
107
|
+
doc.lengthUnit === "char" ? (doc.names ?? []).map((name) => name.replace(/\s+/gu, "")) : (doc.names ?? []);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 文をまたいで数えない。文の終わりと次の文の始まりが繋がると、固有名詞が言い回しに見える。
|
|
111
|
+
* 並べた名前にかかる語句も数えない。名前が繰り返されれば、その前後(「the …」)も一緒に繰り返されるのは当たり前。
|
|
112
|
+
* 一覧の飾り(gram-furniture.ts)も数えない。項目ごとに繰り返すのはひな形で、書き手ではない。
|
|
113
|
+
*/
|
|
114
|
+
const tallySentence = (doc: ProseDocument, sentence: Sentence, tally: Tally): void => {
|
|
115
|
+
const source = compacted(sentence.text, doc.lengthUnit);
|
|
116
|
+
const named = nameSpans(source.text, namesOf(doc));
|
|
117
|
+
const mask = furnitureMask(source.text, linkedIn(doc, sentence, source));
|
|
118
|
+
windowsOf(source.text, doc.lengthUnit)
|
|
119
|
+
.filter((window) => !touchesAny(named, window.start, window.end) && !isFurniture(source.text, mask, window))
|
|
120
|
+
.forEach((window) => {
|
|
121
|
+
const gram = source.text.slice(window.start, window.end);
|
|
122
|
+
const key = keyOf(gram, doc.lengthUnit);
|
|
123
|
+
tally.counts.set(key, (tally.counts.get(key) ?? 0) + 1);
|
|
124
|
+
const place = placeAt(source, window);
|
|
125
|
+
if (!tally.first.has(key) && place !== undefined) tally.first.set(key, { gram, sentence, place });
|
|
126
|
+
});
|
|
105
127
|
};
|
|
106
128
|
|
|
107
|
-
|
|
108
|
-
const
|
|
129
|
+
const gramsOf = (doc: ProseDocument): Tally => {
|
|
130
|
+
const tally: Tally = { counts: new Map(), first: new Map() };
|
|
131
|
+
doc.sentences.forEach((sentence) => tallySentence(doc, sentence, tally));
|
|
132
|
+
return tally;
|
|
133
|
+
};
|
|
109
134
|
|
|
110
135
|
/**
|
|
111
136
|
* 語句が文の中で占める範囲に、述語になる動詞か助動詞があるか(gram-predicate.ts)。
|
|
112
137
|
* 品詞が無ければ見分けられないので、これまでどおり言い回しとして数える。
|
|
113
138
|
*/
|
|
114
|
-
const hasPredicate = (
|
|
115
|
-
if (sentence.tokens === undefined) return true;
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
return hasPredicateIn(sentence.tokens, { start: sentence.span.start + place.start, end: sentence.span.start + place.end }, unit);
|
|
139
|
+
const hasPredicate = (at: FirstSeen | undefined, unit: ProseDocument["lengthUnit"]): boolean => {
|
|
140
|
+
if (at?.sentence.tokens === undefined) return true;
|
|
141
|
+
const start = at.sentence.span.start;
|
|
142
|
+
return hasPredicateIn(at.sentence.tokens, { start: start + at.place.start, end: start + at.place.end }, unit);
|
|
119
143
|
};
|
|
120
144
|
|
|
121
145
|
export const ngramRepetition: Detector = (doc, options): Finding[] => {
|
|
122
|
-
if (wordsOf(doc) <
|
|
123
|
-
const
|
|
124
|
-
const worst = [...
|
|
125
|
-
.filter(([
|
|
146
|
+
if (wordsOf(doc) < MIN_DOCUMENT_LENGTH[doc.lengthUnit]) return [];
|
|
147
|
+
const tally = gramsOf(doc);
|
|
148
|
+
const worst = [...tally.counts.entries()]
|
|
149
|
+
.filter(([key, count]) => count > options.limit && isPhrasing(key, doc.lengthUnit))
|
|
126
150
|
.toSorted(([, left], [, right]) => right - left)
|
|
127
|
-
.map(([
|
|
128
|
-
.find(({
|
|
151
|
+
.map(([key, count]) => ({ key, count, at: tally.first.get(key) }))
|
|
152
|
+
.find(({ at }) => hasPredicate(at, doc.lengthUnit));
|
|
129
153
|
if (worst === undefined) return [];
|
|
130
|
-
const at = worst.at;
|
|
154
|
+
const at = worst.at?.sentence;
|
|
131
155
|
return [
|
|
132
156
|
{
|
|
133
157
|
rule: "ngram-repetition",
|
|
134
158
|
severity: "info",
|
|
135
159
|
line: 0,
|
|
136
160
|
column: 0,
|
|
137
|
-
quote: at?.text.trim() ?? worst.
|
|
138
|
-
values: { word: worst.gram, count: worst.count, limit: options.limit, offset: at?.span.start ?? 0 },
|
|
161
|
+
quote: at?.text.trim() ?? worst.key,
|
|
162
|
+
values: { word: worst.at?.gram ?? worst.key, count: worst.count, limit: options.limit, offset: at?.span.start ?? 0 },
|
|
139
163
|
},
|
|
140
164
|
];
|
|
141
165
|
};
|
|
@@ -237,6 +261,13 @@ const outsideDates = (hits: readonly AcronymHit[], dates: readonly Span[]): Acro
|
|
|
237
261
|
const isExpanded = (body: string, acronym: string, expandedAt: ExpandedAt): boolean =>
|
|
238
262
|
[...body.matchAll(new RegExp(`${EDGE_BEFORE}${acronym}${EDGE_AFTER}`, "gu"))].some((match) => expandedAt(body, acronym, match.index));
|
|
239
263
|
|
|
264
|
+
/**
|
|
265
|
+
* 見出しは文にならないので、見出しの中の展開(Maximum Envelope of Water (MEOW) runs)は見出しの文字列で探す。
|
|
266
|
+
* 見出しの括弧は添え書き(Your Own AI (LLM)、(Beta))にも使うので、見出しの語から略語の文字が順に拾えるときだけ認める。
|
|
267
|
+
*/
|
|
268
|
+
const expandsInHeading = (heading: string, acronym: string, expandedAt: ExpandedAt): boolean =>
|
|
269
|
+
isExpanded(heading, acronym, expandedAt) && abbreviates(heading.replaceAll(acronym, " "), acronym);
|
|
270
|
+
|
|
240
271
|
const patternsOf = (doc: ProseDocument, id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
241
272
|
|
|
242
273
|
const notationOf = (doc: ProseDocument): NotAcronymSpans =>
|
|
@@ -247,6 +278,7 @@ const notationOf = (doc: ProseDocument): NotAcronymSpans =>
|
|
|
247
278
|
usStates: patternsOf(doc, "us-state-code"),
|
|
248
279
|
emphasis: patternsOf(doc, "emphasis-word"),
|
|
249
280
|
divisions: patternsOf(doc, "numbered-division"),
|
|
281
|
+
abbreviatedLabels: patternsOf(doc, "abbreviated-label"),
|
|
250
282
|
honorifics: patternsOf(doc, "honorific"),
|
|
251
283
|
titles: patternsOf(doc, "name-title"),
|
|
252
284
|
dateTimeUnits: patternsOf(doc, "date-time-unit"),
|
|
@@ -265,7 +297,9 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
|
|
|
265
297
|
const common = new Set([...(options.lexicon ?? []).map((entry) => entry.pattern), ...patternsOf(doc, "http-method"), ...(doc.names ?? [])]);
|
|
266
298
|
const expandedAt = expansionAt({ markers: patternsOf(doc, "definition-marker"), verbs: definitionVerbsOf(doc) });
|
|
267
299
|
const entries = termEntryAcronyms(doc.source);
|
|
268
|
-
const
|
|
300
|
+
const headings = doc.sections.map((section) => section.heading);
|
|
301
|
+
const explainedAlone = (word: string): boolean =>
|
|
302
|
+
common.has(word) || entries.has(word) || isExpanded(body, word, expandedAt) || headings.some((heading) => expandsInHeading(heading, word, expandedAt));
|
|
269
303
|
const hits = acronymsOf(doc, notationOf(doc));
|
|
270
304
|
const unexplained = new Set([...firstHits(hits).keys()].filter((acronym) => !isExplained(acronym, explainedAlone)));
|
|
271
305
|
// 日付を読むには文書の木を作る。上限に届かない文書では作らない。
|
|
@@ -339,7 +373,7 @@ export const dashDensity: Detector = (doc, options): Finding[] => {
|
|
|
339
373
|
const hits = findIn(doc, DASH);
|
|
340
374
|
const first = hits[0];
|
|
341
375
|
const rate = density(doc, hits.length);
|
|
342
|
-
if (wordsOf(doc) <
|
|
376
|
+
if (wordsOf(doc) < MIN_DOCUMENT_LENGTH[doc.lengthUnit] || first === undefined || rate <= options.limit) return [];
|
|
343
377
|
return [
|
|
344
378
|
{
|
|
345
379
|
rule: "no-em-dash",
|
|
@@ -4,11 +4,13 @@ import { numberingBreaks } from "../structure/numbering.ts";
|
|
|
4
4
|
import { weekdayMismatches } from "../structure/weekday.ts";
|
|
5
5
|
import { dateOrderBreaks } from "../structure/date-order.ts";
|
|
6
6
|
import { totalMismatches, type Amount } from "../structure/total.ts";
|
|
7
|
+
import { reversedRanges, type DatedSpan, type RangeWords } from "../structure/date-range.ts";
|
|
8
|
+
import { percentSumMismatches, type ShareWords } from "../structure/percent-sum.ts";
|
|
7
9
|
|
|
8
10
|
const QUOTE_LENGTH = 80;
|
|
9
11
|
|
|
10
12
|
/** 指摘の位置から行末までを引用する。条の見出しや参照を含む一行が、読み手の探す手がかりになる。 */
|
|
11
|
-
const quoteAt = (source: string, offset: number): string => {
|
|
13
|
+
export const quoteAt = (source: string, offset: number): string => {
|
|
12
14
|
const end = source.indexOf("\n", offset);
|
|
13
15
|
return source
|
|
14
16
|
.slice(offset, end === -1 ? source.length : end)
|
|
@@ -96,3 +98,45 @@ export const totalMismatch: Detector = (doc): Finding[] =>
|
|
|
96
98
|
quote: quoteAt(doc.source, issue.offset),
|
|
97
99
|
values: { ...issue.values, offset: issue.offset },
|
|
98
100
|
}));
|
|
101
|
+
|
|
102
|
+
const datedSpans = (tree: NonNullable<ProseDocument["structure"]>): DatedSpan[] =>
|
|
103
|
+
inDocumentOrder(tree).flatMap((node) => (node.kind === "date" ? [{ offset: node.span.start, end: node.span.end, value: String(node.attrs["value"]) }] : []));
|
|
104
|
+
|
|
105
|
+
const rangeWordsOf = (doc: ProseDocument): RangeWords => ({
|
|
106
|
+
connectors: (doc.lexicons["range-connector"] ?? []).map((entry) => entry.pattern),
|
|
107
|
+
openers: (doc.lexicons["range-opener"] ?? []).map((entry) => entry.pattern),
|
|
108
|
+
closers: (doc.lexicons["range-closer"] ?? []).map((entry) => entry.pattern),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
/** 期間の終わりが始まりより前。範囲の記号と語は言語パッケージの語彙表(range-connector、range-opener、range-closer)から取る。 */
|
|
112
|
+
export const dateRangeReversed: Detector = (doc): Finding[] =>
|
|
113
|
+
doc.structure === undefined
|
|
114
|
+
? []
|
|
115
|
+
: reversedRanges(doc.source, datedSpans(doc.structure), rangeWordsOf(doc)).map((issue) => ({
|
|
116
|
+
rule: "date-range-reversed",
|
|
117
|
+
severity: "warning",
|
|
118
|
+
line: 0,
|
|
119
|
+
column: 0,
|
|
120
|
+
quote: quoteAt(doc.source, issue.offset),
|
|
121
|
+
values: { ...issue.values, offset: issue.offset },
|
|
122
|
+
}));
|
|
123
|
+
|
|
124
|
+
const shareWordsOf = (doc: ProseDocument): ShareWords => ({
|
|
125
|
+
labels: (doc.lexicons["share-label"] ?? []).map((entry) => entry.pattern),
|
|
126
|
+
exceptions: (doc.lexicons["share-exception"] ?? []).map((entry) => entry.pattern),
|
|
127
|
+
units: (doc.lexicons["percent-unit"] ?? []).map((entry) => entry.pattern),
|
|
128
|
+
totalLabels: (doc.lexicons["total-label"] ?? []).map((entry) => entry.pattern),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
/** 構成比や内訳の百分率の和が 100% にならない。割合の語と百分率の単位は言語パッケージの語彙表から取る。 */
|
|
132
|
+
export const percentSumMismatch: Detector = (doc): Finding[] =>
|
|
133
|
+
doc.structure === undefined
|
|
134
|
+
? []
|
|
135
|
+
: percentSumMismatches(doc.source, amountsOf(doc.structure), shareWordsOf(doc)).map((issue) => ({
|
|
136
|
+
rule: "percent-sum-mismatch",
|
|
137
|
+
severity: "warning",
|
|
138
|
+
line: 0,
|
|
139
|
+
column: 0,
|
|
140
|
+
quote: quoteAt(doc.source, issue.offset),
|
|
141
|
+
values: { ...issue.values, offset: issue.offset },
|
|
142
|
+
}));
|
|
@@ -4,6 +4,7 @@ import { dateStampIndexes, stampCandidates } from "../date-stamp.ts";
|
|
|
4
4
|
import { inDocumentOrder } from "../structure/issues.ts";
|
|
5
5
|
import { preambleParagraphs } from "../preamble-paragraphs.ts";
|
|
6
6
|
import { isTooLongParagraph } from "../paragraph-length.ts";
|
|
7
|
+
import { bodySectionOf } from "../body-section.ts";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* ばらつきは変動係数(標準偏差 ÷ 平均)で測る。
|
|
@@ -118,12 +119,10 @@ const withoutDateStamps = (doc: ProseDocument, paragraphs: readonly Paragraph[])
|
|
|
118
119
|
|
|
119
120
|
/**
|
|
120
121
|
* 本題に入るまでが長い。業務文書では、読み手は結論を探しに来ている。
|
|
121
|
-
*
|
|
122
|
-
* 「本題」は最初の中見出し(深さ 2 以上)とする。表題(深さ 1)の直後から数えると、
|
|
123
|
-
* 表題しか無い文書で全文が前置きになる。中見出しが無い文書では何も言わない。
|
|
122
|
+
* 「本題」は最初の中見出し。中見出しが無い文書では、rule が requires の headings で動かず、動かなかった理由が出る。
|
|
124
123
|
*/
|
|
125
124
|
export const preambleLength: Detector = (doc, options): Finding[] => {
|
|
126
|
-
const body = doc.sections
|
|
125
|
+
const body = bodySectionOf(doc.sections);
|
|
127
126
|
if (body === undefined) return [];
|
|
128
127
|
const all = preambleParagraphs(doc.paragraphs, body.span.start);
|
|
129
128
|
if (all.length <= options.limit) return [];
|
|
@@ -9,10 +9,13 @@ const joinsAsNoun = (previous: Token, token: Token | undefined): token is Token
|
|
|
9
9
|
|
|
10
10
|
/** 空白も助詞も挟まずに続く名詞の連なり(最大|瞬間|風速)の最後の語。連なりが無ければ undefined。 */
|
|
11
11
|
const lastJoined = (tokens: readonly Token[], at: number): Token | undefined => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
let last: Token | undefined;
|
|
13
|
+
for (let index = at; ; index += 1) {
|
|
14
|
+
const previous = tokens[index - 1];
|
|
15
|
+
const token = tokens[index];
|
|
16
|
+
if (previous === undefined || !joinsAsNoun(previous, token)) return last;
|
|
17
|
+
last = token;
|
|
18
|
+
}
|
|
16
19
|
};
|
|
17
20
|
|
|
18
21
|
const measures = (noun: Token, quantities: Lexicon): boolean => quantities.some((entry) => entry.pattern === noun.surface);
|
|
@@ -48,9 +48,14 @@ const namedBefore = (tokens: readonly Token[], range: TokenRange, markers: Lexic
|
|
|
48
48
|
|
|
49
49
|
/** 最上級に続く名詞句の終わり。名詞が出るまでは修飾を、出た後は名詞の連なりを読む。 */
|
|
50
50
|
export const phraseEnd = (tokens: readonly Token[], at: number, nounSeen = false): number => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
let end = at;
|
|
52
|
+
let seen = nounSeen;
|
|
53
|
+
for (;;) {
|
|
54
|
+
const token = tokens[end];
|
|
55
|
+
if (token === undefined || !(seen ? NOUN_RUN : PREMODIFIER).has(token.pos)) return end;
|
|
56
|
+
seen ||= NOMINAL.has(token.pos);
|
|
57
|
+
end += 1;
|
|
58
|
+
}
|
|
54
59
|
};
|
|
55
60
|
|
|
56
61
|
/** 最上級 + 名詞句 + 範囲の語 + 名詞句(the best pizza in Chicago・the most famous of the sculptures)。 */
|