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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Detector, Finding } from "../plugin.ts";
|
|
2
|
+
import { quoteAround } from "./quote-around.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 句読点が二つ並んだところ(「。。」「、。」「,,」「..」)。打ち直しで残った印。
|
|
6
|
+
* 同じ印を三つ以上並べたもの(「...」「。。。」)は、わざと伸ばした書き方なので数えない。
|
|
7
|
+
* コロンは「::」(C++ の名前、IPv6)があるので見ない。
|
|
8
|
+
*/
|
|
9
|
+
const PUNCTUATION_RUN = /[、。,.,.;;]{2,}/gu;
|
|
10
|
+
|
|
11
|
+
/** 略語の点の後ろの読点やセミコロン(e.g.,、Inc.,、etc.;)。 */
|
|
12
|
+
const AFTER_ABBREVIATION = /^\.[,;]$/u;
|
|
13
|
+
|
|
14
|
+
const WORD = /[\p{L}\p{N}]/u;
|
|
15
|
+
|
|
16
|
+
/** 「..」の前後が字か数字か「/」なら、範囲や道のり(1..10、a..b、../)で、書き損じではない。 */
|
|
17
|
+
const JOINED = /[\p{L}\p{N}/]/u;
|
|
18
|
+
|
|
19
|
+
const isDrawnOut = (run: string): boolean => run.length >= 3 && [...run].every((mark) => mark === run.charAt(0));
|
|
20
|
+
|
|
21
|
+
const isJoinedDots = (text: string, start: number, run: string): boolean =>
|
|
22
|
+
run === ".." && (JOINED.test(text.charAt(start + run.length)) || text.charAt(start - 1) === "/");
|
|
23
|
+
|
|
24
|
+
export type DoubledMarks = { readonly start: number; readonly run: string };
|
|
25
|
+
|
|
26
|
+
/** 並びの終わりの点が次の語の頭(「、.NET」「。.well-known」)なら、その点は語のうち。 */
|
|
27
|
+
const withoutWordDot = (text: string, found: DoubledMarks): DoubledMarks =>
|
|
28
|
+
found.run.endsWith(".") && !isDrawnOut(found.run) && found.run !== ".." && WORD.test(text.charAt(found.start + found.run.length))
|
|
29
|
+
? { start: found.start, run: found.run.slice(0, -1) }
|
|
30
|
+
: found;
|
|
31
|
+
|
|
32
|
+
const isSlip = (text: string, { start, run }: DoubledMarks): boolean =>
|
|
33
|
+
run.length >= 2 && !isDrawnOut(run) && !AFTER_ABBREVIATION.test(run) && !isJoinedDots(text, start, run);
|
|
34
|
+
|
|
35
|
+
/** text の中の、句読点が重なった並び(位置と並び)。 */
|
|
36
|
+
export const doubledMarks = (text: string): DoubledMarks[] =>
|
|
37
|
+
[...text.matchAll(PUNCTUATION_RUN)].map((match) => withoutWordDot(text, { start: match.index, run: match[0] })).filter((found) => isSlip(text, found));
|
|
38
|
+
|
|
39
|
+
export const doubledPunctuation: Detector = (doc): Finding[] => {
|
|
40
|
+
const text = doc.prose ?? doc.source;
|
|
41
|
+
return doubledMarks(text).map(({ start, run }) => ({
|
|
42
|
+
rule: "",
|
|
43
|
+
severity: "warning",
|
|
44
|
+
line: 0,
|
|
45
|
+
column: 0,
|
|
46
|
+
quote: quoteAround(text, start, start + run.length),
|
|
47
|
+
values: { marks: run, offset: start },
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
@@ -90,7 +90,18 @@ export const doubledAt = (source: string, first: Token, second: Token, spaced: b
|
|
|
90
90
|
export const isNameBefore = (first: Token, second: Token, opensSentence: boolean): boolean =>
|
|
91
91
|
!opensSentence && !isDeterminer(first) && UPPER_START.test(first.surface) && LOWER_START.test(second.surface);
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
/** 大文字 1 字の語。 */
|
|
94
|
+
const SINGLE_CAPITAL = /^\p{Lu}$/u;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 文の途中の大文字 1 字の冠詞(at site A the connection、Peer A our copy)は、名前にした文字。冠詞は文の途中で大文字にならない。
|
|
98
|
+
* 同じ語(site A a)と文頭の A the は書き損じのまま。
|
|
99
|
+
*/
|
|
100
|
+
export const isLetterName = (first: Token, second: Token, opensSentence: boolean): boolean =>
|
|
101
|
+
!opensSentence && SINGLE_CAPITAL.test(first.surface) && !sameWord(first, second);
|
|
102
|
+
|
|
103
|
+
/** 文の最初の、字のある語の位置。at 語目より前に字のある語が無ければ、at 語目は文の書き出し。 */
|
|
104
|
+
const firstWordIndex = (tokens: readonly Token[]): number => tokens.findIndex((token) => LETTER.test(token.surface));
|
|
94
105
|
|
|
95
106
|
const repeatsPrevious = (tokens: readonly Token[], at: number): boolean => {
|
|
96
107
|
const [previous, token] = [tokens[at - 1], tokens[at]];
|
|
@@ -110,14 +121,18 @@ export const opensPhrase = (tokens: readonly Token[], at: number, phrases: Lexic
|
|
|
110
121
|
return words.length > 1 && surfacesOf(tokens.slice(at, at + words.length)) === surfacesOf(words);
|
|
111
122
|
});
|
|
112
123
|
|
|
113
|
-
export const doubledIn = (source: string, tokens: readonly Token[], spaced: boolean, allowed: Lexicon, phrases: Lexicon = []): Doubled[] =>
|
|
114
|
-
|
|
124
|
+
export const doubledIn = (source: string, tokens: readonly Token[], spaced: boolean, allowed: Lexicon, phrases: Lexicon = []): Doubled[] => {
|
|
125
|
+
const firstWord = firstWordIndex(tokens);
|
|
126
|
+
return tokens.flatMap((second, index) => {
|
|
115
127
|
const first = tokens[index - 1];
|
|
116
128
|
if (first === undefined || !doubledAt(source, first, second, spaced)) return [];
|
|
117
129
|
if (isAllowed(tokens, index - 1, allowedAt(tokens, index - 1, allowed))) return [];
|
|
118
130
|
if (!sameWord(first, second) && opensPhrase(tokens, index, phrases)) return [];
|
|
119
|
-
|
|
131
|
+
// first は字のある語なので、firstWord は見つかっていて index - 1 以下。
|
|
132
|
+
const opens = firstWord >= index - 1;
|
|
133
|
+
return isNameBefore(first, second, opens) || isLetterName(first, second, opens) ? [] : [{ first, second }];
|
|
120
134
|
});
|
|
135
|
+
};
|
|
121
136
|
|
|
122
137
|
/** 印を挟んでいても(the [the)、見せるのは二語だけ。 */
|
|
123
138
|
const wordOf = (doubled: Doubled, spaced: boolean): string => [doubled.first.surface, doubled.second.surface].join(spaced ? " " : "");
|
|
@@ -12,10 +12,19 @@ const labelOf = (node: StructureNode): string => {
|
|
|
12
12
|
* 条の外で、番号の付いた行(言語パッケージが項目と読んだ「(1)」など)。
|
|
13
13
|
* 条の中の番号付きの行は、条の項(条の本文の続き)でもありうるので数えない。
|
|
14
14
|
*/
|
|
15
|
-
export const numberedStarts = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export const numberedStarts = (root: StructureNode, inArticle = false): NumberedStart[] => {
|
|
16
|
+
const found: NumberedStart[] = [];
|
|
17
|
+
const pending = [{ node: root, inArticle }];
|
|
18
|
+
while (pending.length > 0) {
|
|
19
|
+
const next = pending.pop();
|
|
20
|
+
if (next === undefined) break;
|
|
21
|
+
const { node } = next;
|
|
22
|
+
if (node.kind === "item" && !next.inArticle) found.push({ start: node.span.start, label: labelOf(node) });
|
|
23
|
+
const within = next.inArticle || node.kind === "article";
|
|
24
|
+
node.children.toReversed().forEach((child) => pending.push({ node: child, inArticle: within }));
|
|
25
|
+
}
|
|
26
|
+
return found;
|
|
27
|
+
};
|
|
19
28
|
|
|
20
29
|
const INDENT = /^[ \t\u3000]*/u;
|
|
21
30
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
|
|
3
|
+
// ひな形が項目ごとに繰り返す飾り(一覧の札、リンクの文字、記号の並び)。書き手の言い回しではない。
|
|
4
|
+
|
|
5
|
+
const MARK = /[\p{P}\p{S}]/gu;
|
|
6
|
+
|
|
7
|
+
const BRACKETED = /[([{([{]([^()[\]{}()[]{}]*)[)\]})]}]/gu;
|
|
8
|
+
|
|
9
|
+
/** 札の 1 項目。空白を含まない 1 語で、平仮名も含まない(日本語で平仮名を含めば、括弧の中は言い回し)。 */
|
|
10
|
+
const TAG_ITEM = /^\s*[^\s\p{Script=Hiragana}]+\s*$/u;
|
|
11
|
+
|
|
12
|
+
/** 括弧の中が、1 語か 1 語ずつの並び((replaced)、[pdf, html, other])。(if applicable) のような句は札ではない。 */
|
|
13
|
+
const isTag = (inside: string): boolean => inside.split(/[,、]/u).every((item) => TAG_ITEM.test(item));
|
|
14
|
+
|
|
15
|
+
const spansOf = (text: string, pattern: RegExp, keep: (match: RegExpExecArray) => boolean): Span[] =>
|
|
16
|
+
[...text.matchAll(pattern)].filter(keep).map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
17
|
+
|
|
18
|
+
/** text の各位置(UTF-16 の単位)が飾りか。記号・句読点、括弧でくくった札、リンクの文字(linked が決める)。 */
|
|
19
|
+
export const furnitureMask = (text: string, linked: (index: number) => boolean): boolean[] => {
|
|
20
|
+
const mask = Array.from({ length: text.length }, (_, index) => linked(index));
|
|
21
|
+
[...spansOf(text, MARK, () => true), ...spansOf(text, BRACKETED, (match) => isTag(match[1] ?? ""))].forEach((span) => mask.fill(true, span.start, span.end));
|
|
22
|
+
return mask;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** 窓の中の空白でない文字の過半が飾りなら、その出現は飾り。 */
|
|
26
|
+
export const isFurniture = (text: string, mask: readonly boolean[], window: Span): boolean => {
|
|
27
|
+
const visible = Array.from({ length: window.end - window.start }, (_, step) => window.start + step).filter((index) => !/\s/u.test(text[index] ?? ""));
|
|
28
|
+
const marked = visible.filter((index) => mask[index] === true);
|
|
29
|
+
return visible.length > 0 && marked.length * 2 > visible.length;
|
|
30
|
+
};
|
|
@@ -37,12 +37,16 @@ export const compacted = (text: string, unit: LengthUnit): Compacted => {
|
|
|
37
37
|
return { text: chars.join(""), offsets };
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
/** 詰めた文の中の範囲を、元の文の範囲に戻す。 */
|
|
41
|
+
export const placeAt = (source: Compacted, window: Span): Span | undefined => {
|
|
42
|
+
const start = source.offsets[window.start];
|
|
43
|
+
const last = source.offsets[window.end - 1];
|
|
44
|
+
if (start === undefined || last === undefined) return undefined;
|
|
45
|
+
return { start, end: last + 1 };
|
|
46
|
+
};
|
|
47
|
+
|
|
40
48
|
/** 詰めた文の中の gram の最初の出現を、元の文の範囲に戻す。無ければ undefined。 */
|
|
41
49
|
export const placeOf = (source: Compacted, gram: string): Span | undefined => {
|
|
42
50
|
const at = source.text.indexOf(gram);
|
|
43
|
-
|
|
44
|
-
const start = source.offsets[at];
|
|
45
|
-
const last = source.offsets[at + gram.length - 1];
|
|
46
|
-
if (start === undefined || last === undefined) return undefined;
|
|
47
|
-
return { start, end: last + 1 };
|
|
51
|
+
return at === -1 ? undefined : placeAt(source, { start: at, end: at + gram.length });
|
|
48
52
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
|
|
3
|
+
/** 1 文字ずつずらした、幅 width の窓。 */
|
|
4
|
+
export const charWindows = (text: string, width: number): Span[] =>
|
|
5
|
+
Array.from({ length: Math.max(0, text.length - width + 1) }, (_, start) => ({ start, end: start + width }));
|
|
6
|
+
|
|
7
|
+
/** first 番目の語から数えて、minLength 文字に届く最初の語。届く前に尽きるのは minLength 文字に満たない末尾だけなので、深くならない。 */
|
|
8
|
+
const reachingWord = (words: readonly Span[], first: number, minLength: number): Span | undefined => {
|
|
9
|
+
const start = words[first]?.start ?? 0;
|
|
10
|
+
const step = (index: number): Span | undefined => {
|
|
11
|
+
const word = words[index];
|
|
12
|
+
if (word === undefined || word.end - start >= minLength) return word;
|
|
13
|
+
return step(index + 1);
|
|
14
|
+
};
|
|
15
|
+
return step(first);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** 語。前後の句読点と括弧は含めない。"described," と "described" を別の語句として数えないため。 */
|
|
19
|
+
const WORD = /[\p{L}\p{N}](?:\S*[\p{L}\p{N}])?/gu;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 語の頭で始まり語の尾で終わる窓。語を 1 つずつ足して、minLength 文字に届いた最短のもの。
|
|
23
|
+
* 文字で切ると " generat" や "roductivity change a" のような語の断片が数えられる。
|
|
24
|
+
*/
|
|
25
|
+
export const wordWindows = (text: string, minLength: number): Span[] => {
|
|
26
|
+
const words = [...text.matchAll(WORD)].map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
27
|
+
return words.flatMap((first, index) => {
|
|
28
|
+
const last = reachingWord(words, index, minLength);
|
|
29
|
+
return last === undefined ? [] : [{ start: first.start, end: last.end }];
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -1,7 +1,33 @@
|
|
|
1
|
+
import { straightApostrophes } from "../orthography.ts";
|
|
2
|
+
import { withoutCodeWords } from "./heading-code-words.ts";
|
|
3
|
+
|
|
4
|
+
/** 語の中のアポストロフィは ' に畳んでから読む(Fed’s)。’ を語の外に置くと、’s が小文字の語に見える。 */
|
|
1
5
|
const WORD = /[A-Za-z][A-Za-z'-]*/gu;
|
|
2
6
|
|
|
3
7
|
/** 小さい語は Title Case でも小文字のままなので、大文字化の判定から外す。 */
|
|
4
|
-
const
|
|
8
|
+
export const MINOR_WORDS: ReadonlySet<string> = new Set([
|
|
9
|
+
"a",
|
|
10
|
+
"an",
|
|
11
|
+
"the",
|
|
12
|
+
"and",
|
|
13
|
+
"or",
|
|
14
|
+
"but",
|
|
15
|
+
"of",
|
|
16
|
+
"in",
|
|
17
|
+
"on",
|
|
18
|
+
"at",
|
|
19
|
+
"to",
|
|
20
|
+
"for",
|
|
21
|
+
"with",
|
|
22
|
+
"as",
|
|
23
|
+
"by",
|
|
24
|
+
"from",
|
|
25
|
+
"is",
|
|
26
|
+
// 語の並び(WORD)は点を含まないので、vs. と v. は vs と v で拾う。
|
|
27
|
+
"vs",
|
|
28
|
+
"v",
|
|
29
|
+
"via",
|
|
30
|
+
]);
|
|
5
31
|
|
|
6
32
|
/** 大文字だけの語(PR・FCPs)は略語で、どちらの流儀でも大文字のまま。Title Case の証拠にならない。 */
|
|
7
33
|
const ACRONYM = /^[A-Z]{2,}s?$/u;
|
|
@@ -10,7 +36,9 @@ const TITLE_DEPTH = 1;
|
|
|
10
36
|
|
|
11
37
|
/** 見出しが Title Case か。判定できなければ undefined。 */
|
|
12
38
|
export const isTitleCase = (heading: string): boolean | undefined => {
|
|
13
|
-
const words = [...heading.matchAll(WORD)]
|
|
39
|
+
const words = [...withoutCodeWords(straightApostrophes(heading)).matchAll(WORD)]
|
|
40
|
+
.map((match) => match[0])
|
|
41
|
+
.filter((word) => !MINOR_WORDS.has(word.toLowerCase()) && !ACRONYM.test(word));
|
|
14
42
|
// 1 語の見出しは、どちらの流儀でも先頭が大文字になる。判定できない。
|
|
15
43
|
if (words.length < 2) return undefined;
|
|
16
44
|
const capitalized = words.filter((word) => word[0] === word[0]?.toUpperCase()).length;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// A code span closes at the next run of exactly as many backticks as opened it: ``a ` b`` is one span.
|
|
2
|
+
const CODE_SPAN = /(?<!`)(`+)(?!`)[\s\S]*?(?<!`)\1(?!`)/gu;
|
|
3
|
+
|
|
4
|
+
const OPENING = new Set([..."(\"'“‘["]);
|
|
5
|
+
const CLOSING = new Set([...")\"'”’].,:;!?"]);
|
|
6
|
+
|
|
7
|
+
/** The word without the punctuation around it: `(optional)` is `optional`, `Setup:` is `Setup`. */
|
|
8
|
+
const bareWord = (token: string): string => {
|
|
9
|
+
const chars = [...token];
|
|
10
|
+
const first = chars.findIndex((char) => !OPENING.has(char));
|
|
11
|
+
const last = chars.findLastIndex((char) => !CLOSING.has(char));
|
|
12
|
+
return first === -1 || last < first ? "" : chars.slice(first, last + 1).join("");
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** A mark a word of prose does not carry inside it: `config.yaml`, `snake_case`, `src/index`, `useEffect()`, `$HOME`. */
|
|
16
|
+
const CODE_MARK = /[._/\\=(){}[\]<>$@#*]/u;
|
|
17
|
+
|
|
18
|
+
/** A word that starts in lower case and has a capital after it (`useEffect`, `iPhone`): its case is its owner's. */
|
|
19
|
+
const CAMEL_CASE = /^[a-z]+[A-Z]/u;
|
|
20
|
+
|
|
21
|
+
const isCodeWord = (token: string): boolean => {
|
|
22
|
+
const bare = bareWord(token);
|
|
23
|
+
return bare.startsWith("-") || CAMEL_CASE.test(bare) || CODE_MARK.test(bare);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The heading without its code words: a code span, a flag (`--force`), a file name (`config.yaml`), an identifier
|
|
28
|
+
* (`useEffect`). They are written the same in Title Case and in sentence case, so they are evidence for neither.
|
|
29
|
+
*/
|
|
30
|
+
export const withoutCodeWords = (heading: string): string =>
|
|
31
|
+
heading
|
|
32
|
+
.replace(CODE_SPAN, " ")
|
|
33
|
+
.split(/\s+/u)
|
|
34
|
+
.filter((token) => !isCodeWord(token))
|
|
35
|
+
.join(" ");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { lengthOf, proseText } from "../measure.ts";
|
|
2
2
|
import { newContentMorphemes } from "./content-morphemes.ts";
|
|
3
3
|
import { echoedHeadingUnits, trigrams } from "./heading-overlap.ts";
|
|
4
|
+
import { titleTokens } from "../heading-label.ts";
|
|
4
5
|
import { handsOver } from "./lead-in.ts";
|
|
5
6
|
import { withoutQuotedVariants } from "./quoted-variant.ts";
|
|
6
7
|
import type { Detector, Finding, LengthUnit, ProseDocument, Section } from "../plugin.ts";
|
|
@@ -37,12 +38,15 @@ const NEW_MATERIAL = { word: 6, char: 20 };
|
|
|
37
38
|
*/
|
|
38
39
|
const NEW_CONTENT_MORPHEMES = 1;
|
|
39
40
|
|
|
41
|
+
/** 重なりを測る見出し。頭の番号の札(例 3:、Step 3:、1.)は本文で繰り返されないので、数えると短い見出しほど重なりが下がる。 */
|
|
42
|
+
const measuredHeading = (section: Section): string => section.unlabeledHeading ?? section.heading;
|
|
43
|
+
|
|
40
44
|
const addsLittle = (section: Section, unit: LengthUnit): boolean => {
|
|
41
45
|
const first = section.firstSentence;
|
|
42
46
|
if (first === undefined) return false;
|
|
43
47
|
if (unit === "char" && first.tokens !== undefined && section.headingTokens !== undefined)
|
|
44
|
-
return newContentMorphemes(section.headingTokens, first.tokens) <= NEW_CONTENT_MORPHEMES;
|
|
45
|
-
return lengthOf(first, unit) - echoedHeadingUnits(section
|
|
48
|
+
return newContentMorphemes(titleTokens(section.heading, measuredHeading(section), section.headingTokens), first.tokens) <= NEW_CONTENT_MORPHEMES;
|
|
49
|
+
return lengthOf(first, unit) - echoedHeadingUnits(measuredHeading(section), proseText(first), unit) <= NEW_MATERIAL[unit];
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
/** 最初の文が、同じ節の後ろ(箇条書き・表・コード)へ読者を渡している。 */
|
|
@@ -52,14 +56,14 @@ const leadsIn = (doc: ProseDocument, section: Section, phrases: readonly string[
|
|
|
52
56
|
};
|
|
53
57
|
|
|
54
58
|
/** 見出しとの重なりを測る文。用語集や表記の手引きは見出しの語の別の書き方を引用する(Not “datacentre”)ので、それは数えない。 */
|
|
55
|
-
const echoedText = (section: Section): string => withoutQuotedVariants(section.firstSentence?.text ?? "", section
|
|
59
|
+
const echoedText = (section: Section): string => withoutQuotedVariants(section.firstSentence?.text ?? "", measuredHeading(section));
|
|
56
60
|
|
|
57
61
|
export const headingEcho: Detector = (doc, options): Finding[] => {
|
|
58
62
|
const leadIns = (doc.lexicons["lead-in"] ?? []).map((entry) => entry.pattern);
|
|
59
63
|
return doc.sections
|
|
60
64
|
.filter((section) => section.heading.length > 0 && section.firstSentence !== undefined && addsLittle(section, doc.lengthUnit))
|
|
61
65
|
.filter((section) => !leadsIn(doc, section, leadIns))
|
|
62
|
-
.map((section) => ({ section, overlap: Math.round(containment(trigrams(section
|
|
66
|
+
.map((section) => ({ section, overlap: Math.round(containment(trigrams(measuredHeading(section)), trigrams(echoedText(section))) * 100) }))
|
|
63
67
|
.filter(({ overlap }) => overlap >= options.limit)
|
|
64
68
|
.map(({ section, overlap }) => ({
|
|
65
69
|
rule: "heading-echo",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Detector, Finding, MarkupHeading } from "../plugin.ts";
|
|
2
|
+
import { findingAt, markupOf } from "./markup-finding.ts";
|
|
3
|
+
|
|
4
|
+
export type SkippedHeading = { readonly heading: MarkupHeading; readonly from: number };
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 一つ前の見出しより二段以上深い見出し(## の次の ####)。最初の見出しは何段から始めてもよい。
|
|
8
|
+
* 飛んだ後は、飛んだ先の深さを基準にする(#### の次の #### は飛んでいない)。markdownlint の MD001 と同じ数え方。
|
|
9
|
+
*/
|
|
10
|
+
export const skippedHeadings = (headings: readonly MarkupHeading[]): SkippedHeading[] =>
|
|
11
|
+
headings.flatMap((heading, index) => {
|
|
12
|
+
const previous = headings[index - 1];
|
|
13
|
+
return previous !== undefined && heading.depth > previous.depth + 1 ? [{ heading, from: previous.depth }] : [];
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const headingLevelSkip: Detector = (doc): Finding[] =>
|
|
17
|
+
skippedHeadings(markupOf(doc)?.headings ?? []).map(({ heading, from }) =>
|
|
18
|
+
findingAt(doc, heading, { heading: heading.text, from, to: heading.depth, expected: from + 1 }),
|
|
19
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Detector, Finding, MarkupImage } from "../plugin.ts";
|
|
2
|
+
import { findingAt, markupOf, quoteOf } from "./markup-finding.ts";
|
|
3
|
+
|
|
4
|
+
/** 代替テキストの無い画像。Markdown の `` は alt が空、HTML の `<img>` は alt 属性が無いもの。`alt=""` は飾りと明示したので数えない。 */
|
|
5
|
+
const lacksAlt = (source: string, image: MarkupImage): boolean => {
|
|
6
|
+
if (image.alt === undefined) return true;
|
|
7
|
+
return image.alt.trim() === "" && !source.startsWith("<", image.start);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const imageAltText: Detector = (doc): Finding[] =>
|
|
11
|
+
(markupOf(doc)?.images ?? []).filter((image) => lacksAlt(doc.source, image)).map((image) => findingAt(doc, image, { image: quoteOf(doc.source, image) }));
|
package/src/detectors/index.ts
CHANGED
|
@@ -19,7 +19,28 @@ import { aiTell, contractionMix, cushionDensity, hedging, repeatedConjunction, u
|
|
|
19
19
|
import { internalJargon, properNounDensity, requiredSections } from "./team.ts";
|
|
20
20
|
import { latinSpacing, preferredTerm } from "./orthography.ts";
|
|
21
21
|
import { straySpace } from "./stray-space.ts";
|
|
22
|
-
import {
|
|
22
|
+
import { announcedCount } from "./announced-count.ts";
|
|
23
|
+
import { danglingFigure } from "./dangling-figure.ts";
|
|
24
|
+
import {
|
|
25
|
+
danglingReference,
|
|
26
|
+
dateOrder,
|
|
27
|
+
dateRangeReversed,
|
|
28
|
+
dateWeekdayMismatch,
|
|
29
|
+
duplicateDefinition,
|
|
30
|
+
numberingGap,
|
|
31
|
+
percentSumMismatch,
|
|
32
|
+
totalMismatch,
|
|
33
|
+
} from "./structure-tree.ts";
|
|
34
|
+
import { headingLevelSkip } from "./heading-level-skip.ts";
|
|
35
|
+
import { imageAltText } from "./image-alt-text.ts";
|
|
36
|
+
import { brokenLink } from "./broken-link.ts";
|
|
37
|
+
import { urlRunOn } from "./url-run-on.ts";
|
|
38
|
+
import { unbalancedBracket } from "./unbalanced-bracket.ts";
|
|
39
|
+
import { doubledPunctuation } from "./doubled-punctuation.ts";
|
|
40
|
+
import { kutotenConsistency } from "./kutoten-consistency.ts";
|
|
41
|
+
import { katakanaLongVowel } from "./long-vowel.ts";
|
|
42
|
+
import { customPattern, customTokens, customWords } from "./custom.ts";
|
|
43
|
+
import { assistantResidue, colonLeadIn, contrastFraming, openerDensity, openerPile, unfilledPlaceholder } from "./ai-phrasing.ts";
|
|
23
44
|
|
|
24
45
|
/** rule 定義の how_to_find がここを引く。rule 側は実装を知らない。 */
|
|
25
46
|
export const DETECTORS: Readonly<Record<string, Detector>> = {
|
|
@@ -58,6 +79,12 @@ export const DETECTORS: Readonly<Record<string, Detector>> = {
|
|
|
58
79
|
"unqualified-superlative": unqualifiedSuperlative,
|
|
59
80
|
"repeated-conjunction": repeatedConjunction,
|
|
60
81
|
"ai-tell": aiTell,
|
|
82
|
+
"contrast-framing": contrastFraming,
|
|
83
|
+
"stock-transition": openerDensity,
|
|
84
|
+
"opener-pile": openerPile,
|
|
85
|
+
"colon-lead-in": colonLeadIn,
|
|
86
|
+
"assistant-residue": assistantResidue,
|
|
87
|
+
"unfilled-placeholder": unfilledPlaceholder,
|
|
61
88
|
"contraction-mix": contractionMix,
|
|
62
89
|
"internal-jargon": internalJargon,
|
|
63
90
|
"required-sections": requiredSections,
|
|
@@ -65,10 +92,25 @@ export const DETECTORS: Readonly<Record<string, Detector>> = {
|
|
|
65
92
|
"preferred-term": preferredTerm,
|
|
66
93
|
"latin-spacing": latinSpacing,
|
|
67
94
|
"stray-space": straySpace,
|
|
95
|
+
"katakana-long-vowel": katakanaLongVowel,
|
|
96
|
+
"custom-words": customWords,
|
|
97
|
+
"custom-pattern": customPattern,
|
|
98
|
+
"custom-tokens": customTokens,
|
|
68
99
|
"dangling-reference": danglingReference,
|
|
69
100
|
"date-weekday-mismatch": dateWeekdayMismatch,
|
|
70
101
|
"date-order": dateOrder,
|
|
71
102
|
"total-mismatch": totalMismatch,
|
|
72
103
|
"numbering-gap": numberingGap,
|
|
73
104
|
"duplicate-definition": duplicateDefinition,
|
|
105
|
+
"announced-count": announcedCount,
|
|
106
|
+
"dangling-figure": danglingFigure,
|
|
107
|
+
"date-range-reversed": dateRangeReversed,
|
|
108
|
+
"percent-sum-mismatch": percentSumMismatch,
|
|
109
|
+
"heading-level-skip": headingLevelSkip,
|
|
110
|
+
"image-alt-text": imageAltText,
|
|
111
|
+
"broken-link": brokenLink,
|
|
112
|
+
"url-run-on": urlRunOn,
|
|
113
|
+
"unbalanced-bracket": unbalancedBracket,
|
|
114
|
+
"doubled-punctuation": doubledPunctuation,
|
|
115
|
+
"kutoten-consistency": kutotenConsistency,
|
|
74
116
|
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Detector, Finding, Sentence, Span } from "../plugin.ts";
|
|
2
|
+
import { minorityStyle } from "../orthography.ts";
|
|
3
|
+
import { isWithinAny, quotedSpans } from "../quoted-span.ts";
|
|
4
|
+
|
|
5
|
+
/** 日本語の読点と句点の、二つの書き方。「、。」と、横書きの論文や公用文に多い「,.」。どちらが正しいかは決めない。 */
|
|
6
|
+
type Kind = { readonly id: "comma" | "period"; readonly usual: string; readonly western: string };
|
|
7
|
+
|
|
8
|
+
const KINDS: readonly Kind[] = [
|
|
9
|
+
{ id: "comma", usual: "、", western: "," },
|
|
10
|
+
{ id: "period", usual: "。", western: "." },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const MARKS = /[、,。.]/gu;
|
|
14
|
+
|
|
15
|
+
const DIGIT = /[\d0-9]/u;
|
|
16
|
+
|
|
17
|
+
/** 番号の印(行の頭や読点・空白・括弧の後ろの「1.」「2.」)。文の中の数の後ろの点(締切は10.)は文の終わり。 */
|
|
18
|
+
const LIST_NUMBER = /(?:^|[\s、,,((])[\d0-9]{1,3}$/u;
|
|
19
|
+
const LIST_NUMBER_REACH = 4;
|
|
20
|
+
|
|
21
|
+
/** 一、二文字の英字だけの印(Q.、No.)。「API.」のような語の後ろの点は文の終わり。 */
|
|
22
|
+
const LATIN_LABEL = /(?:^|[^A-Za-zA-Za-z])[A-Za-zA-Za-z]{1,2}$/u;
|
|
23
|
+
const LATIN_LABEL_REACH = 3;
|
|
24
|
+
|
|
25
|
+
const isInsideNumber = (text: string, at: number): boolean => DIGIT.test(text.charAt(at - 1)) && DIGIT.test(text.charAt(at + 1));
|
|
26
|
+
|
|
27
|
+
const isLabelPeriod = (text: string, at: number): boolean =>
|
|
28
|
+
LIST_NUMBER.test(text.slice(Math.max(0, at - LIST_NUMBER_REACH), at)) || LATIN_LABEL.test(text.slice(Math.max(0, at - LATIN_LABEL_REACH), at));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 句読点として数えない「,」「.」。数の中の桁の区切りと小数点(1,000、3.5)、番号の印の点(1.はじめに、、2.確認)、
|
|
32
|
+
* 一、二文字の英字の印の後ろの点(Q.、No.)は、日本語の文の区切りではない。
|
|
33
|
+
*/
|
|
34
|
+
const isNotPunctuation = (text: string, at: number, mark: string): boolean => {
|
|
35
|
+
if (mark === ".") return isInsideNumber(text, at) || isLabelPeriod(text, at);
|
|
36
|
+
if (mark === ",") return isInsideNumber(text, at);
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type Mark = { readonly kind: Kind["id"]; readonly western: boolean; readonly mark: string; readonly offset: number };
|
|
41
|
+
|
|
42
|
+
/** 文の中の句読点。鉤括弧で引いたものの中は、引いた元の書き方なので数えない。offset は文書の中の位置。 */
|
|
43
|
+
export const marksIn = (sentence: Sentence): Mark[] => {
|
|
44
|
+
const quoted: readonly Span[] = quotedSpans(sentence.text);
|
|
45
|
+
return [...sentence.text.matchAll(MARKS)]
|
|
46
|
+
.filter((match) => !isNotPunctuation(sentence.text, match.index, match[0]))
|
|
47
|
+
.filter((match) => !isWithinAny(quoted, { start: match.index, end: match.index }))
|
|
48
|
+
.map((match) => {
|
|
49
|
+
const western = match[0] === "," || match[0] === ".";
|
|
50
|
+
const kind = match[0] === "、" || match[0] === "," ? "comma" : "period";
|
|
51
|
+
return { kind, western, mark: match[0], offset: sentence.span.start + match.index };
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 注や文献の番号と空白で始まる行(白書の「2 亀田健司,「…」,2018年」、「[1] 山田太郎,…」「注1 …」「※1 …」)。
|
|
57
|
+
* 白書や論文の注と文献は、本文と違う区切り方で書く決まりがある。
|
|
58
|
+
*/
|
|
59
|
+
const NOTE_NUMBER = /^(?:[\d0-9]{1,3}|[[[][\d0-9]{1,3}[\]]]|注[\d0-9]{1,3}|※[\d0-9]{0,3})[\u3000 ]/u;
|
|
60
|
+
|
|
61
|
+
const URL_SCHEME = /https?:\/\//u;
|
|
62
|
+
|
|
63
|
+
/** 文献や出典を挙げた文。注の番号で始まるか、URL を含む。区切りは引いた元や文献の書き方に従う。 */
|
|
64
|
+
export const isCitation = (sentence: Sentence, source: string): boolean =>
|
|
65
|
+
NOTE_NUMBER.test(sentence.text.trimStart()) || URL_SCHEME.test(source.slice(sentence.span.start, sentence.span.end));
|
|
66
|
+
|
|
67
|
+
type Tally = { readonly count: number; readonly of: number; readonly limit: number };
|
|
68
|
+
|
|
69
|
+
const findingOf = (sentence: Sentence, entry: Mark, kind: Kind, tally: Tally): Finding => ({
|
|
70
|
+
rule: "",
|
|
71
|
+
severity: "warning",
|
|
72
|
+
line: 0,
|
|
73
|
+
column: 0,
|
|
74
|
+
quote: sentence.text.trim(),
|
|
75
|
+
values: { mark: entry.mark, usual: entry.western ? kind.usual : kind.western, ...tally, offset: entry.offset },
|
|
76
|
+
variant: entry.kind,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 読点(、と,)と句点(。と.)を、それぞれ文書の中でどちらかにそろえているか。混ざっていれば少ないほうを指摘する。
|
|
81
|
+
* latin-spacing と同じく、同数なら文書が先に使った書き方をその文書の書き方とする。
|
|
82
|
+
*/
|
|
83
|
+
export const kutotenConsistency: Detector = (doc, options): Finding[] => {
|
|
84
|
+
const located = doc.sentences
|
|
85
|
+
.filter((sentence) => !isCitation(sentence, doc.source))
|
|
86
|
+
.flatMap((sentence) => marksIn(sentence).map((entry) => ({ sentence, entry })));
|
|
87
|
+
return KINDS.flatMap((kind) => {
|
|
88
|
+
const ofKind = located.filter(({ entry }) => entry.kind === kind.id);
|
|
89
|
+
const minority = minorityStyle(ofKind.map(({ entry }) => ({ spaced: entry.western })));
|
|
90
|
+
if (minority === undefined) return [];
|
|
91
|
+
const odd = ofKind.filter(({ entry }) => entry.western === minority);
|
|
92
|
+
if (odd.length < options.limit) return [];
|
|
93
|
+
const tally = { count: odd.length, of: ofKind.length, limit: options.limit };
|
|
94
|
+
return odd.map(({ sentence, entry }) => findingOf(sentence, entry, kind, tally));
|
|
95
|
+
});
|
|
96
|
+
};
|
package/src/detectors/lead-in.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/** 文末のコロン。後ろに強調の印(**・_)や空白が残っていても見る。 */
|
|
2
2
|
const ENDS_WITH_COLON = /[::][\s*_]*$/u;
|
|
3
3
|
|
|
4
|
+
export const endsWithColon = (sentence: string): boolean => ENDS_WITH_COLON.test(sentence.trim());
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* 後ろの箇条書きや表へ読者を渡す文(「次のとおりとする。」「The following expenses require receipts:」)。
|
|
6
8
|
* 見出しの語を繰り返していても、中身は後ろにある。言い回しは言語パッケージの語彙表 lead-in が持つ。
|
|
7
9
|
*/
|
|
8
10
|
export const isLeadIn = (sentence: string, phrases: readonly string[]): boolean => {
|
|
9
11
|
const text = sentence.trim().toLowerCase();
|
|
10
|
-
return
|
|
12
|
+
return endsWithColon(text) || phrases.some((phrase) => phrase !== "" && text.includes(phrase.toLowerCase()));
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
/** 渡す先(following: 同じ節の、その文より後ろ)が空なら、渡す文ではなくただの繰り返し。 */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LexiconEntry, Sentence, Token } from "../plugin.ts";
|
|
2
2
|
import { proseText } from "../measure.ts";
|
|
3
|
+
import { straightApostrophes } from "../orthography.ts";
|
|
3
4
|
|
|
4
5
|
/** 活用する品詞。"best" を "good" と同じ語にはしない。 */
|
|
5
6
|
const INFLECTING = new Set(["VERB", "AUX"]);
|
|
@@ -15,6 +16,12 @@ const sameWord = (written: Token, entry: Token): boolean => {
|
|
|
15
16
|
return inflects && entry.lemma?.toLowerCase() === surface && written.lemma?.toLowerCase() === surface;
|
|
16
17
|
};
|
|
17
18
|
|
|
19
|
+
/** 品詞が無いときに照らす形。大文字小文字と、アポストロフィの形(it’s と it's)は語を変えない。 */
|
|
20
|
+
export const comparableWords = (text: string): string => straightApostrophes(text).toLowerCase();
|
|
21
|
+
|
|
22
|
+
/** 文を、品詞が無いときに照らす形に。行の折り返しの空白はまとめる。 */
|
|
23
|
+
export const comparableText = (sentence: Sentence): string => comparableWords(proseText(sentence));
|
|
24
|
+
|
|
18
25
|
const runsAt = (tokens: readonly Token[], entry: readonly Token[], start: number): boolean =>
|
|
19
26
|
entry.every((word, offset) => {
|
|
20
27
|
const written = tokens[start + offset];
|
|
@@ -28,7 +35,7 @@ const runsAt = (tokens: readonly Token[], entry: readonly Token[], start: number
|
|
|
28
35
|
export const entryIn = (sentence: Sentence, entry: LexiconEntry): boolean => {
|
|
29
36
|
const tokens = sentence.tokens;
|
|
30
37
|
const words = entry.tokens;
|
|
31
|
-
if (tokens === undefined || words === undefined || words.length === 0) return
|
|
38
|
+
if (tokens === undefined || words === undefined || words.length === 0) return comparableText(sentence).includes(comparableWords(entry.pattern));
|
|
32
39
|
return tokens.some((_token, start) => runsAt(tokens, words, start));
|
|
33
40
|
};
|
|
34
41
|
|
|
@@ -48,7 +55,7 @@ const LEADING_MARK = new Set(["PUNCT", "SYM"]);
|
|
|
48
55
|
export const entryOpens = (sentence: Sentence, entry: LexiconEntry): boolean => {
|
|
49
56
|
const tokens = sentence.tokens;
|
|
50
57
|
const words = entry.tokens;
|
|
51
|
-
if (tokens === undefined || words === undefined || words.length === 0) return
|
|
58
|
+
if (tokens === undefined || words === undefined || words.length === 0) return comparableText(sentence).startsWith(comparableWords(entry.pattern));
|
|
52
59
|
const first = tokens.findIndex((token) => !LEADING_MARK.has(token.pos));
|
|
53
60
|
return runsAt(tokens, words, first);
|
|
54
61
|
};
|