chaffjs 0.48.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/README.ja.md +1 -0
  2. package/README.md +1 -0
  3. package/dist/announced-count.d.ts.map +1 -1
  4. package/dist/announced-count.js +18 -1
  5. package/dist/announced-count.js.map +1 -1
  6. package/dist/announced-list.d.ts.map +1 -1
  7. package/dist/announced-list.js +6 -1
  8. package/dist/announced-list.js.map +1 -1
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +4 -2
  11. package/dist/cli.js.map +1 -1
  12. package/dist/composite-signals.d.ts +3 -1
  13. package/dist/composite-signals.d.ts.map +1 -1
  14. package/dist/composite-signals.js +7 -0
  15. package/dist/composite-signals.js.map +1 -1
  16. package/dist/detectors/acronym-name.d.ts +2 -2
  17. package/dist/detectors/acronym-name.d.ts.map +1 -1
  18. package/dist/detectors/acronym-name.js +3 -3
  19. package/dist/detectors/acronym-name.js.map +1 -1
  20. package/dist/detectors/agentless-passive.d.ts.map +1 -1
  21. package/dist/detectors/agentless-passive.js +39 -4
  22. package/dist/detectors/agentless-passive.js.map +1 -1
  23. package/dist/detectors/agreement-slip.d.ts +2 -0
  24. package/dist/detectors/agreement-slip.d.ts.map +1 -1
  25. package/dist/detectors/agreement-slip.js +10 -3
  26. package/dist/detectors/agreement-slip.js.map +1 -1
  27. package/dist/detectors/amount-scale.js +2 -2
  28. package/dist/detectors/amount-scale.js.map +1 -1
  29. package/dist/detectors/char-shape.d.ts.map +1 -1
  30. package/dist/detectors/char-shape.js +11 -4
  31. package/dist/detectors/char-shape.js.map +1 -1
  32. package/dist/detectors/chat-citation.d.ts +2 -6
  33. package/dist/detectors/chat-citation.d.ts.map +1 -1
  34. package/dist/detectors/chat-citation.js +4 -2
  35. package/dist/detectors/chat-citation.js.map +1 -1
  36. package/dist/detectors/chat-mark-extent.d.ts +11 -0
  37. package/dist/detectors/chat-mark-extent.d.ts.map +1 -0
  38. package/dist/detectors/chat-mark-extent.js +53 -0
  39. package/dist/detectors/chat-mark-extent.js.map +1 -0
  40. package/dist/detectors/concrete-evidence-density.js +2 -2
  41. package/dist/detectors/concrete-evidence.d.ts +7 -0
  42. package/dist/detectors/concrete-evidence.d.ts.map +1 -1
  43. package/dist/detectors/concrete-evidence.js +20 -0
  44. package/dist/detectors/concrete-evidence.js.map +1 -1
  45. package/dist/detectors/conjugated-entry.d.ts +2 -2
  46. package/dist/detectors/conjugated-entry.d.ts.map +1 -1
  47. package/dist/detectors/conjugated-entry.js +3 -5
  48. package/dist/detectors/conjugated-entry.js.map +1 -1
  49. package/dist/detectors/contrast-frame.d.ts.map +1 -1
  50. package/dist/detectors/contrast-frame.js +34 -1
  51. package/dist/detectors/contrast-frame.js.map +1 -1
  52. package/dist/detectors/currency-notation.js +2 -2
  53. package/dist/detectors/currency-notation.js.map +1 -1
  54. package/dist/detectors/defined-term-form.d.ts.map +1 -1
  55. package/dist/detectors/defined-term-form.js +15 -3
  56. package/dist/detectors/defined-term-form.js.map +1 -1
  57. package/dist/detectors/definition-use.d.ts.map +1 -1
  58. package/dist/detectors/definition-use.js +5 -1
  59. package/dist/detectors/definition-use.js.map +1 -1
  60. package/dist/detectors/ellipsis.js +2 -2
  61. package/dist/detectors/ellipsis.js.map +1 -1
  62. package/dist/detectors/email-letter.d.ts +2 -0
  63. package/dist/detectors/email-letter.d.ts.map +1 -1
  64. package/dist/detectors/email-letter.js +1 -1
  65. package/dist/detectors/email-letter.js.map +1 -1
  66. package/dist/detectors/en-shape.d.ts +1 -0
  67. package/dist/detectors/en-shape.d.ts.map +1 -1
  68. package/dist/detectors/en-shape.js +41 -9
  69. package/dist/detectors/en-shape.js.map +1 -1
  70. package/dist/detectors/gram-furniture.d.ts +1 -0
  71. package/dist/detectors/gram-furniture.d.ts.map +1 -1
  72. package/dist/detectors/gram-furniture.js +6 -0
  73. package/dist/detectors/gram-furniture.js.map +1 -1
  74. package/dist/detectors/gram-repetition.d.ts.map +1 -1
  75. package/dist/detectors/gram-repetition.js +8 -2
  76. package/dist/detectors/gram-repetition.js.map +1 -1
  77. package/dist/detectors/heading-case.d.ts +1 -0
  78. package/dist/detectors/heading-case.d.ts.map +1 -1
  79. package/dist/detectors/heading-case.js +10 -3
  80. package/dist/detectors/heading-case.js.map +1 -1
  81. package/dist/detectors/kanji-name-edge.d.ts +10 -0
  82. package/dist/detectors/kanji-name-edge.d.ts.map +1 -1
  83. package/dist/detectors/kanji-name-edge.js +23 -0
  84. package/dist/detectors/kanji-name-edge.js.map +1 -1
  85. package/dist/detectors/kutoten-consistency.d.ts.map +1 -1
  86. package/dist/detectors/kutoten-consistency.js +27 -6
  87. package/dist/detectors/kutoten-consistency.js.map +1 -1
  88. package/dist/detectors/lexicon-match.d.ts +2 -0
  89. package/dist/detectors/lexicon-match.d.ts.map +1 -1
  90. package/dist/detectors/lexicon-match.js +14 -3
  91. package/dist/detectors/lexicon-match.js.map +1 -1
  92. package/dist/detectors/lexicon.d.ts.map +1 -1
  93. package/dist/detectors/lexicon.js +8 -1
  94. package/dist/detectors/lexicon.js.map +1 -1
  95. package/dist/detectors/list-item-clause.d.ts +4 -0
  96. package/dist/detectors/list-item-clause.d.ts.map +1 -0
  97. package/dist/detectors/list-item-clause.js +8 -0
  98. package/dist/detectors/list-item-clause.js.map +1 -0
  99. package/dist/detectors/list-parallel.d.ts.map +1 -1
  100. package/dist/detectors/list-parallel.js +6 -2
  101. package/dist/detectors/list-parallel.js.map +1 -1
  102. package/dist/detectors/list-sentence.d.ts +2 -0
  103. package/dist/detectors/list-sentence.d.ts.map +1 -1
  104. package/dist/detectors/list-sentence.js.map +1 -1
  105. package/dist/detectors/mark-shape.d.ts.map +1 -1
  106. package/dist/detectors/mark-shape.js +28 -8
  107. package/dist/detectors/mark-shape.js.map +1 -1
  108. package/dist/detectors/missing-final-period.d.ts.map +1 -1
  109. package/dist/detectors/missing-final-period.js +10 -1
  110. package/dist/detectors/missing-final-period.js.map +1 -1
  111. package/dist/detectors/name-variant-two-things.d.ts +1 -1
  112. package/dist/detectors/name-variant-two-things.d.ts.map +1 -1
  113. package/dist/detectors/name-variant-two-things.js +16 -4
  114. package/dist/detectors/name-variant-two-things.js.map +1 -1
  115. package/dist/detectors/nominalization.d.ts.map +1 -1
  116. package/dist/detectors/nominalization.js +11 -4
  117. package/dist/detectors/nominalization.js.map +1 -1
  118. package/dist/detectors/ordinal-suffix.js +2 -2
  119. package/dist/detectors/ordinal-suffix.js.map +1 -1
  120. package/dist/detectors/orthographic-variant.d.ts.map +1 -1
  121. package/dist/detectors/orthographic-variant.js +30 -6
  122. package/dist/detectors/orthographic-variant.js.map +1 -1
  123. package/dist/detectors/orthography.d.ts.map +1 -1
  124. package/dist/detectors/orthography.js +13 -7
  125. package/dist/detectors/orthography.js.map +1 -1
  126. package/dist/detectors/oxford-comma.d.ts.map +1 -1
  127. package/dist/detectors/oxford-comma.js +15 -1
  128. package/dist/detectors/oxford-comma.js.map +1 -1
  129. package/dist/detectors/paragraph-run.js +2 -2
  130. package/dist/detectors/paragraph-run.js.map +1 -1
  131. package/dist/detectors/phone-number-variant.d.ts.map +1 -1
  132. package/dist/detectors/phone-number-variant.js +2 -1
  133. package/dist/detectors/phone-number-variant.js.map +1 -1
  134. package/dist/detectors/phrase-context.d.ts +6 -0
  135. package/dist/detectors/phrase-context.d.ts.map +1 -0
  136. package/dist/detectors/phrase-context.js +12 -0
  137. package/dist/detectors/phrase-context.js.map +1 -0
  138. package/dist/detectors/phrase-match-all.d.ts +3 -0
  139. package/dist/detectors/phrase-match-all.d.ts.map +1 -0
  140. package/dist/detectors/phrase-match-all.js +47 -0
  141. package/dist/detectors/phrase-match-all.js.map +1 -0
  142. package/dist/detectors/phrase-match.d.ts +2 -1
  143. package/dist/detectors/phrase-match.d.ts.map +1 -1
  144. package/dist/detectors/phrase-match.js +25 -6
  145. package/dist/detectors/phrase-match.js.map +1 -1
  146. package/dist/detectors/placeholder-text.d.ts.map +1 -1
  147. package/dist/detectors/placeholder-text.js +14 -2
  148. package/dist/detectors/placeholder-text.js.map +1 -1
  149. package/dist/detectors/proper-noun-density.d.ts.map +1 -1
  150. package/dist/detectors/proper-noun-density.js +10 -6
  151. package/dist/detectors/proper-noun-density.js.map +1 -1
  152. package/dist/detectors/quote-around.d.ts +3 -0
  153. package/dist/detectors/quote-around.d.ts.map +1 -1
  154. package/dist/detectors/quote-around.js +2 -0
  155. package/dist/detectors/quote-around.js.map +1 -1
  156. package/dist/detectors/range-notation.js +2 -2
  157. package/dist/detectors/range-notation.js.map +1 -1
  158. package/dist/detectors/reference-entry.d.ts.map +1 -1
  159. package/dist/detectors/reference-entry.js +35 -5
  160. package/dist/detectors/reference-entry.js.map +1 -1
  161. package/dist/detectors/register-set-apart.d.ts +1 -1
  162. package/dist/detectors/register-set-apart.js +4 -4
  163. package/dist/detectors/register-set-apart.js.map +1 -1
  164. package/dist/detectors/register-voice.d.ts +5 -0
  165. package/dist/detectors/register-voice.d.ts.map +1 -1
  166. package/dist/detectors/register-voice.js +17 -0
  167. package/dist/detectors/register-voice.js.map +1 -1
  168. package/dist/detectors/registry/phrase-match-all.d.ts +3 -0
  169. package/dist/detectors/registry/phrase-match-all.d.ts.map +1 -0
  170. package/dist/detectors/registry/phrase-match-all.js +3 -0
  171. package/dist/detectors/registry/phrase-match-all.js.map +1 -0
  172. package/dist/detectors/requirement-lists.d.ts.map +1 -1
  173. package/dist/detectors/requirement-lists.js +2 -0
  174. package/dist/detectors/requirement-lists.js.map +1 -1
  175. package/dist/detectors/sentence-counts.d.ts.map +1 -1
  176. package/dist/detectors/sentence-counts.js +7 -4
  177. package/dist/detectors/sentence-counts.js.map +1 -1
  178. package/dist/detectors/sentence-ending.d.ts +2 -2
  179. package/dist/detectors/sentence-ending.d.ts.map +1 -1
  180. package/dist/detectors/sentence-ending.js +3 -1
  181. package/dist/detectors/sentence-ending.js.map +1 -1
  182. package/dist/detectors/sentence-length.d.ts.map +1 -1
  183. package/dist/detectors/sentence-length.js +12 -4
  184. package/dist/detectors/sentence-length.js.map +1 -1
  185. package/dist/detectors/sentence-parts.d.ts +6 -3
  186. package/dist/detectors/sentence-parts.d.ts.map +1 -1
  187. package/dist/detectors/sentence-parts.js +15 -7
  188. package/dist/detectors/sentence-parts.js.map +1 -1
  189. package/dist/detectors/signals.d.ts.map +1 -1
  190. package/dist/detectors/signals.js +6 -1
  191. package/dist/detectors/signals.js.map +1 -1
  192. package/dist/detectors/speaker-turns.d.ts +4 -0
  193. package/dist/detectors/speaker-turns.d.ts.map +1 -0
  194. package/dist/detectors/speaker-turns.js +28 -0
  195. package/dist/detectors/speaker-turns.js.map +1 -0
  196. package/dist/detectors/team.d.ts.map +1 -1
  197. package/dist/detectors/team.js +42 -9
  198. package/dist/detectors/team.js.map +1 -1
  199. package/dist/detectors/unit-spacing.js +2 -2
  200. package/dist/detectors/unit-spacing.js.map +1 -1
  201. package/dist/detectors/vague-deadline.d.ts.map +1 -1
  202. package/dist/detectors/vague-deadline.js +2 -1
  203. package/dist/detectors/vague-deadline.js.map +1 -1
  204. package/dist/levels.d.ts +14 -0
  205. package/dist/levels.d.ts.map +1 -1
  206. package/dist/levels.js +8 -3
  207. package/dist/levels.js.map +1 -1
  208. package/dist/name-variant-shapes.d.ts +10 -0
  209. package/dist/name-variant-shapes.d.ts.map +1 -1
  210. package/dist/name-variant-shapes.js +24 -0
  211. package/dist/name-variant-shapes.js.map +1 -1
  212. package/dist/phone-numbers.d.ts +5 -2
  213. package/dist/phone-numbers.d.ts.map +1 -1
  214. package/dist/phone-numbers.js +17 -3
  215. package/dist/phone-numbers.js.map +1 -1
  216. package/dist/plugin.d.ts +2 -0
  217. package/dist/plugin.d.ts.map +1 -1
  218. package/dist/render/explain.d.ts +2 -0
  219. package/dist/render/explain.d.ts.map +1 -1
  220. package/dist/render/explain.js +38 -14
  221. package/dist/render/explain.js.map +1 -1
  222. package/dist/render/options.d.ts.map +1 -1
  223. package/dist/render/options.js +11 -6
  224. package/dist/render/options.js.map +1 -1
  225. package/dist/render/text.d.ts.map +1 -1
  226. package/dist/render/text.js +14 -4
  227. package/dist/render/text.js.map +1 -1
  228. package/dist/run.d.ts +3 -0
  229. package/dist/run.d.ts.map +1 -1
  230. package/dist/run.js +20 -13
  231. package/dist/run.js.map +1 -1
  232. package/dist/set-phrase-particles.js +2 -2
  233. package/dist/set-phrase-particles.js.map +1 -1
  234. package/dist/structure/deadline-after-event.d.ts +1 -1
  235. package/dist/structure/deadline-after-event.d.ts.map +1 -1
  236. package/dist/structure/deadline-after-event.js +36 -9
  237. package/dist/structure/deadline-after-event.js.map +1 -1
  238. package/dist/structure/definition-use.d.ts +10 -1
  239. package/dist/structure/definition-use.d.ts.map +1 -1
  240. package/dist/structure/definition-use.js +4 -4
  241. package/dist/structure/definition-use.js.map +1 -1
  242. package/dist/structure/leg-times.d.ts.map +1 -1
  243. package/dist/structure/leg-times.js +10 -2
  244. package/dist/structure/leg-times.js.map +1 -1
  245. package/dist/structure/requirement-lists.d.ts +3 -0
  246. package/dist/structure/requirement-lists.d.ts.map +1 -1
  247. package/dist/structure/requirement-lists.js +8 -2
  248. package/dist/structure/requirement-lists.js.map +1 -1
  249. package/dist/structure/time-marks.d.ts +10 -0
  250. package/dist/structure/time-marks.d.ts.map +1 -1
  251. package/dist/structure/time-marks.js +21 -0
  252. package/dist/structure/time-marks.js.map +1 -1
  253. package/dist/topic-clause.d.ts.map +1 -1
  254. package/dist/topic-clause.js +12 -5
  255. package/dist/topic-clause.js.map +1 -1
  256. package/package.json +3 -3
  257. package/rules/abstract-length.yaml +1 -1
  258. package/rules/adverb-overuse.yaml +1 -1
  259. package/rules/agentless-passive.yaml +3 -3
  260. package/rules/agreement-slip.yaml +5 -4
  261. package/rules/ai-generated-composite.yaml +3 -3
  262. package/rules/ai-structure.yaml +1 -1
  263. package/rules/all-caps-shouting.yaml +1 -1
  264. package/rules/announced-count-mismatch.yaml +2 -2
  265. package/rules/announcing-opener.yaml +1 -1
  266. package/rules/arrival-before-departure.yaml +1 -1
  267. package/rules/article-sound.yaml +1 -1
  268. package/rules/baito-keigo.yaml +1 -1
  269. package/rules/bold-density.yaml +1 -1
  270. package/rules/bold-emphasis.yaml +1 -1
  271. package/rules/bold-label-list.yaml +1 -1
  272. package/rules/bracket-width-consistency.yaml +1 -1
  273. package/rules/chat-citation-residue.yaml +1 -1
  274. package/rules/citation-style-mix.yaml +1 -1
  275. package/rules/clause-chain.yaml +1 -1
  276. package/rules/cliche.yaml +4 -4
  277. package/rules/closing-cliche.yaml +1 -1
  278. package/rules/closing-exhortation.yaml +1 -1
  279. package/rules/cold-open.yaml +1 -1
  280. package/rules/colloquial-opener.yaml +1 -1
  281. package/rules/concrete-evidence-density.yaml +3 -3
  282. package/rules/contraction-consistency.yaml +1 -1
  283. package/rules/cross-doc-term-variant.yaml +2 -2
  284. package/rules/cushion-phrase-density.yaml +1 -1
  285. package/rules/deadline-after-event.yaml +2 -2
  286. package/rules/demonstrative-opener-run.yaml +1 -1
  287. package/rules/double-keigo.yaml +1 -1
  288. package/rules/double-negative.yaml +11 -2
  289. package/rules/doubled-nado.yaml +1 -1
  290. package/rules/email-stock-courtesy.yaml +1 -1
  291. package/rules/email-subject-length.yaml +1 -1
  292. package/rules/emoji-heading.yaml +1 -1
  293. package/rules/empty-intensifier.yaml +1 -1
  294. package/rules/excessive-hedging.yaml +1 -1
  295. package/rules/exclamation-width-consistency.yaml +1 -1
  296. package/rules/expletive-construction.yaml +5 -5
  297. package/rules/figurative-density.yaml +3 -3
  298. package/rules/hiragana-fukushi.yaml +1 -1
  299. package/rules/homophone-slip.yaml +3 -3
  300. package/rules/honesty-marker.yaml +1 -1
  301. package/rules/humble-for-others.yaml +1 -1
  302. package/rules/hyphen-as-dash.yaml +1 -1
  303. package/rules/idiom-misuse.yaml +1 -1
  304. package/rules/internal-jargon.yaml +1 -1
  305. package/rules/kana-function-word.yaml +1 -1
  306. package/rules/katakana-long-vowel.yaml +1 -1
  307. package/rules/kutoten-consistency.yaml +7 -3
  308. package/rules/latin-abbreviation-form.yaml +1 -1
  309. package/rules/latin-spacing.yaml +1 -1
  310. package/rules/max-kanji-continuous.yaml +5 -3
  311. package/rules/max-paragraph-length.yaml +1 -1
  312. package/rules/max-sentence-length.yaml +1 -1
  313. package/rules/max-ten.yaml +1 -1
  314. package/rules/misconversion.yaml +2 -2
  315. package/rules/name-variant.yaml +2 -2
  316. package/rules/ngram-repetition.yaml +3 -3
  317. package/rules/no-doubled-joshi.yaml +2 -2
  318. package/rules/no-em-dash.yaml +3 -3
  319. package/rules/no-mixed-desumasu.yaml +4 -3
  320. package/rules/no-nakaguro-parallel.yaml +1 -1
  321. package/rules/nominalization.yaml +1 -1
  322. package/rules/nonstandard-word.yaml +2 -2
  323. package/rules/numbered-generic-heading.yaml +1 -1
  324. package/rules/numbering-gap.yaml +2 -2
  325. package/rules/one-sentence-paragraph-run.yaml +1 -1
  326. package/rules/orthographic-variant.yaml +2 -2
  327. package/rules/over-general-claim.yaml +1 -1
  328. package/rules/oxford-comma-consistency.yaml +4 -3
  329. package/rules/padded-intro.yaml +1 -1
  330. package/rules/phone-number-variant.yaml +1 -1
  331. package/rules/preamble-length.yaml +1 -1
  332. package/rules/preferred-term.yaml +1 -1
  333. package/rules/proper-noun-density.yaml +1 -1
  334. package/rules/q-fragment-answer.yaml +1 -1
  335. package/rules/quote-style-consistency.yaml +1 -1
  336. package/rules/quote-without-source.yaml +1 -1
  337. package/rules/redundant-expression.yaml +1 -1
  338. package/rules/repeated-conjunction.yaml +1 -1
  339. package/rules/repeated-sentence-ending.yaml +1 -1
  340. package/rules/repeated-sentence-head.yaml +5 -5
  341. package/rules/required-listed-as-preferred.yaml +2 -2
  342. package/rules/required-sections.yaml +1 -1
  343. package/rules/sasete-itadaku.yaml +1 -1
  344. package/rules/sentence-initial-conjunction-run.yaml +1 -1
  345. package/rules/sentence-initial-so.yaml +1 -1
  346. package/rules/sentence-spacing-consistency.yaml +1 -1
  347. package/rules/shell-prompt-mix.yaml +1 -1
  348. package/rules/stock-transition.yaml +1 -1
  349. package/rules/stray-space.yaml +1 -1
  350. package/rules/taigen-dome-in-prose.yaml +1 -1
  351. package/rules/teki-overuse.yaml +1 -1
  352. package/rules/title-case-consistency.yaml +1 -1
  353. package/rules/title-length.yaml +1 -1
  354. package/rules/topic-predicate-distance.yaml +3 -3
  355. package/rules/translationese-density.yaml +1 -1
  356. package/rules/uncomparable-graded.yaml +1 -1
  357. package/rules/undefined-acronym.yaml +3 -3
  358. package/rules/unfilled-placeholder.yaml +4 -4
  359. package/rules/unqualified-superlative.yaml +1 -1
  360. package/rules/use-before-definition.yaml +2 -2
  361. package/rules/vague-word-density.yaml +3 -3
  362. package/rules/weasel-word.yaml +1 -1
  363. package/rules/which-that-consistency.yaml +1 -1
  364. package/rules/wordy-phrase.yaml +1 -1
  365. package/skills/chaff/SKILL.md +3 -1
  366. package/src/announced-count.ts +22 -1
  367. package/src/announced-list.ts +7 -1
  368. package/src/cli.ts +4 -2
  369. package/src/composite-signals.ts +10 -1
  370. package/src/detectors/acronym-name.ts +6 -3
  371. package/src/detectors/agentless-passive.ts +49 -5
  372. package/src/detectors/agreement-slip.ts +11 -3
  373. package/src/detectors/amount-scale.ts +2 -2
  374. package/src/detectors/char-shape.ts +18 -3
  375. package/src/detectors/chat-citation.ts +4 -5
  376. package/src/detectors/chat-mark-extent.ts +63 -0
  377. package/src/detectors/concrete-evidence-density.ts +2 -2
  378. package/src/detectors/concrete-evidence.ts +27 -0
  379. package/src/detectors/conjugated-entry.ts +3 -5
  380. package/src/detectors/contrast-frame.ts +37 -2
  381. package/src/detectors/currency-notation.ts +2 -2
  382. package/src/detectors/defined-term-form.ts +15 -4
  383. package/src/detectors/definition-use.ts +5 -8
  384. package/src/detectors/ellipsis.ts +2 -2
  385. package/src/detectors/email-letter.ts +1 -1
  386. package/src/detectors/en-shape.ts +50 -9
  387. package/src/detectors/gram-furniture.ts +8 -0
  388. package/src/detectors/gram-repetition.ts +8 -1
  389. package/src/detectors/heading-case.ts +11 -3
  390. package/src/detectors/kanji-name-edge.ts +27 -0
  391. package/src/detectors/kutoten-consistency.ts +37 -6
  392. package/src/detectors/lexicon-match.ts +17 -3
  393. package/src/detectors/lexicon.ts +10 -4
  394. package/src/detectors/list-item-clause.ts +9 -0
  395. package/src/detectors/list-parallel.ts +5 -2
  396. package/src/detectors/list-sentence.ts +2 -0
  397. package/src/detectors/mark-shape.ts +36 -8
  398. package/src/detectors/missing-final-period.ts +11 -1
  399. package/src/detectors/name-variant-two-things.ts +28 -3
  400. package/src/detectors/nominalization.ts +14 -4
  401. package/src/detectors/ordinal-suffix.ts +2 -2
  402. package/src/detectors/orthographic-variant.ts +44 -8
  403. package/src/detectors/orthography.ts +19 -9
  404. package/src/detectors/oxford-comma.ts +15 -1
  405. package/src/detectors/paragraph-run.ts +2 -2
  406. package/src/detectors/phone-number-variant.ts +2 -1
  407. package/src/detectors/phrase-context.ts +19 -0
  408. package/src/detectors/phrase-match-all.ts +57 -0
  409. package/src/detectors/phrase-match.ts +31 -6
  410. package/src/detectors/placeholder-text.ts +19 -3
  411. package/src/detectors/proper-noun-density.ts +14 -6
  412. package/src/detectors/quote-around.ts +6 -0
  413. package/src/detectors/range-notation.ts +2 -2
  414. package/src/detectors/reference-entry.ts +36 -6
  415. package/src/detectors/register-set-apart.ts +4 -4
  416. package/src/detectors/register-voice.ts +19 -0
  417. package/src/detectors/registry/phrase-match-all.ts +4 -0
  418. package/src/detectors/requirement-lists.ts +2 -0
  419. package/src/detectors/sentence-counts.ts +9 -5
  420. package/src/detectors/sentence-ending.ts +8 -4
  421. package/src/detectors/sentence-length.ts +18 -6
  422. package/src/detectors/sentence-parts.ts +21 -9
  423. package/src/detectors/signals.ts +10 -1
  424. package/src/detectors/speaker-turns.ts +37 -0
  425. package/src/detectors/team.ts +50 -12
  426. package/src/detectors/unit-spacing.ts +2 -2
  427. package/src/detectors/vague-deadline.ts +2 -1
  428. package/src/levels.ts +9 -3
  429. package/src/name-variant-shapes.ts +29 -0
  430. package/src/phone-numbers.ts +19 -3
  431. package/src/plugin.ts +2 -0
  432. package/src/render/explain.ts +46 -16
  433. package/src/render/options.ts +12 -6
  434. package/src/render/text.ts +20 -7
  435. package/src/run.ts +32 -8
  436. package/src/set-phrase-particles.ts +2 -2
  437. package/src/structure/deadline-after-event.ts +49 -10
  438. package/src/structure/definition-use.ts +15 -5
  439. package/src/structure/leg-times.ts +16 -1
  440. package/src/structure/requirement-lists.ts +14 -2
  441. package/src/structure/time-marks.ts +25 -0
  442. package/src/topic-clause.ts +17 -5
  443. package/dist/honorific-group.d.ts +0 -8
  444. package/dist/honorific-group.d.ts.map +0 -1
  445. package/dist/honorific-group.js +0 -15
  446. package/dist/honorific-group.js.map +0 -1
