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
@@ -2,9 +2,7 @@ import type { Detector, Finding, Lexicon, ProseDocument, Span } from "../plugin.
2
2
  import { escapeRegExp } from "../orthography.ts";
3
3
  import { isQuotedAlone } from "../quoted-span.ts";
4
4
  import { findingAt, markupOf } from "./markup-finding.ts";
5
-
6
- /** One marker a chat interface leaves when its answer is pasted: where it is and what was written. */
7
- export type ChatMarker = { readonly matched: string; readonly span: Span };
5
+ import { wholeMarks, type ChatMarker } from "./chat-mark-extent.ts";
8
6
 
9
7
  /** Every place a lexicon pattern is written in `text`, case and all, in the order they appear. */
10
8
  export const markersIn = (text: string, lexicon: Lexicon): ChatMarker[] =>
@@ -69,9 +67,10 @@ export const standsAlone = (source: string, span: Span): boolean => {
69
67
  return withoutSurrounding(`${before}${marker}${after}`) === marker;
70
68
  };
71
69
 
72
- /** Each marker is a leftover in its own right, so each is reported, from the first. */
70
+ /** Each mark is a leftover in its own right, so each is reported once, whole, from the first. */
73
71
  export const chatCitationResidue: Detector = (doc, options): Finding[] => {
74
- const markers = markersIn(doc.source, options.lexicon ?? []).filter((marker) => reachesReader(doc, marker.span) && !standsAlone(doc.source, marker.span));
72
+ const found = markersIn(doc.source, options.lexicon ?? []).filter((marker) => reachesReader(doc, marker.span) && !standsAlone(doc.source, marker.span));
73
+ const markers = wholeMarks(doc.source, found);
75
74
  if (markers.length === 0 || markers.length < options.limit) return [];
76
75
  return markers.map((marker) => findingAt(doc, marker.span, { matched: marker.matched, count: markers.length, limit: options.limit }));
77
76
  };
@@ -0,0 +1,63 @@
1
+ import type { Span } from "../plugin.ts";
2
+
3
+ /** One marker a chat interface leaves when its answer is pasted: where it is and what was written. */
4
+ export type ChatMarker = { readonly matched: string; readonly span: Span };
5
+
6
+ const CLOSING_OF: Readonly<Record<string, string>> = { "[": "]", "【": "】" };
7
+ const OPENING_OF: Readonly<Record<string, string>> = { "]": "[", "】": "【" };
8
+ const LEAD_IN = ":";
9
+
10
+ const lineEndAfter = (source: string, index: number): number => {
11
+ const end = source.indexOf("\n", index);
12
+ return end === -1 ? source.length : end;
13
+ };
14
+
15
+ /** Where the bracket opened at `open` closes on its line (just after the closer), or undefined when it does not. */
16
+ const closedAt = (source: string, open: number): number | undefined => {
17
+ const closer = CLOSING_OF[source[open] ?? ""];
18
+ if (closer === undefined) return undefined;
19
+ const close = source.indexOf(closer, open + 1);
20
+ return close === -1 || close >= lineEndAfter(source, open) ? undefined : close + 1;
21
+ };
22
+
23
+ /** A marker that opens a bracket (contentReference[) runs to its closer and any {…} right after it. */
24
+ const forwardEnd = (source: string, span: Span): number => {
25
+ const opened = span.end - 1;
26
+ const closed = CLOSING_OF[source[opened] ?? ""] === undefined ? undefined : closedAt(source, opened);
27
+ const end = closed ?? span.end;
28
+ return source[end] === "{" ? (closedBraceAt(source, end) ?? end) : end;
29
+ };
30
+
31
+ const closedBraceAt = (source: string, open: number): number | undefined => {
32
+ const close = source.indexOf("}", open + 1);
33
+ return close === -1 || close >= lineEndAfter(source, open) ? undefined : close + 1;
34
+ };
35
+
36
+ /** A marker that closes a bracket it did not open (†source】) starts where that bracket opens on its line. */
37
+ const backwardStart = (source: string, span: Span): number => {
38
+ const written = source.slice(span.start, span.end);
39
+ const opener = OPENING_OF[written.at(-1) ?? ""];
40
+ if (opener === undefined || written.includes(opener)) return span.start;
41
+ const lineStart = source.lastIndexOf("\n", span.start - 1) + 1;
42
+ const open = source.lastIndexOf(opener, span.start - 1);
43
+ return open < lineStart ? span.start : open;
44
+ };
45
+
46
+ /** The whole mark a marker belongs to as written (:contentReference[oaicite:0]{index=0}, 【4:0†source】). */
47
+ export const markExtent = (source: string, span: Span): Span => {
48
+ const start = backwardStart(source, span);
49
+ const end = forwardEnd(source, span);
50
+ const widened = end > span.end || start < span.start;
51
+ return { start: widened && source[start - 1] === LEAD_IN ? start - 1 : start, end };
52
+ };
53
+
54
+ /** One marker per mark: each widened to its whole mark, and the markers inside a mark already taken dropped. */
55
+ export const wholeMarks = (source: string, markers: readonly ChatMarker[]): ChatMarker[] =>
56
+ markers
57
+ .map((marker) => markExtent(source, marker.span))
58
+ .toSorted((left, right) => left.start - right.start || right.end - left.end)
59
+ .reduce<Span[]>((kept, span) => {
60
+ const last = kept.at(-1);
61
+ return last !== undefined && span.start < last.end ? kept : [...kept, span];
62
+ }, [])
63
+ .map((span) => ({ matched: source.slice(span.start, span.end), span }));
@@ -12,7 +12,7 @@ import {
12
12
  isNavigationLine,
13
13
  startsWithin,
14
14
  statesIntent,
15
- withSubsections,
15
+ familyWithSlots,
16
16
  type AdviceWords,
17
17
  type IntentWords,
18
18
  } from "./concrete-evidence.ts";