@@ -322,12 +322,21 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
322
322
  return alone.map(([acronym, hit]) => acronymFinding(acronym, hit, alone.length, options.limit));
323
323
  };
324
324
 
325
+ /** 二つ重ねて一本に組むダッシュ(——、――)。重ねた二つ目からは、同じ一本の続き。 */
326
+ const DOUBLED_DASH = /[—―]/u;
327
+ const continuesDash = (source: string, offset: number): boolean => DOUBLED_DASH.test(source[offset] ?? "") && DOUBLED_DASH.test(source[offset - 1] ?? "");
328
+
329
+ /** 重ねたダッシュの最後の字の位置。段落の終わりで箇条を導くかは、そこから後ろで見る。 */
330
+ const dashEnd = (source: string, offset: number): number => (continuesDash(source, offset + 1) ? dashEnd(source, offset + 1) : offset);
331
+
325
332
  /**
326
333
  * ダッシュの多用。英語では正当な用法が多いが、2026 年時点で最も知られた生成文のシグナルでもある。
327
334
  * 日本語の組版ではそもそも扱いが難しい。どちらが正しいかは severity の言語別指定で分ける。spec §12.4。
328
335
  */
329
336
  export const dashDensity: Detector = (doc, options): Finding[] => {
330
- const hits = findIn(doc, DASH).filter((hit) => !introducesList(doc.source, hit.offset) && !opensLine(doc.source, hit.offset));
337
+ const hits = findIn(doc, DASH).filter(
338
+ (hit) => !continuesDash(doc.source, hit.offset) && !introducesList(doc.source, dashEnd(doc.source, hit.offset)) && !opensLine(doc.source, hit.offset),
339
+ );
331
340
  const first = hits[0];
332
341
  const rate = density(doc, hits.length);
333
342
  if (wordsOf(doc) < MIN_DOCUMENT_LENGTH[doc.lengthUnit] || first === undefined || rate <= options.limit) return [];
@@ -0,0 +1,37 @@
1
+ // The paragraphs of near-verbatim minutes that open with a speaker's name ("Mara: There's some history ..."). What
2
+ // follows the name is that person's own phrasing as the note-taker recorded it, not the writer's. Pure.
3
+ import type { Span } from "../plugin.ts";
4
+
5
+ /** How many names must each open MIN_TURNS paragraphs: one or two repeated labels are fields (Status:, Comments:). */
6
+ const MIN_SPEAKERS = 3;
7
+ const MIN_TURNS = 3;
8
+ /** The share of the paragraphs the names must open, so a few labelled lines in a report do not make it minutes. */
9
+ const MIN_TURN_SHARE = 0.2;
10
+
11
+ /** A name of up to three words, written at the very start of the paragraph, a colon, then the words said. */
12
+ const TURN = /^(?<name>\p{L}[\p{L}'’.-]*(?: \p{Lu}[\p{L}'’.-]*){0,2}): +\S/u;
13
+ const BLANK_LINES = /\n[ \t\r]*(?:\n[ \t\r]*)+/gu;
14
+
15
+ type Paragraph = { readonly span: Span; readonly name: string | undefined };
16
+
17
+ const paragraphsOf = (source: string): Paragraph[] => {
18
+ const breaks = [...source.matchAll(BLANK_LINES)];
19
+ const starts = [0, ...breaks.map((found) => found.index + found[0].length)];
20
+ const ends = [...breaks.map((found) => found.index), source.length];
21
+ return starts
22
+ .map((start, index) => ({ start, end: ends[index] ?? source.length }))
23
+ .filter(({ start, end }) => source.slice(start, end).trim() !== "")
24
+ .map((span) => ({ span, name: TURN.exec(source.slice(span.start, span.end))?.groups?.["name"] }));
25
+ };
26
+
27
+ const turnCounts = (paragraphs: readonly Paragraph[]): Map<string, number> =>
28
+ paragraphs.reduce((counts, { name }) => (name === undefined ? counts : counts.set(name, (counts.get(name) ?? 0) + 1)), new Map<string, number>());
29
+
30
+ /** The spans of the paragraphs a speaker's name opens, when the document reads as minutes of who said what; else none. */
31
+ export const speakerTurns = (source: string): Span[] => {
32
+ const paragraphs = paragraphsOf(source);
33
+ const turns = paragraphs.filter((paragraph) => paragraph.name !== undefined);
34
+ const speakers = [...turnCounts(turns).values()].filter((count) => count >= MIN_TURNS).length;
35
+ if (speakers < MIN_SPEAKERS || turns.length < paragraphs.length * MIN_TURN_SHARE) return [];
36
+ return turns.map((turn) => turn.span);
37
+ };
@@ -1,6 +1,6 @@
1
1
  import { joinWords } from "./word-list.ts";