@@ -83,7 +83,7 @@ export const concreteEvidence: Detector = (doc, options): Finding[] => {
83
83
  mostlyClaims(sentences, doc.language, advice, intent)
84
84
  );
85
85
  });
86
- const families = new Map(sections.map((section) => [section, withSubsections(doc.sections, section)]));
86
+ const families = new Map(sections.map((section) => [section, familyWithSlots(doc.sections, section)]));
87
87
  const familyOf = (section: Section): Section[] => families.get(section) ?? [section];
88
88
  const bare = sections.filter((section) => familyOf(section).every((member) => !concreteIn(doc, member)));
89
89
  // 構造の木と名前は求めるのに手間がかかる。指摘に届かない文書では求めない。
@@ -155,6 +155,33 @@ export const withSubsections = <T extends Pick<Section, "depth">>(sections: read
155
155
  return [section, ...(next === -1 ? after : after.slice(0, next))];
156
156
  };
157
157
 
158
+ type SlotSection = Pick<Section, "depth" | "heading" | "unlabeledHeading">;
159
+
160
+ /** 同じ見出しの節がこの数の親の下にあれば、項目ごとに繰り返す型の欄(状況・解決策・備考)。 */
161
+ const MIN_SLOT_PARENTS = 3;
162
+
163
+ const titleOf = (section: SlotSection): string => (section.unlabeledHeading ?? section.heading).trim();
164
+
165
+ const parentOf = <T extends SlotSection>(sections: readonly T[], section: T): T | undefined => {
166
+ const index = sections.indexOf(section);
167
+ const parent = sections.slice(0, Math.max(index, 0)).findLast((other) => other.depth < section.depth);
168
+ return parent !== undefined && parent.depth > 0 ? parent : undefined;
169
+ };
170
+
171
+ /**
172
+ * 型の欄の節は、その欄を持つ項目(親の節)と、項目の他の欄と合わせて読む。具体物を何欄目に書くかは項目ごとに違い、
173
+ * 一つの欄だけでは持ち帰るものを決められない。型の欄でなければ、その節と下の節。
174
+ */
175
+ export const familyWithSlots = <T extends SlotSection>(sections: readonly T[], section: T): T[] => {
176
+ const parent = parentOf(sections, section);
177
+ if (parent === undefined || titleOf(section) === "") return withSubsections(sections, section);
178
+ const parentsOfSameTitle = new Set(
179
+ sections.filter((other) => other.depth === section.depth && titleOf(other) === titleOf(section)).map((other) => parentOf(sections, other)),
180
+ );
181
+ parentsOfSameTitle.delete(undefined);
182
+ return parentsOfSameTitle.size >= MIN_SLOT_PARENTS ? withSubsections(sections, parent) : withSubsections(sections, section);
183
+ };
184
+
158
185
  /** 大文字だけの略語(API、PDFs)。どの文書にも出る技術の語で、名指しした物ではない。 */
159
186
  const ACRONYM = /^\p{Lu}+s?$/u;
160
187
  const CAPITAL_HEAD = /^\p{Lu}/u;
@@ -41,13 +41,11 @@ const occurrencesOf = (text: string, word: string): Span[] =>
41
41
  }));
42
42
 
43
43
  /**
44
- * prefer の「使わない書き方」が動詞のとき、活用した形の始まり(文の中の字の位置)。「使う書き方」の中に出たものは除く。
44
+ * prefer の「使わない書き方」が動詞のとき、活用した形の範囲(文の中の字の位置)。「使う書き方」の中に出たものは除く。
45
45
  * 大文字小文字だけ違う組(Javascript・JavaScript)は語で照らすと区別が消えるので、字で探す側に任せる。
46
46
  */