2
2
  import { conjugatedSpans } from "./conjugated-entry.ts";
3
- import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence } from "../plugin.ts";
3
+ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span } from "../plugin.ts";
4
4
 
5
5
  /**
6
6
  * チームの言葉。社内でしか通じない語を、チームが chaff.yaml に自分で並べる。
@@ -13,23 +13,56 @@ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence } from ".
13
13
  * 複合動詞(「巻き取る」)は語に割れるので、語の並びで原形に照らす(「巻き取ります」)。
14
14
  * 品詞解析があれば原形で当たり、無くても表層で当たる。要求はしない。
15
15
  */
16
- const matches = (sentence: Sentence, entry: LexiconEntry): boolean => {
16
+ const textSpans = (sentence: Sentence, wanted: string): Span[] => {
17
+ const at = sentence.text.toLowerCase().indexOf(wanted);
18
+ return at < 0 ? [] : [{ start: at, end: at + wanted.length }];
19
+ };
20
+
21
+ const lemmaSpans = (sentence: Sentence, wanted: string): Span[] =>
22
+ (sentence.tokens ?? [])
23
+ .filter((token) => token.lemma?.toLowerCase() === wanted)
24
+ .map((token) => ({ start: token.span.start - sentence.span.start, end: token.span.end - sentence.span.start }));
25
+
26
+ /** 活用した形の後ろに詰めて付く語(握っ|た・巻き取り|ます)。指摘には本文に書いた形を引く。 */
27
+ const ENDING_POS = new Set(["AUX", "SCONJ"]);
28
+
29
+ /**
30
+ * 当たった範囲を、本文に書いた形まで伸ばす。語の途中で終われば語の終わりまで(巻き取 → 巻き取り)、
31
+ * 詰めて付いた助動詞まで(握っ → 握った)。語の間に空白がある英語は、後ろの語まで伸ばさない。
32
+ */
33
+ const writtenSpan = (sentence: Sentence, span: Span): Span => {
34
+ const end = sentence.span.start + span.end;
35
+ const tokens = sentence.tokens ?? [];
36
+ const inside = tokens.find((token) => token.span.start < end && end < token.span.end);
37
+ const next = tokens.find((token) => token.span.start === end && ENDING_POS.has(token.pos));
38
+ const reach = inside ?? next;
39
+ return reach === undefined ? span : writtenSpan(sentence, { start: span.start, end: reach.span.end - sentence.span.start });
40
+ };
41
+
42
+ /** 並べた語が文のどこに出たか(文の中の字の範囲)。表層、原形、複合動詞の活用した形の順に、最初の 1 か所。 */
43
+ const firstSpan = (sentence: Sentence, entry: LexiconEntry): Span | undefined => {
17
44
  // 大文字小文字は区別しない。英語の文頭の「Circle back」も「circle back」として当てる。
18
45
  const wanted = entry.pattern.toLowerCase();
19
- return (
20
- sentence.text.toLowerCase().includes(wanted) ||
21
- (sentence.tokens ?? []).some((token) => token.lemma?.toLowerCase() === wanted) ||
22
- conjugatedSpans(sentence, entry).length > 0
23
- );
46
+ const found = [...textSpans(sentence, wanted), ...lemmaSpans(sentence, wanted), ...conjugatedSpans(sentence, entry)][0];
47
+ return found === undefined ? undefined : writtenSpan(sentence, found);
48
+ };
49
+
50
+ const covers = (outer: Span, inner: Span): boolean => outer !== inner && outer.start <= inner.start && inner.end <= outer.end;
51
+
52
+ /** 文に出た、並べた語のそれぞれ。並べた語どうしが重なれば(握る・握っておく)、長い方だけ。 */
53
+ const sentenceHits = (sentence: Sentence, entries: readonly LexiconEntry[]): Span[] => {
54
+ const spans = entries.flatMap((entry) => {
55
+ const span = firstSpan(sentence, entry);
56
+ return span === undefined ? [] : [span];
57
+ });
58
+ const distinct = spans.filter((span, index) => spans.findIndex((other) => other.start === span.start && other.end === span.end) === index);
59
+ return distinct.filter((span) => !distinct.some((other) => covers(other, span))).toSorted((left, right) => left.start - right.start);
24
60
  };
25
61
 
26
62
  export const internalJargon: Detector = (doc, options): Finding[] => {
27
63
  const entries = options.lexicon ?? [];
28
64
  if (entries.length === 0) return [];
29
- const hits = doc.sentences.flatMap((sentence) => {
30
- const matched = entries.find((entry) => matches(sentence, entry))?.pattern;
31
- return matched === undefined ? [] : [{ sentence, matched }];
32
- });
65
+ const hits = doc.sentences.flatMap((sentence) => sentenceHits(sentence, entries).map((span) => ({ sentence, span })));
33
66
  if (hits.length < options.limit) return [];
34
67
  return hits.map((hit) => ({
35
68
  rule: "internal-jargon",
@@ -37,7 +70,12 @@ export const internalJargon: Detector = (doc, options): Finding[] => {
37
70
  line: 0,
38
71
  column: 0,
39
72
  quote: hit.sentence.text.trim(),
40
- values: { matched: hit.matched, count: hits.length, limit: options.limit, offset: hit.sentence.span.start },
73
+ values: {
74
+ matched: hit.sentence.text.slice(hit.span.start, hit.span.end),
75
+ count: hits.length,
76
+ limit: options.limit,
77
+ offset: hit.sentence.span.start + hit.span.start,
78
+ },
41
79
  }));
42
80
  };
43
81
 
@@ -1,7 +1,7 @@
1
1
  import type { Detector, Finding } from "../plugin.ts";
2
2
  import { escapeRegExp } from "../orthography.ts";
3
3
  import { formMinority } from "./form-minority.ts";
4
- import { quoteAround } from "./quote-around.ts";
4
+ import { quoteAround, sentenceQuoteAt } from "./quote-around.ts";
5
5
 
6
6
  // One document writing a number and a unit symbol both with a space between them ("5 GB") and without ("5GB"). Neither is
7
7
  // called right; per unit, the less common way is reported. The symbols come from each language's lexicon "unit-symbol".
@@ -65,7 +65,7 @@ export const unitSpacing: Detector = (doc, options): Finding[] => {
65
65
  severity: "info",
66
66
  line: 0,
67
67
  column: 0,
68
- quote: quoteAround(text, odd.offset, odd.offset + odd.written.length),
68
+ quote: sentenceQuoteAt(doc.sentences, odd.offset) ?? quoteAround(text, odd.offset, odd.offset + odd.written.length),
69
69
  values: { written: odd.written, usual, count, of, offset: odd.offset },
70
70
  }));