47
- export const conjugatedStartsOutside = (sentence: Sentence, entry: LexiconEntry, use: string): number[] => {
47
+ export const conjugatedSpansOutside = (sentence: Sentence, entry: LexiconEntry, use: string): Span[] => {
48
48
  if (entry.pattern.toLowerCase() === use.toLowerCase()) return [];
49
49
  const covered = occurrencesOf(sentence.text, use);
50
- return conjugatedSpans(sentence, entry)
51
- .filter((span) => !covered.some((cover) => cover.start <= span.start && span.end <= cover.end))
52
- .map((span) => span.start);
50
+ return conjugatedSpans(sentence, entry).filter((span) => !covered.some((cover) => cover.start <= span.start && span.end <= cover.end));
53
51
  };
@@ -1,4 +1,4 @@
1
- import type { Lexicon, LexiconEntry, Sentence } from "../plugin.ts";
1
+ import type { Lexicon, LexiconEntry, Sentence, Token } from "../plugin.ts";
2
2
  import { escapeRegExp } from "../orthography.ts";
3
3
  import { comparableText, comparableWords, entryCloses, entryIn, entryOpens, entryRanges } from "./lexicon-match.ts";
4
4
 
@@ -67,6 +67,41 @@ const opensWithWord = (sentence: Sentence, entry: LexiconEntry): boolean => {
67
67
  const nextAffirms = (next: Sentence | undefined, words: ContrastWords): boolean =>
68
68
  next !== undefined && groupOf(words.turns, ACROSS).some((turn) => opensWithWord(next, turn)) && !words.leads.some((lead) => entryIn(next, lead));
69
69
 
70
+ const ECHO = "echo";
71
+ const VERBAL: ReadonlySet<string> = new Set(["VERB", "AUX"]);
72
+ const SKIPPED: ReadonlySet<string> = new Set(["ADV", "PART"]);
73
+
74
+ const lemmaOf = (token: Token): string => comparableWords(token.lemma ?? token.surface);
75
+
76
+ /** The verb a denial denies: the verb right after it (didn't build → build), or its own (weren't → be). */
77
+ const deniedVerb = (sentence: Sentence, lead: LexiconEntry): string | undefined => {
78
+ const tokens = sentence.tokens ?? [];
79
+ const range = entryRanges(sentence, lead)[0];
80
+ if (range === undefined) return undefined;
81
+ const next = tokens.slice(range.end).find((token) => !SKIPPED.has(token.pos));
82
+ const own = tokens.slice(range.start, range.end).find((token) => VERBAL.has(token.pos));
83
+ const verb = next?.pos === "VERB" ? next : own;
84
+ return verb === undefined ? undefined : lemmaOf(verb);
85
+ };
86
+
87
+ /** The verb right after the subject that opens the sentence (We built → build). */
88
+ const affirmedVerb = (sentence: Sentence): string | undefined => {
89
+ const verb = (sentence.tokens ?? []).slice(1).find((token) => !SKIPPED.has(token.pos));
90
+ return verb !== undefined && VERBAL.has(verb.pos) ? lemmaOf(verb) : undefined;
91
+ };
92
+
93
+ /**
94
+ * A denial whose own subject (We, You) opens the next sentence and says the denied verb again, without a denial
95
+ * (We didn't build this for speed. We built it for teams.). Another verb is the story going on (We didn't have backups. We lost the data.).
96
+ */
97
+ const echoAffirms = (sentence: Sentence, lead: LexiconEntry, next: Sentence | undefined, words: ContrastWords): boolean => {
98
+ if (next === undefined || sentence.tokens === undefined || next.tokens === undefined) return false;
99
+ if (words.leads.some((other) => entryIn(next, other))) return false;
100
+ const subject = groupOf(words.turns, ECHO).find((turn) => opensWithWord(sentence, turn) && opensWithWord(next, turn));
101
+ const denied = subject === undefined ? undefined : deniedVerb(sentence, lead);
102
+ return denied !== undefined && denied === affirmedVerb(next);
103
+ };
104
+
70
105
  const AFTER = "after";
71
106
  const DIGIT_AFTER = /^\p{Nd}/u;
72
107
  /** 数字と、続く助数詞一字(1回、2つ)。 */
@@ -94,7 +129,7 @@ const framesIn = (sentence: Sentence, frame: LexiconEntry, amounts: Lexicon): bo
94
129
  const closesWithTurn = (sentence: Sentence, words: ContrastWords): boolean => groupOf(words.turns, CLOSING).some((turn) => entryCloses(sentence, turn));
95
130
 
96
131
  const answeredBy = (lead: LexiconEntry, sentence: Sentence, next: Sentence | undefined, words: ContrastWords): boolean => {
97
- if (lead.group === ACROSS) return nextAffirms(next, words);
132
+ if (lead.group === ACROSS) return nextAffirms(next, words) || echoAffirms(sentence, lead, next, words);
98
133
  if (lead.group === CLOSING) return closesWithTurn(sentence, words);
99
134
  return turnAfter(sentence, lead, words) || nextTurns(next, words);
100
135
  };
@@ -2,7 +2,7 @@ import type { Detector, Finding, ProseDocument } from "../plugin.ts";
2
2
  import { escapeRegExp } from "../orthography.ts";
3
3
  import { formMinority } from "./form-minority.ts";
4
4
  import { proseAndTablesOf } from "../table-text.ts";
5
- import { quoteAround } from "./quote-around.ts";
5
+ import { quoteAround, sentenceQuoteAt } from "./quote-around.ts";
6
6
 
7
7
  // 一つの文書で、同じ通貨の金額を二通りに書いた所(1,000円 と ¥1,000、$20 と 20 dollars)。どちらが正しいかは決めず、少ないほうを指す。
8
8
  // 通貨の書き方、それを金額のどちら側に書くか、どの通貨か(group)は語彙表 currency-notation、桁の語は amount-multiplier が言う。
@@ -85,7 +85,7 @@ export const currencyNotation: Detector = (doc, options): Finding[] => {
85
85
  severity: "info",
86
86
  line: 0,
87
87
  column: 0,
88
- quote: quoteAround(text, odd.offset, odd.offset + odd.written.length),
88
+ quote: sentenceQuoteAt(doc.sentences, odd.offset) ?? quoteAround(text, odd.offset, odd.offset + odd.written.length),
89
89
  values: { written: odd.written.trim(), usual: usual.trim(), count, of, offset: odd.offset },
90
90
  }));
91
91
  };
@@ -267,9 +267,20 @@ const isLongName = (name: string): boolean => {
267
267
  return !LATIN.test(name) || JAPANESE.test(name) || (words.length >= MIN_NAME_WORDS && words.some((word) => UPPER_START.test(word)));
268
268
  };
269
269
 
270
- /** A conjunction that joins the run to a name before it (書面または電磁的記録(以下「書面等」)): the bracket names them all. */
271
- const joinsList = (token: Token | undefined, joiners: readonly string[]): boolean =>
272
- token !== undefined && token.pos === "CCONJ" && joiners.includes(token.surface.toLowerCase());
270
+ const CLOSING_BRACKETS = new Set([")", ")"]);
271
+ const COMMAS = new Set([",", "、", ","]);
272
+
273
+ /**
274
+ * A conjunction that joins the run to a name before it (書面または電磁的記録(以下「書面等」)): the bracket names them all.
275
+ * Right after another definition's bracket (Brookside Ltd (the "Client") and Harbour Works Ltd (the "Supplier")) it joins
276
+ * two parties, each given its own short name.
277
+ */
278
+ const joinsList = (tokens: readonly Token[], at: number, joiners: readonly string[]): boolean => {
279
+ const token = tokens[at];
280
+ if (token === undefined || token.pos !== "CCONJ" || !joiners.includes(token.surface.toLowerCase())) return false;
281
+ const before = tokens.slice(0, at).findLast((candidate) => !COMMAS.has(candidate.surface));
282
+ return before === undefined || !CLOSING_BRACKETS.has(before.surface);
283
+ };
273
284
 
274
285
  /**
275
286
  * The long name written right before an inline definition: the run of name words that ends at its opening bracket. A run
@@ -279,7 +290,7 @@ export const nameBefore = (sentence: Sentence, bracket: number, joiners: readonl
279
290
  if (LABELS_THE_CLAUSE.test(sentence.text.slice(bracket - sentence.span.start))) return undefined;
280
291
  const tokens = (sentence.tokens ?? []).filter((token) => token.span.end <= bracket);
281
292
  const firstOfRun = tokens.findLastIndex((token) => !isNamePart(token)) + 1;
282
- if (isModifier(tokens[firstOfRun - 1]) || joinsList(tokens[firstOfRun - 1], joiners)) return undefined;
293
+ if (isModifier(tokens[firstOfRun - 1]) || joinsList(tokens, firstOfRun - 1, joiners)) return undefined;
283
294
  const run = tokens.slice(firstOfRun).filter((token, index, all) => index > 0 || !NAME_MARKS.has(token.surface) || all.length === 1);
284
295
  const first = run[0];
285
296
  const end = run.at(-1);
@@ -80,14 +80,11 @@ const ownDefinitions = (tree: StructureNode): DefinedTerm[] => {
80
80
  export const useBeforeDefinition: Detector = (doc): Finding[] =>
81
81
  doc.structure === undefined
82
82
  ? []
83
- : usesBeforeDefinition(
84
- ownDefinitions(doc.structure),
85
- bodyOf(doc),
86
- mentionedIn(doc),
87
- titleIn(doc),
88
- patternsOf(doc, "self-prefix"),
89
- patternsOf(doc, "term-source-marker"),
90
- ).map((use) => findingAt(doc, use.offset, { term: use.term.term, defined: use.term.line }));
83
+ : usesBeforeDefinition(ownDefinitions(doc.structure), bodyOf(doc), mentionedIn(doc), titleIn(doc), {
84
+ selfPrefixes: patternsOf(doc, "self-prefix"),
85
+ sourceMarkers: patternsOf(doc, "term-source-marker"),
86
+ singleKanjiNames: new Set(patternsOf(doc, "party-short-name")),
87
+ }).map((use) => findingAt(doc, use.offset, { term: use.term.term, defined: use.term.line }));
91
88
 
92
89
  /** 同じ略語を、文書の中で二通りに展開している所。 */