71
71
  };
@@ -5,6 +5,7 @@
5
5
  // promptly suspend, 速やかに解除することができる) sets no deadline. The words come from the language package's word
6
6
  // lists: vague-deadline, concrete-deadline (a stated limit: 日以内, "within … days") and deadline-permission. Pure.
7
7
  import { quoteAt } from "./structure-tree.ts";
8
+ import { sentenceQuoteAt } from "./quote-around.ts";
8
9
  import type { Detector, Finding, LexiconEntry, ProseDocument } from "../plugin.ts";
9
10
 
10
11
  export type VagueDeadline = { readonly offset: number; readonly word: string };
@@ -127,6 +128,6 @@ export const vagueDeadline: Detector = (doc): Finding[] =>
127
128
  severity: "info",
128
129
  line: 0,
129
130
  column: 0,
130
- quote: quoteAt(doc.source, hit.offset),
131
+ quote: sentenceQuoteAt(doc.sentences, hit.offset) ?? quoteAt(doc.source, hit.offset),
131
132
  values: { word: hit.word, offset: hit.offset },
132
133
  }));
package/src/levels.ts CHANGED
@@ -18,11 +18,17 @@ export type Resolved = { readonly level: Level; readonly limit: number; readonly
18
18
  * ジャンル別の閾値。"business/email" は "business" より細かいので先に当たる。
19
19
  * 仕様書の一文と社内メールに同じ文長を課すと、どちらかが必ず間違う。spec §9。
20
20
  */
21
- const tableFor = (rule: RuleDefinition, genre: string | undefined): LevelTable => {
22
- if (genre === undefined) return rule.levels;
21
+ /** The by_genre key whose numbers a genre takes, or undefined when it takes the rule's default levels. */
22
+ export const genreKeyFor = (rule: RuleDefinition, genre: string | undefined): string | undefined => {
23
+ if (genre === undefined) return undefined;
23
24
  const parts = genre.split("/");
24
25
  const keys = parts.map((_, index) => parts.slice(0, parts.length - index).join("/"));
25
- return keys.reduce<LevelTable | undefined>((found, key) => found ?? rule.by_genre[key], undefined) ?? rule.levels;
26
+ return keys.find((key) => rule.by_genre[key] !== undefined);
27
+ };
28
+
29
+ const tableFor = (rule: RuleDefinition, genre: string | undefined): LevelTable => {
30
+ const key = genreKeyFor(rule, genre);
31
+ return (key === undefined ? undefined : rule.by_genre[key]) ?? rule.levels;
26
32
  };
27
33
 
28
34
  export const resolve = (rule: RuleDefinition, level: Level, genre?: string): Resolved => {
@@ -130,3 +130,32 @@ export const isInFileName = (text: string, offset: number, length: number): bool
130
130
  const run = withoutTrailingMarks(text.slice(start, offset + length + (after < 0 ? rest.length : after)));
131
131
  return run.replace(EXTENSION, "").length > length && FILE_OR_URL.test(run);
132
132
  };
133
+
134
+ /** The word just before a form, with spaces or an opening quotation mark between (A in “A Coiner). */
135
+ const WORD_BEFORE = /(?<!\p{L})(\p{L}+)[\s"“‘']*$/u;
136
+
137
+ /**
138
+ * Whether the one-word form at offset follows an article from the lexicon name-count-article (a, an) and is a dictionary
139
+ * word ("A Coiner, a very good workman" beside Mrs. Coiler): a count noun, not a name.
140
+ */
141
+ export const isAfterCountArticle = (text: string, offset: number, name: string, articles: readonly string[], isKnown: (word: string) => boolean): boolean => {
142
+ const before = WORD_BEFORE.exec(text.slice(text.lastIndexOf("\n", offset - 1) + 1, offset))?.[1]?.toLowerCase();
143
+ return ONE_WORD.test(name) && before !== undefined && articles.includes(before) && isKnown(name.toLowerCase());
144
+ };
145
+
146
+ /** What may stand between a wrong mark and the form it marks: spaces, a colon. */
147
+ const MARK_GAP = /[\s::]/u;
148
+
149
+ const withoutTrailingGap = (text: string): string => {
150
+ const chars = [...text];
151
+ return chars.slice(0, chars.findLastIndex((char) => !MARK_GAP.test(char)) + 1).join("");
152
+ };
153
+
154
+ /**
155
+ * Whether the form at offset follows a wrong mark from the lexicon name-wrong-mark on its own line (× Rspec beside ○ RSpec):
156
+ * a list showing a wrong spelling on purpose, not a use of the name.
157
+ */
158
+ export const isMarkedWrong = (text: string, offset: number, marks: readonly string[]): boolean => {
159
+ const before = withoutTrailingGap(text.slice(text.lastIndexOf("\n", offset - 1) + 1, offset));
160
+ return marks.some((mark) => before.endsWith(mark));
161
+ };
@@ -94,13 +94,29 @@ const withoutUnclosedBracket = (written: string): string => written.replace(UNCL
94
94
  /** URLs covered with spaces, so neither a path segment (/call/) nor an id in one is read. Offsets stay the same. */
95
95
  export const withoutUrls = (text: string): string => text.replaceAll(URL, (url) => " ".repeat(url.length));
96
96
 
97
- /** The phone numbers of a text that have a label shortly before them on their line; unlabelled digits and URLs are not read. */
98
- export const labelledPhoneNumbers = (source: string, labels: readonly LexiconEntry[]): PhoneNumber[] => {
97
+ /** Link words (at, on, us) written whole right before a number, as one run: "line at ", "us on ". */
98
+ const linkRunOf = (links: readonly string[]): RegExp | undefined =>
99
+ links.length === 0 ? undefined : new RegExp(String.raw`(?:(?<!\p{L})(?:${links.map(escapeRegExp).join("|")})\s+)+$`, "iu");
100
+
101
+ /** Where a number's label is looked for: before the link words that join it to the number (Call us on, our recall line at). */
102
+ const labelEnd = (text: string, offset: number, linkRun: RegExp | undefined): number => {
103
+ if (linkRun === undefined) return offset;
104
+ const lineStart = text.lastIndexOf("\n", offset - 1) + 1;
105
+ const run = linkRun.exec(text.slice(lineStart, offset));
106
+ return run === null ? offset : offset - run[0].length;
107
+ };
108
+
109
+ /**
110
+ * The phone numbers of a text that have a label shortly before them on their line; unlabelled digits and URLs are not read.
111
+ * links are the words that may stand between a label and its number (the language's phone-label-link lexicon).
112
+ */
113
+ export const labelledPhoneNumbers = (source: string, labels: readonly LexiconEntry[], links: readonly string[] = []): PhoneNumber[] => {
99
114
  const text = withoutUrls(source);
115
+ const linkRun = linkRunOf(links);
100
116
  const read = (match: RegExpExecArray, spaced: boolean): PhoneNumber[] => {
101
117
  const digits = match[0].replaceAll(NOT_DIGIT, "");
102
118
  if (digits.length < MIN_DIGITS || digits.length > MAX_DIGITS) return [];
103
- const label = labelBefore(text, match.index, labels);
119
+ const label = labelBefore(text, labelEnd(text, match.index, linkRun), labels);
104
120
  if (label === undefined) return [];
105
121
  if (spaced && !COUNTRY_CODE_START.test(match[0]) && !LABEL_TO_NUMBER.test(label.between)) return [];
106
122
  const matched = match[0].trim();
package/src/plugin.ts CHANGED
@@ -79,6 +79,8 @@ export type LexiconEntry = {
79
79
  readonly heading_only?: boolean | undefined;
80
80
  /** The entry counts only where it opens the sentence (近年、… but not その後、近年の…). phrase-match honours it. */
81
81
  readonly opens?: boolean | undefined;
82
+ /** The entry does not count where the next word has one of these parts of speech: "your welcome email" is a welcome email, not "you're welcome". phrase-match honours it when tokens are read. */
83
+ readonly not_before_pos?: readonly string[] | undefined;
82
84
  /** pattern を adapter が語に分けたもの。品詞が読めるときだけ core が入れる。語彙表を書く側は書かない。 */
83
85
  readonly tokens?: readonly Token[] | undefined;
84
86
  };
@@ -1,4 +1,4 @@
1
- import { definedLevels, resolve, severityAt } from "../levels.ts";
1
+ import { definedLevels, genreKeyFor, resolve, severityAt } from "../levels.ts";
2
2
  import { fill, localized, readableText } from "./text.ts";
3
3
  import { SEVERITY_NAME } from "./severity-name.ts";
4
4
  import { uiLanguageOf, type Texts } from "../ui.ts";
@@ -9,8 +9,10 @@ import { depthMeaning } from "../rewrite-depth.ts";
9
9
 
10
10
  const TEXT: Texts<{
11
11
  readonly off: string;
12
- readonly defaultGenre: string;
13
- readonly genreNote: (genre: string, others: string) => string;
12
+ readonly numbersFor: (key: string | undefined, genre: string | undefined) => string;
13
+ readonly othersOwn: (others: readonly string[]) => string;
14
+ readonly othersDefault: string;
15
+ readonly sentenceGap: string;
14
16
  readonly experimental: string;
15
17
  readonly alone: (id: string) => string;
16
18
  readonly howToFix: string;
@@ -22,13 +24,19 @@ const TEXT: Texts<{
22
24
  readonly severities: string;
23
25
  readonly now: (level: string) => string;
24
26
  readonly nowNumber: (limit: string) => string;
27
+ readonly notRun: (why: string) => string;
25
28
  readonly from: (source: string) => string;
26
29
  readonly change: (id: string) => string;
27
30
  }> = {
28
31
  ja: {
29
32
  off: "見ない",
30
- defaultGenre: "既定",
31
- genreNote: (genre, others) => `この数字は ${genre} のものです。ほかに ${others} で別の数字を持っています。`,
33
+ numbersFor: (key, genre) => {
34
+ const owner = key === undefined ? "既定" : ` ${key} `;
35
+ return genre === undefined || genre === key ? `この数字は${owner}のものです。` : `この数字は${owner}のもので、${genre} はこれを使います。`;
36
+ },
37
+ othersOwn: (others) => `${others.join(" / ")} は別の数字を持っています。`,
38
+ othersDefault: "ほかのジャンルは既定の数字を使います。",
39
+ sentenceGap: "",
32
40
  experimental: "このルールはまだ試験中で、既定では動きません(--experimental で動きます)。",
33
41
  alone: (id) => `このルールだけを動かす: npx chaffjs enable ${id}(chaff.yaml の rules に ${id}: normal と書くのと同じです)`,
34
42
  howToFix: "直しかた",
@@ -38,17 +46,24 @@ const TEXT: Texts<{
38
46
  definedIn: (plugin) =>
39
47
  plugin === undefined ? "このルールはチームが chaff.yaml の custom_rules で決めたものです。" : `このルールはプラグイン ${plugin} のものです。`,
40
48
  values: "設定できる値:",
41
- times: "回",
49
+ times: "{limit} 回",
42
50
  severities: "設定できる値(数える上限は無く、指摘の重さが変わります):",
43
51
  now: (level) => `いまは ${level} です。`,
44
52
  nowNumber: (limit) => `いまは段階ではなく数です: ${limit}。`,
53
+ notRun: (why) => `いまは動きません(${why})。`,
45
54
  from: (source) => `(${source} で決めています)`,
46
55
  change: (id) => `変える: npx chaffjs relax ${id} --why "理由"`,
47
56
  },
48
57
  en: {
49
58
  off: "not checked",
50
- defaultGenre: "the default genre",
51
- genreNote: (genre, others) => `These numbers are for ${genre}. ${others} have numbers of their own.`,
59
+ numbersFor: (key, genre) => {
60
+ if (key === undefined)
61
+ return genre === undefined ? "These numbers are for the default genre." : `These numbers are the default ones, which ${genre} takes.`;
62
+ return genre === key ? `These numbers are for ${key}.` : `These numbers are for ${key}, which ${genre} takes.`;
63
+ },
64
+ othersOwn: (others) => `${others.join(" / ")} ${others.length === 1 ? "has numbers of its own" : "have numbers of their own"}.`,
65
+ othersDefault: "Other genres take the default numbers.",
66
+ sentenceGap: " ",
52
67
  experimental: "This rule is still experimental and does not run by default (--experimental runs it).",
53
68
  alone: (id) => `Turn on this rule alone: npx chaffjs enable ${id} (the same as rules: { ${id}: normal } in chaff.yaml)`,
54
69
  howToFix: "How to fix",
@@ -57,10 +72,11 @@ const TEXT: Texts<{
57
72
  definedIn: (plugin) =>
58
73
  plugin === undefined ? "The team defined this rule under custom_rules in chaff.yaml." : `This rule comes from the plugin ${plugin}.`,
59
74
  values: "Levels:",
60
- times: "times",
75
+ times: "{limit} {limit|time|times}",
61
76
  severities: "Levels (there is no limit to count to; a level sets how a finding is marked):",
62
77
  now: (level) => `Now: ${level}.`,
63
78
  nowNumber: (limit) => `Now: ${limit}, set as a number rather than a level.`,
79
+ notRun: (why) => `Now: not run (${why}).`,
64
80
  from: (source) => ` (set by ${source})`,
65
81
  change: (id) => `Change it: npx chaffjs relax ${id} --why "reason"`,
66
82
  },
@@ -72,7 +88,7 @@ const TEXT: Texts<{
72
88
  */
73
89
  const limitText = (rule: RuleDefinition, limit: number, language: string): string => {
74
90
  const meaning = localized(rule.guide?.levelMeaning ?? {}, language);
75
- return meaning === "" ? `${String(limit)} ${TEXT[uiLanguageOf(language)].times}` : fill(meaning, { limit });
91
+ return fill(meaning === "" ? TEXT[uiLanguageOf(language)].times : meaning, { limit });
76
92
  };
77
93
 
78
94
  /** What a level holds: the limit a detector counts to, or the severity a rule with nothing to count gives. */
@@ -90,9 +106,11 @@ const levelLine = (rule: RuleDefinition, level: Level, current: Level | undefine
90
106
 
91
107
  /** ジャンルで数字が変わる rule は、それを言わないと「設定したのに効かない」に見える。 */
92
108
  const genreNote = (rule: RuleDefinition, genre: string | undefined, text: (typeof TEXT)["ja"]): string[] => {
93
- const others = Object.keys(rule.by_genre).filter((key) => key !== genre);
94
- if (others.length === 0) return [];
95
- return ["", ` ${text.genreNote(genre ?? text.defaultGenre, others.join(" / "))}`];
109
+ const key = genreKeyFor(rule, genre);
110
+ const others = Object.keys(rule.by_genre).filter((other) => other !== key);
111
+ if (others.length === 0 && key === undefined) return [];
112
+ const othersLine = others.length === 0 ? text.othersDefault : text.othersOwn(others);
113
+ return ["", ` ${text.numbersFor(key, genre)}${text.sentenceGap}${othersLine}`];
96
114
  };
97
115
 
98
116
  /** A team's rule shows its example, before and after, and says where it was defined. */
@@ -117,6 +135,13 @@ export type ExplainSettings = {
117
135
  readonly limit?: number | undefined;
118
136
  /** The rule is off only because it is experimental, so naming it would run it: say how. */
119
137
  readonly offOnlyAsExperimental?: boolean;
138
+ /** Why the genre keeps the rule from running, as a run lists it: then no level is current. */
139
+ readonly genreStop?: string | undefined;
140
+ };
141
+
142
+ const nowLine = (rule: RuleDefinition, current: Level, limit: number | undefined, language: string): string => {
143
+ const text = TEXT[uiLanguageOf(language)];
144
+ return limit === undefined ? text.now(current) : text.nowNumber(limitText(rule, limit, language));
120
145
  };
121
146
 
122
147
  /** rule の意図と根拠を読む。指摘に納得できないときの入口。 */
@@ -124,10 +149,15 @@ export const renderExplain = (rule: RuleDefinition, current: Level, language: st
124
149
  const { optionLayers = [], levelFrom } = settings;
125
150
  // A rule with nothing to count has no number to set; chaff.yaml's number on it is reported as a problem and ignored.
126
151
  const limit = rule.level_sets === "severity" ? undefined : settings.limit;
127
- const marked = limit === undefined ? current : undefined;
152
+ const { genreStop } = settings;
153
+ const marked = limit === undefined && genreStop === undefined ? current : undefined;
128
154
  const text = TEXT[uiLanguageOf(language)];
129
155
  const experimental =
130
- rule.status === "experimental" ? [` ${text.experimental}`, ...(settings.offOnlyAsExperimental === true ? [` ${text.alone(rule.id)}`] : [])] : [];
156
+ rule.status === "experimental" && genreStop === undefined
157
+ ? [` ${text.experimental}`, ...(settings.offOnlyAsExperimental === true ? [` ${text.alone(rule.id)}`] : [])]
158
+ : [];
159
+ const from = levelFrom === undefined ? "" : text.from(levelFrom);
160
+ const now = genreStop === undefined ? `${nowLine(rule, current, limit, language)}${from}` : text.notRun(genreStop);
131
161
  return [
132
162
  "",
133
163
  ` ${readableText(rule, rule.name, language)} (${rule.id})`,
@@ -143,7 +173,7 @@ export const renderExplain = (rule: RuleDefinition, current: Level, language: st
143
173
  ...genreNote(rule, genre, text),
144
174
  ...optionLines(rule, optionLayers, language),
145
175
  "",
146
- ` ${limit === undefined ? text.now(current) : text.nowNumber(limitText(rule, limit, language))}${levelFrom === undefined ? "" : text.from(levelFrom)}`,
176
+ ` ${now}`,
147
177
  ...experimental,
148
178
  "",
149
179
  ` ${text.change(rule.id)}`,
@@ -29,18 +29,23 @@ const TEXT: Texts<{ readonly heading: string; readonly byDefault: string; readon
29
29
  {
30
30
  ja: {
31
31
  heading: "オプション(chaff.yaml の options で決めます):",
32
- byDefault: "既定",
33
- from: (source) => `${source} から`,
32
+ byDefault: "(既定)",
33
+ from: (source) => `(${source} から)`,
34
34
  howTo: (id) => `決める: chaff.yaml に options: { ${id}: { <名前>: <値> } } を書く`,
35
35
  },
36
36
  en: {
37
37
  heading: "Options (set under options in chaff.yaml):",
38
- byDefault: "default",
39
- from: (source) => `from ${source}`,
38
+ byDefault: "(default)",
39
+ from: (source) => `(from ${source})`,
40
40
  howTo: (id) => `Set one: write options: { ${id}: { <name>: <value> } } in chaff.yaml`,
41
41
  },
42
42
  };
43
43
 
44
+ /** The narrowest column a choice name is padded to, so short names line up as before. */
45
+ const CHOICE_COLUMN = 11;
46
+ /** The spaces between the longest choice name and its meaning. */
47
+ const CHOICE_GAP = 2;
48
+
44
49
  /** A rule's options for explain: each one's value now and where it came from, what it decides, and each choice's meaning. */
45
50
  export const optionLines = (rule: RuleDefinition, layers: readonly OptionLayer[], language: string): string[] => {
46
51
  if (rule.options === undefined) return [];
@@ -49,10 +54,11 @@ export const optionLines = (rule: RuleDefinition, layers: readonly OptionLayer[]
49
54
  const lines = Object.entries(rule.options).flatMap(([name, option]) => {
50
55
  const now = settled[name];
51
56
  const source = now === undefined || now.from === DEFAULT_SOURCE ? text.byDefault : text.from(now.from);
57
+ const width = Math.max(CHOICE_COLUMN, ...Object.keys(option.choiceNames).map((choice) => choice.length + CHOICE_GAP));
52
58
  const choices = Object.entries(option.choiceNames).map(
53
- ([choice, meaning]) => ` ${choice === now?.value ? "→" : " "} ${choice.padEnd(11)}${localized(meaning, language)}`,
59
+ ([choice, meaning]) => ` ${choice === now?.value ? "→" : " "} ${choice.padEnd(width)}${localized(meaning, language)}`,
54
60
  );
55
- return [` ${name}: ${printed(now?.value ?? option.default)} (${source})`, ` ${localized(option.about, language)}`, ...choices];
61
+ return [` ${name}: ${printed(now?.value ?? option.default)} ${source}`, ` ${localized(option.about, language)}`, ...choices];
56
62
  });
57
63
  return ["", ` ${text.heading}`, ...lines, "", ` ${text.howTo(rule.id)}`];
58
64
  };
@@ -22,16 +22,29 @@ export const templateForReading = (template: string, readings: Readonly<Record<s
22
22
  /** A rule's text for one finding, with the finding's values in it. */
23
23
  export const filledText = (field: Localized, finding: Finding, language: string): string => fill(localized(field, language), finding.values);
24
24
 
25
+ /** An English reading that opens with a determiner (the word found) describes the value; one that does not (always, N) is a sample of it. */
26
+ const DESCRIBING = /^(?:the|a|an|another|one|how)\s/iu;
27
+ /** A stand-in for the value itself (〇〇), which reads as the word in quotation marks. */
28
+ const STAND_IN = /^〇+$/u;
29
+ const QUOTED_PLACEHOLDER = /([「『“"])\{(\w+)\}([」』”"])/gu;
30
+ const CLOSER: Readonly<Record<string, string>> = { "「": "」", "『": "』", "“": "”", '"': '"' };
31
+
32
+ /** A description in quotation marks reads as if it were the word itself (Change it to 「直した書き方」), so its marks go. */
33
+ const unquoteDescriptions = (template: string, describing: ReadonlySet<string>): string =>
34
+ template.replace(QUOTED_PLACEHOLDER, (whole, open: string, key: string, close: string) =>
35
+ CLOSER[open] === close && describing.has(key) ? `{${key}}` : whole,
36
+ );
37
+
25
38
  /** A rule's text where no finding fills it (explain, rules --json, the rule reference): each value as the rule's words for it. */
26
39
  export const readableText = (rule: Pick<RuleDefinition, "placeholders">, field: Localized, language: string): string => {
27
40
  // The same fallback as the text itself: an English-only rule read in Japanese still gets its English words.
28
- const readings = Object.fromEntries(
29
- Object.entries(rule.placeholders ?? {}).flatMap(([key, reading]) => {
30
- const words = localized(reading, language);
31
- return words === "" ? [] : [[key, words]];
32
- }),
33
- );
34
- return templateForReading(localized(field, language), readings);
41
+ const entries = Object.entries(rule.placeholders ?? {}).flatMap(([key, reading]) => {
42
+ const words = localized(reading, language);
43
+ return words === "" ? [] : [{ key, words, describing: DESCRIBING.test(reading["en"] ?? "") && !STAND_IN.test(words) }];
44
+ });
45
+ const readings = Object.fromEntries(entries.map(({ key, words }) => [key, words]));
46
+ const describing = new Set(entries.filter((entry) => entry.describing).map(({ key }) => key));
47
+ return templateForReading(unquoteDescriptions(localized(field, language), describing), readings);
35
48
  };
36
49
 
37
50
  const templateOf = (rule: RuleDefinition, finding: Finding): Localized =>
package/src/run.ts CHANGED
@@ -19,7 +19,7 @@ import { PatternTimeout } from "./custom/pattern-timeout.ts";
19
19
  import { PluginRuleFailure } from "./extension/module-detector.ts";
20
20
  import { failureReason } from "./extension/failure-text.ts";
21
21
  import { tagCoverage } from "./tag-coverage.ts";
22
- import { compositeSignals } from "./composite-signals.ts";
22
+ import { compositeSignals, signalNames } from "./composite-signals.ts";
23
23
 
24
24
  export type Skipped = {
25
25
  readonly rule: string;
@@ -157,6 +157,10 @@ const untagged = (rule: RuleDefinition, doc: ProseDocument): string | undefined
157
157
 
158
158
  const suitsGenre = (rule: RuleDefinition, genre: string): boolean => rule.use_for.some((target) => genre.startsWith(target));
159
159
 
160
+ /** Why the genre keeps the rule from running, in a run's words: use_for leaves the genre out, or its preset turns the rule off and chaff.yaml does not name it. */
161
+ export const genreStop = (rule: RuleDefinition, settings: Settings, preset: Settings, genre: string, reasons: Reasons): string | undefined =>
162
+ !suitsGenre(rule, genre) || (settings[rule.id] === undefined && preset[rule.id] === "off") ? reasons.presetOff(genre) : undefined;
163
+
160
164
  const forGenre = (rules: readonly RuleDefinition[], genre: string): RuleDefinition[] => rules.filter((rule) => suitsGenre(rule, genre));
161
165
 
162
166
  /** A rule use_for keeps out of the genre. A rule for another language says that first: no genre would run it here. */
@@ -212,7 +216,10 @@ export const place = (starts: readonly number[], finding: Finding): Finding => {
212
216
  * 元の指摘は消さない。`padded-intro` のように単独でも正しい指摘が混ざっており、
213
217
  * まとめるために消すと本物の指摘が見えなくなる。
214
218
  */
215
- const compositeOf = (rule: RuleDefinition, found: readonly Finding[], limit: number, starts: readonly number[], language: string): Finding[] => {
219
+ type CompositeContext = { readonly starts: readonly number[]; readonly language: string; readonly rules: readonly RuleDefinition[] };
220
+
221
+ const compositeOf = (rule: RuleDefinition, found: readonly Finding[], limit: number, context: CompositeContext): Finding[] => {
222
+ const { starts, language, rules } = context;
216
223
  const fired = compositeSignals(rule.from, found);
217
224
  if (fired.length < limit) return [];
218
225
  // 数えなかった signal も含めて、最初に出た所に置く。同じ形を 1 種に数えても、指摘の位置は動かない。
@@ -224,7 +231,13 @@ const compositeOf = (rule: RuleDefinition, found: readonly Finding[], limit: num
224
231
  line: 0,
225
232
  column: 0,
226
233
  quote: first?.quote ?? "",
227
- values: { word: joinWords(fired, language), count: fired.length, limit, offset: first === undefined ? 0 : Number(first.values["offset"] ?? 0) },
234
+ values: {
235
+ word: joinWords(fired, language),
236
+ signals: joinWords(signalNames(fired, rules, uiLanguageOf(language)), language),
237
+ count: fired.length,
238
+ limit,
239
+ offset: first === undefined ? 0 : Number(first.values["offset"] ?? 0),
240
+ },
228
241
  }),
229
242
  ];
230
243
  };
@@ -234,6 +247,17 @@ export type Limits = Readonly<Record<string, number>>;
234
247
 
235
248
  export const limitFor = (rule: RuleDefinition, level: Level, genre: string, limits: Limits): number => limits[rule.id] ?? resolve(rule, level, genre).limit;
236
249
 
250
+ type CompositeLevels = {
251
+ readonly levelOf: (rule: RuleDefinition) => Level;
252
+ readonly limitOf: (rule: RuleDefinition, level: Level) => number;
253
+ readonly context: CompositeContext;
254
+ };
255
+
256
+ const compositesOf = (applicable: readonly RuleDefinition[], found: readonly Finding[], levels: CompositeLevels): Finding[] =>
257
+ applicable
258
+ .filter((rule) => rule.from.length > 0 && levels.levelOf(rule) !== "off")
259
+ .flatMap((rule) => compositeOf(rule, found, levels.limitOf(rule, levels.levelOf(rule)), levels.context));
260
+
237
261
  /** 文書と違う言語で書いた文の上限。chaff.yaml の数値は文書の言語の単位で書いたものなので、ここには効かせない。 */
238
262
  const embeddedLimitsFor = (rule: RuleDefinition, level: Level, genre: string, embedded: readonly string[]): Record<string, number> =>
239
263
  Object.fromEntries(
@@ -326,11 +350,11 @@ export const runRulesWith = (doc: ProseDocument, rules: readonly RuleDefinition[
326
350
  },
327
351
  { findings: [], skipped: [] },
328
352
  );
329
- const composites = applicable
330
- .filter((rule) => rule.from.length > 0 && levelFor(rule, settings, experimental, preset) !== "off")
331
- .flatMap((rule) =>
332
- compositeOf(rule, outcome.findings, limitFor(rule, levelFor(rule, settings, experimental, preset), genre, limits), starts, doc.language),
333
- );
353
+ const composites = compositesOf(applicable, outcome.findings, {
354
+ levelOf: (rule) => levelFor(rule, settings, experimental, preset),
355
+ limitOf: (rule, level) => limitFor(rule, level, genre, limits),
356
+ context: { starts, language: doc.language, rules },
357
+ });
334
358
  const all = [...outcome.findings, ...composites];
335
359
  return { ...outcome, findings: all.toSorted(byPosition), forcedExperimental: forced, presetExperimental: presetOn };
336
360
  };
@@ -18,13 +18,13 @@ const headBefore = (tokens: readonly Token[], at: number): string => {
18
18
  .join("");
19
19
  };
20
20
 
21
- /** Whether the particle at `at`, the words before it and the dictionary form of the word after it spell one of phrases (おそれのある). */
21
+ /** Whether the particle at `at`, the words before it and the dictionary form of the word after it spell one of phrases (おそれのある). A phrase that starts with the particle (のよう) takes any word before it. */
22
22
  const isInPhrase = (tokens: readonly Token[], at: number, phrases: readonly string[]): boolean => {
23
23
  const [particle, after] = [tokens[at], tokens[at + 1]];
24
24
  if (particle === undefined || after === undefined || !touches(particle, after)) return false;
25
25
  const tail = `${particle.surface}${after.lemma ?? after.surface}`;
26
26
  const head = headBefore(tokens, at);
27
- return phrases.some((phrase) => phrase.endsWith(tail) && phrase.length > tail.length && head.endsWith(phrase.slice(0, -tail.length)));
27
+ return phrases.some((phrase) => phrase.endsWith(tail) && head.endsWith(phrase.slice(0, -tail.length)));
28
28
  };
29
29
 
30
30
  /** The counted particles (particles) of a sentence that stand inside one of phrases, each written whole (おそれのある). */