93
90
  export const acronymExpansionConflict: Detector = (doc): Finding[] => {
@@ -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 an ellipsis two ways ("..." and "…", "……" and "・・・"). Neither is called right; the less common is
7
7
  // reported. The forms come from each language's lexicon "ellipsis".
@@ -83,7 +83,7 @@ export const ellipsisConsistency: Detector = (doc, options): Finding[] => {
83
83
  severity: "info",
84
84
  line: 0,
85
85
  column: 0,
86
- quote: quoteAround(text, ellipsis.offset, ellipsis.offset + ellipsis.form.length),
86
+ quote: sentenceQuoteAt(doc.sentences, ellipsis.offset) ?? quoteAround(text, ellipsis.offset, ellipsis.offset + ellipsis.form.length),
87
87
  values: { written: ellipsis.form, usual: minority.usual.form, count: minority.odd.length, of: ellipses.length, offset: ellipsis.offset },
88
88
  }));
89
89
  };
@@ -283,7 +283,7 @@ const nextText = (lines: readonly SourceLine[], index: number): string => {
283
283
  };
284
284
 
285
285
  /** A header field's line (From: Ann). Not any colon: a subject may hold one (Re: Lunch, 10:00 meeting, Q3: budget). */
286
- const isHeaderField = (line: string, headerFields: readonly string[]): boolean => {
286
+ export const isHeaderField = (line: string, headerFields: readonly string[]): boolean => {
287
287
  const name = fieldOf(line)?.name.toLowerCase();
288
288
  return name !== undefined && headerFields.some((field) => field.toLowerCase() === name);
289
289
  };
@@ -5,6 +5,7 @@ import { namesWrittenMidSentence } from "./heading-names.ts";
5
5
  import type { Detector, Finding, Lexicon, ProseDocument, Section, Sentence, Token } from "../plugin.ts";
6
6
  import { entryOpens } from "./lexicon-match.ts";
7
7
  import { opensWithPhrase } from "./opener-phrase.ts";
8
+ import { speakerTurns } from "./speaker-turns.ts";
8
9
 
9
10
  const PER = 1000;
10
11
 
@@ -66,27 +67,67 @@ export const beforeConcession = (tokens: readonly Token[]): readonly Token[] =>
66
67
  return at === -1 ? tokens : tokens.slice(0, at);
67
68
  };
68
69
 
70
+ /** The words a be can follow in the same verb: a modal (There will be), a perfect's have (There have been), a negation (There has never been). */
71
+ const BEFORE_BE = new Set([
72
+ "will",
73
+ "would",
74
+ "may",
75
+ "might",
76
+ "can",
77
+ "could",
78
+ "should",
79
+ "must",
80
+ "shall",
81
+ "'ll",
82
+ "wo",
83
+ "ca",
84
+ "has",
85
+ "have",
86
+ "had",
87
+ "'ve",
88
+ "'d",
89
+ "not",
90
+ "n't",
91
+ "never",
92
+ ]);
93
+
94
+ /** The be of the verb right after head, past the modal, have and negation before it: There were / There have been / There will not be. */
95
+ const beAfter = (tokens: readonly Token[], head: Token): Token | undefined => {
96
+ const words = tokens.filter((token) => token.span.start >= head.span.end && token.pos !== "PUNCT");
97
+ const at = words.findIndex((token) => !BEFORE_BE.has(token.surface.toLowerCase()));
98
+ const verb = words[at];
99
+ return verb !== undefined && BE.has(verb.lemma ?? verb.surface.toLowerCase()) ? verb : undefined;
100
+ };
101
+
69
102
  /**
70
103
  * There is / It is ... that は、主語を後ろへ押しやって誰が何をするのかを消す。
71
104
  * 「There is a need to review」は、誰が必要としているのかを言っていない。
72
105
  */
73
- const expletiveAt = (tokens: readonly Token[]): Token | undefined => {
106
+ /** The sentence's opening, from There / It through its be: the finding names the form this sentence uses (There were, It was). */
107
+ type Opening = { readonly head: Token; readonly be: Token };
108
+
109
+ const expletiveAt = (tokens: readonly Token[]): Opening | undefined => {
74
110
  const head = tokens.find((token) => token.pos !== "PUNCT");
75
111
  if (head === undefined) return undefined;
76
112
  const lead = head.surface.toLowerCase();
77
113
  if (lead !== "there" && lead !== "it") return undefined;
78
- const next = tokens.find((token) => token.span.start >= head.span.end && token.pos !== "PUNCT");
79
- if (next === undefined || !BE.has(next.lemma ?? next.surface.toLowerCase())) return undefined;
114
+ const be = beAfter(tokens, head);
115
+ if (be === undefined) return undefined;
80
116
  // "it is" は "it is raining" のような正当な用法があるので、that 節を伴うときだけ数える。
81
117
  if (lead === "it" && !beforeConcession(tokens).some((token) => token.surface.toLowerCase() === "that")) return undefined;
82
- return head;
118
+ return { head, be };
83
119
  };
84
120
 
121
+ /** In minutes of who said what, a speaker's sentences are their own phrasing, recorded as said: not the writer's to recast. */
85
122
  export const expletive: Detector = (doc, options): Finding[] => {
86
- const hits = doc.sentences.flatMap((sentence) => {
87
- const at = expletiveAt(sentence.tokens ?? []);
88
- return at === undefined ? [] : [{ sentence, at }];
89
- });
123
+ const turns = speakerTurns(doc.source);
124
+ const spoken = (sentence: Sentence): boolean => turns.some((turn) => turn.start <= sentence.span.start && sentence.span.start < turn.end);
125
+ const hits = doc.sentences
126
+ .filter((sentence) => !spoken(sentence))
127
+ .flatMap((sentence) => {
128
+ const at = expletiveAt(sentence.tokens ?? []);
129
+ return at === undefined ? [] : [{ sentence, at }];
130
+ });
90
131
  if (hits.length <= options.limit) return [];
91
132
  return hits.map(({ sentence, at }) => ({
92
133
  rule: "expletive-construction",
@@ -94,7 +135,7 @@ export const expletive: Detector = (doc, options): Finding[] => {
94
135
  line: 0,
95
136
  column: 0,
96
137
  quote: sentence.text.trim(),
97
- values: { word: at.surface, count: hits.length, limit: options.limit, offset: at.span.start },
138
+ values: { form: doc.source.slice(at.head.span.start, at.be.span.end), count: hits.length, limit: options.limit, offset: at.head.span.start },
98
139
  }));
99
140
  };
100
141
 
@@ -138,6 +138,14 @@ const JA_PART_REFERENCE = /[表図][\d0-9]+(?:[--..][\d0-9]+)*|第[\
138
138
  export const partReferenceSpans = (text: string, unit: LengthUnit): Span[] =>
139
139
  unit === "word" ? spansOf(text, LABEL_AND_NUMBER, (match) => PART_LABELS.has((match[1] ?? "").toLowerCase())) : spansOf(text, JA_PART_REFERENCE, () => true);
140
140
 
141
+ /**
142
+ * 日本語の、数を入れた短い括弧の注((前期比99.6%)、(同101.6%)、(前期は営業損失3,887千円))の範囲。報告は数ごとに比べた数を括弧で
143
+ * 添え、同じ結び(〜となりました。)で閉じる。中身は数で、注に触れる語句は数を並べる書式。長い注は書き手の文なので外さない。
144
+ */
145
+ const JA_FIGURE_ASIDE = /[((][^()()\n]{0,20}[\d0-9][^()()\n]{0,20}[))]/gu;
146
+
147
+ export const figureAsideSpans = (text: string, unit: LengthUnit): Span[] => (unit === "char" ? spansOf(text, JA_FIGURE_ASIDE, () => true) : []);
148
+
141
149
  /**
142
150
  * 角括弧でくくった画面の部品の名前([許可]、[ブックマーク]、[内容を確認]リンク)と、それに付く助詞一つの範囲。画面の手引きは手順ごとに
143
151
  * 違う部品を指して同じ形で書く([…]をクリックすると)。名前にかかる語句と同じく、部品の名前に付いた所からの語句は数えない。
@@ -4,6 +4,7 @@ import { compacted, linkedIn, placeAt } from "./gram-place.ts";
4
4
  import { charWindows, wordWindows } from "./gram-windows.ts";
5
5
  import {
6
6
  fieldLabelSpans,
7
+ figureAsideSpans,
7
8
  fixedEndingSpans,
8
9
  furnitureMask,
9
10
  isFurniture,
@@ -84,7 +85,13 @@ type Context = {
84
85
  /** 数えない範囲: 名前(触れる窓を外す)と、飾り(過半を覆う窓を外す)。 */
85
86
  const excludedIn = (context: Context, sentence: Sentence, text: string, source: ReturnType<typeof compacted>): { named: Span[]; mask: boolean[] } => {
86
87
  const unit = context.doc.lengthUnit;
87
- const named = [...nameSpans(text, context.names), ...fieldLabelSpans(text, unit), ...partReferenceSpans(text, unit), ...screenLabelSpans(text, unit)];
88
+ const named = [
89
+ ...nameSpans(text, context.names),
90
+ ...fieldLabelSpans(text, unit),
91
+ ...partReferenceSpans(text, unit),
92
+ ...figureAsideSpans(text, unit),
93
+ ...screenLabelSpans(text, unit),
94
+ ];
88
95
  const linked = linkedIn(context.doc, sentence, source);
89
96
  const mask = furnitureMask(text, linked);
90
97
  [...fixedEndingSpans(text, context.endings), ...quotedSpans(text), ...quotedClosingSpans(text, context.closings, linked)].forEach((span) =>
@@ -36,9 +36,17 @@ const TITLE_DEPTH = 1;
36
36
 
37
37
  /**
38
38
  * 見出しの頭の番号の札(Section 3. / Day 1: / Part II:)。札の語は流儀によらず大文字で始まり、続く題の語数にも数えない。
39
- * 番号は 3 桁までで、後ろに「.」「:」「)」か ダッシュがあるものだけ(Windows 11 Setup も Budget 2026: も札ではない)。
39
+ * 番号は 3 桁までで、後ろに「.」「:」「)」か ダッシュ、または括弧に入れた題(Rule 1 (Labels))があるものだけ(Windows 11 Setup も Budget 2026: も札ではない)。
40
40
  */
41
- const LEADING_LABEL = /^\s*\p{Lu}\p{Ll}+\s+(?:\d{1,3}(?:\.\d{1,3})*|[IVXLC]+)\s*[.:)\-\u2013\u2014]\s+/u;
41
+ const LABEL_HEAD = /^\s*\p{Lu}\p{Ll}+\s+(?:\d{1,3}(?:\.\d{1,3})*|[IVXLC]+)/u;
42
+ /** What closes the label: a mark and a space, or a space before a bracketed title. */
43
+ const LABEL_END = /^(?:\s*[.:)\-\u2013\u2014]\s+|\s+(?=\())/u;
44
+
45
+ export const withoutLeadingLabel = (heading: string): string => {
46
+ const head = LABEL_HEAD.exec(heading)?.[0];
47
+ const end = head === undefined ? undefined : LABEL_END.exec(heading.slice(head.length))?.[0];
48
+ return head === undefined || end === undefined ? heading : heading.slice(head.length + end.length);
49
+ };
42
50
 
43
51
  /**
44
52
  * 見出しの頭の字や小さいローマ数字の札(a. / b) / iv. / (c))。札は流儀によらず小文字か大文字のまま書くので、語に数えない。
@@ -51,7 +59,7 @@ const LETTER_LABEL = /^\s*\(?(?:[A-Za-z]|[ivxlc]{2,6}|[IVXLC]{2,6})[.)]\s+/u;
51
59
  * どちらの流儀の証拠にもならないので数えない。
52
60
  */
53
61
  export const isTitleCase = (heading: string, fixedCase: ReadonlySet<string> = new Set()): boolean | undefined => {
54
- const words = [...withoutCodeWords(straightApostrophes(heading.replace(LEADING_LABEL, "").replace(LETTER_LABEL, ""))).matchAll(WORD)]
62
+ const words = [...withoutCodeWords(straightApostrophes(withoutLeadingLabel(heading).replace(LETTER_LABEL, ""))).matchAll(WORD)]
55
63
  .map((match) => match[0])
56
64
  .filter((word) => !MINOR_WORDS.has(word.toLowerCase()) && !ACRONYM.test(word) && !fixedCase.has(word));
57
65
  // 1 語の見出しは、どちらの流儀でも先頭が大文字になる。判定できない。
@@ -1,4 +1,5 @@
1
1
  import type { Span, Token } from "../plugin.ts";
2
+ import { quotedSpans } from "../quoted-span.ts";
2
3
 
3
4
  /** 頭から外す語と、文書全体の座標でのその範囲。 */
4
5
  export type Edge = { readonly surface: string; readonly span: Span };
@@ -15,6 +16,20 @@ const KANJI_OR_HIRAGANA = /[一-鿿ぁ-ゖ]/u;
15
16
  export const holdsName = (text: string, span: Span, start: number, end: number): boolean =>
16
17
  span.start <= start && end <= span.end && !KANJI_OR_HIRAGANA.test(text.slice(span.start, start) + text.slice(end, span.end));
17
18
 
19
+ const HIRAGANA_HEAD = /^\s*[ぁ-ゖ]/u;
20
+
21
+ /**
22
+ * 漢字の連なり [start, end) が、一行を漢字も平仮名も無い語(ダイヤル)とだけで埋め、その下に行が続くか。
23
+ * 番号や内容の上に置いた名前の行(児童相談所虐待対応ダイヤル / 189)。下の行が平仮名で始まれば、折り返した文の途中。
24
+ */
25
+ export const labelsLines = (text: string, start: number, end: number): boolean => {
26
+ const lineStart = text.lastIndexOf("\n", start - 1) + 1;
27
+ const lineEnd = text.indexOf("\n", end);
28
+ if (start >= end || lineEnd < 0) return false;
29
+ const below = text.slice(lineEnd + 1);
30
+ return below.trim() !== "" && !HIRAGANA_HEAD.test(below) && holdsName(text, { start: lineStart, end: lineEnd }, start, end);
31
+ };
32
+
18
33
  /** 連なりの前(before: 文の頭から連なりまで)が、空白を挟んだ法人格で終わるか(一般社団法人 全国銀行個人信用情報センター)。 */
19
34
  export const followsForm = (before: string, forms: readonly string[]): boolean => {
20
35
  const trimmed = before.trimEnd();
@@ -108,3 +123,15 @@ export const trailingConjunction = (tokens: readonly Token[], start: number, end
108
123
  if (token === undefined || token.pos !== "CCONJ" || token.span.start <= start) return undefined;
109
124
  return { surface: run.slice(run.length - (end - token.span.start)), start: token.span.start };
110
125
  };
126
+
127
+ /** 丸括弧の補い。 */
128
+ const GLOSS_MARKS = { "(": ")", "(": ")" };
129
+ /** 補いの括弧のすぐ前に立つ、語の字(修士の学位(…)の「位」、EBITDA+(…)の「+」)。 */
130
+ const GLOSSED_WORD_END = /[\p{Script=Han}\p{Script=Katakana}\p{Script=Latin}\p{N}ー++]$/u;
131
+
132
+ /**
133
+ * 語のすぐ後ろの丸括弧の中身が、この連なりだけか(EBITDA+(減価償却他調整前営業利益)、修士の学位(大学院修士課程修了程度))。
134
+ * 前の語の言い換えや展開で、書き手が 1 つの名前として示したもの。
135
+ */
136
+ export const fillsGloss = (text: string, start: number, end: number): boolean =>
137
+ quotedSpans(text, GLOSS_MARKS).some((span) => GLOSSED_WORD_END.test(text.slice(0, span.start - 1)) && holdsName(text, span, start, end));
@@ -175,16 +175,40 @@ export const isCitation = (sentence: Sentence, source: string): boolean =>
175
175
 
176
176
  type Tally = { readonly count: number; readonly of: number; readonly limit: number };
177
177
 
178
- const findingOf = (sentence: Sentence, entry: Mark, kind: Kind, tally: Tally): Finding => ({
178
+ /** 少ないほうの書き方の一つの印と、その種類の文書の中の数。 */
179
+ type Odd = { readonly sentence: Sentence; readonly entry: Mark; readonly kind: Kind; readonly tally: Tally };
180
+
181
+ const usualOf = (odd: Odd): string => (odd.entry.western ? odd.kind.usual : odd.kind.western);
182
+
183
+ /** 一つの種類の印。同じ文に同じ書き方が二つあっても、書き方は一つずつ並べる(「,」)。 */
184
+ const markOf = (odds: readonly Odd[]): string => [...new Set(odds.map((odd) => odd.entry.mark))].join("」「");
185
+
186
+ const sentenceFinding = (sentence: Sentence, values: Finding["values"], variant: string): Finding => ({
179
187
  rule: "",
180
188
  severity: "warning",
181
189
  line: 0,
182
190
  column: 0,
183
191
  quote: sentence.text.trim(),
184
- values: { mark: entry.mark, usual: entry.western ? kind.usual : kind.western, ...tally, offset: entry.offset },
185
- variant: entry.kind,
192
+ values,
193
+ variant,
186
194
  });
187
195
 
196
+ /** 一つの文の少ないほうの印。読点と句点の両方なら、一件で両方を言う(貼り付けた文が一つの書き違い)。 */
197
+ const findingOf = (sentence: Sentence, odds: readonly Odd[]): Finding[] => {
198
+ const commas = odds.filter((odd) => odd.kind.id === "comma");
199
+ const periods = odds.filter((odd) => odd.kind.id === "period");
200
+ const [first] = odds;
201
+ const [comma] = commas;
202
+ const [period] = periods;
203
+ if (first === undefined) return [];
204
+ const offset = first.entry.offset;
205
+ if (comma === undefined || period === undefined) {
206
+ return [sentenceFinding(sentence, { mark: markOf(odds), usual: usualOf(first), ...first.tally, offset }, first.kind.id)];
207
+ }
208
+ const periodValues = { periodMark: markOf(periods), periodUsual: usualOf(period), periodCount: period.tally.count, periodOf: period.tally.of };
209
+ return [sentenceFinding(sentence, { mark: markOf(commas), usual: usualOf(comma), ...comma.tally, ...periodValues, offset }, "both")];
210
+ };
211
+
188
212
  const exceptionsOf = (doc: ProseDocument): MarkExceptions => {
189
213
  const patterns = (name: string): string[] => (doc.lexicons[name] ?? []).map((entry) => entry.pattern);
190
214
  return {
@@ -202,13 +226,20 @@ export const kutotenConsistency: Detector = (doc, options): Finding[] => {
202
226
  const located = doc.sentences
203
227
  .filter((sentence) => !isCitation(sentence, doc.source))
204
228
  .flatMap((sentence) => marksIn(sentence, doc.source, exceptions).map((entry) => ({ sentence, entry })));
205
- return KINDS.flatMap((kind) => {
229
+ const odds = KINDS.flatMap((kind): Odd[] => {
206
230
  const ofKind = located.filter(({ entry }) => entry.kind === kind.id);
207
231
  const minority = minorityOf(ofKind.map(({ entry }) => entry.western));
208
232
  if (minority === undefined) return [];
209
233
  const odd = ofKind.filter(({ entry }) => entry.western === minority);
210
234
  if (odd.length < options.limit) return [];
211
235
  const tally = { count: odd.length, of: ofKind.length, limit: options.limit };
212
- return odd.map(({ sentence, entry }) => findingOf(sentence, entry, kind, tally));
213
- });
236
+ return odd.map(({ sentence, entry }) => ({ sentence, entry, kind, tally }));
237
+ }).toSorted((left, right) => left.entry.offset - right.entry.offset);
238
+ const sentences = [...new Set(odds.map((odd) => odd.sentence))];
239
+ return sentences.flatMap((sentence) =>
240
+ findingOf(
241
+ sentence,
242
+ odds.filter((odd) => odd.sentence === sentence),
243
+ ),
244
+ );
214
245
  };