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
@@ -9,13 +9,16 @@ const INFLECTING = new Set(["VERB", "AUX"]);
9
9
  * 語彙表が原形で書いた語(いただく)だけが、活用した形(いただきます・いただいた)に当たる。
10
10
  * 活用した形で書いた語(could・かもしれません)はその形だけ。"could" は "can" と言っていることが違う。
11
11
  */
12
- const sameWord = (written: Token, entry: Token): boolean => {
12
+ const sameWord = (written: Token, entry: Token, headsPhrase: boolean): boolean => {
13
13
  const surface = entry.surface.toLowerCase();
14
14
  if (written.surface.toLowerCase() === surface) return true;
15
- const inflects = INFLECTING.has(written.pos) && INFLECTING.has(entry.pos);
15
+ const inflects = INFLECTING.has(written.pos) && (INFLECTING.has(entry.pos) || (headsPhrase && entry.pos === "NOUN"));
16
16
  return inflects && entry.lemma?.toLowerCase() === surface && written.lemma?.toLowerCase() === surface;
17
17
  };
18
18
 
19
+ /** A phrase read on its own has no subject, so its head verb is often tagged a noun ("move the needle", "conduct an analysis"). */
20
+ const headsPhrase = (entry: readonly Token[], offset: number): boolean => offset === 0 && entry.length > 1;
21
+
19
22
  /** 品詞が無いときに照らす形。大文字小文字と、アポストロフィの形(it’s と it's)は語を変えない。 */
20
23
  export const comparableWords = (text: string): string => straightApostrophes(text).toLowerCase();
21
24
 
@@ -25,7 +28,7 @@ export const comparableText = (sentence: Sentence): string => comparableWords(pr
25
28
  const runsAt = (tokens: readonly Token[], entry: readonly Token[], start: number): boolean =>
26
29
  entry.every((word, offset) => {
27
30
  const written = tokens[start + offset];
28
- return written !== undefined && sameWord(written, word);
31
+ return written !== undefined && sameWord(written, word, headsPhrase(entry, offset));
29
32
  });
30
33
 
31
34
  /**
@@ -39,6 +42,17 @@ export const entryIn = (sentence: Sentence, entry: LexiconEntry): boolean => {
39
42
  return tokens.some((_token, start) => runsAt(tokens, words, start));
40
43
  };
41
44
 
45
+ const writtenAsIs = (tokens: readonly Token[], entry: readonly Token[], start: number): boolean =>
46
+ entry.every((word, offset) => tokens[start + offset]?.surface.toLowerCase() === word.surface.toLowerCase());
47
+
48
+ /** Whether the lexicon's words stand in the sentence in the very form the lexicon writes them ("reverted back", not "revert back"). */
49
+ export const entryWrittenIn = (sentence: Sentence, entry: LexiconEntry): boolean => {
50
+ const tokens = sentence.tokens;
51
+ const words = entry.tokens;
52
+ if (tokens === undefined || words === undefined || words.length === 0) return entryIn(sentence, entry);
53
+ return tokens.some((_token, start) => writtenAsIs(tokens, words, start));
54
+ };
55
+
42
56
  export type TokenRange = { readonly start: number; readonly end: number };
43
57
 
44
58
  /** 語彙の語が文のどの語の並びに当たったか(始まりと、終わった次の位置)。品詞が無ければ位置を言えないので空。 */
@@ -22,10 +22,16 @@ const FLOOR = { word: 200, char: 500 };
22
22
 
23
23
  type Hit = { readonly sentence: Sentence; readonly matched: string; readonly group?: string | undefined };
24
24
 
25
- const hitsFor = (doc: ProseDocument, lexicon: Lexicon): Hit[] =>
26
- doc.sentences.flatMap((sentence) =>
27
- lexicon.filter((entry) => entryIn(sentence, entry)).map((entry) => ({ sentence, matched: entry.pattern, group: entry.group })),
28
- );
25
+ /** 後ろの語を導く語(まるで)。同じ文にほかの語が当たれば、それと合わせて一つ(まるで魔法のように)と数える。 */
26
+ const OPENER_GROUP = "opener";
27
+
28
+ const sentenceHits = (sentence: Sentence, lexicon: Lexicon): Hit[] => {
29
+ const hits = lexicon.filter((entry) => entryIn(sentence, entry)).map((entry) => ({ sentence, matched: entry.pattern, group: entry.group }));
30
+ const closed = hits.some((hit) => hit.group !== OPENER_GROUP);
31
+ return closed ? hits.filter((hit) => hit.group !== OPENER_GROUP) : hits;
32
+ };
33
+
34
+ const hitsFor = (doc: ProseDocument, lexicon: Lexicon): Hit[] => doc.sentences.flatMap((sentence) => sentenceHits(sentence, lexicon));
29
35
 
30
36
  /**
31
37
  * A lexicon word in group address says how the document speaks to its reader (あなたの). Alone it is the writer's chosen
@@ -0,0 +1,9 @@
1
+ import type { Token } from "../plugin.ts";
2
+ import { isFiniteVerb } from "./list-item-phrase.ts";
3
+
4
+ /** Words opening with a subject pronoun and its finite verb (you will also need a change of clothes): a sentence, closed or not. */
5
+ export const opensWithClause = (words: readonly Token[], isSubject: (token: Token) => boolean): boolean => {
6
+ const [subject, ...rest] = words;
7
+ const verb = rest.find((token) => token.pos !== "ADV");
8
+ return subject !== undefined && verb !== undefined && isSubject(subject) && isFiniteVerb(verb);
9
+ };
@@ -8,6 +8,7 @@ import type { BulletList, Detector, Finding, ProseDocument, Sentence, Span, Toke
8
8
  import { isLinkLabel } from "./link-label.ts";
9
9
  import { itemLayout, splitAtLeadIns } from "./list-layout.ts";
10
10
  import { closesAsSentence, isFiniteVerb, isNounPhraseWithVerbs, isPastForm, isVerb, NOMINAL, NOUN_HEAD, opensObject } from "./list-item-phrase.ts";
11
+ import { opensWithClause } from "./list-item-clause.ts";
11
12
 
12
13
  /** What an item is made of: a phrase or a sentence (ending), and the word it opens with (head, English only). */
13
14
  export type Axis = "ending" | "head";
@@ -113,7 +114,7 @@ const japaneseEnding = (item: readonly Sentence[], headlineEndings: ReadonlySet<
113
114
  * English: a sentence closes with a full stop and has a finite verb outside a noun phrase; a phrase has neither, nor any
114
115
  * verb but those of its noun phrase. Anything between is not judged.
115
116
  */
116
- const englishEnding = (item: readonly Sentence[]): string | undefined => {
117
+ const englishEnding = (item: readonly Sentence[], context: HeadContext): string | undefined => {
117
118
  const sentences = ownEnding(item);
118
119
  const tokens = sentences.flatMap((sentence) => sentence.tokens ?? []);
119
120
  if (tokens.length === 0) return undefined;
@@ -122,6 +123,8 @@ const englishEnding = (item: readonly Sentence[]): string | undefined => {
122
123
  // A noun phrase with a stray full stop (Shelter – a charity who offer advice.) says nothing: neither form.
123
124
  const nounPhrase = isNounPhraseWithVerbs(tokens);
124
125
  if (closed) return tokens.some(isFiniteVerb) && !nounPhrase ? "sentence" : undefined;
126
+ const words = tokens.filter((token) => !SKIPPED_AT_END.has(token.pos));
127
+ if (opensWithClause(words, (token) => isSubjectPronoun(token, context))) return "sentence";
125
128
  return (nounPhrase || !tokens.some(isVerb)) && !isUnsure(tokens[0]) ? "phrase" : undefined;
126
129
  };
127
130
 
@@ -316,7 +319,7 @@ const leadsIn = (sentences: readonly Sentence[]): boolean => LEAD_IN.test(senten
316
319
  export const formOf = (axis: Axis, sentences: readonly Sentence[], language: string, context: HeadContext = NO_HEAD_CONTEXT): string | undefined => {
317
320
  if (axis === "ending" && leadsIn(sentences)) return undefined;
318
321
  if (language === "ja") return axis === "ending" ? japaneseEnding(sentences, context.headlineEndings) : undefined;
319
- return axis === "ending" ? englishEnding(sentences) : englishHead(sentences, context);
322
+ return axis === "ending" ? englishEnding(sentences, context) : englishHead(sentences, context);
320
323
  };
321
324
 
322
325
  const within = (inner: Span, outer: Span): boolean => inner.start >= outer.start && inner.end <= outer.end;
@@ -28,6 +28,8 @@ export type ListWords = {
28
28
  readonly elision?: readonly string[];
29
29
  /** 並びの残りを言う語(so forth / the like)。and so forth の前まで並びが続く。 */
30
30
  readonly openListEnd?: ReadonlySet<string>;
31
+ /** 読点で挟んで名前に添える関係節を始める語(who / which)。Tom, who repaired radios, opened … の節は並びの項目ではない。 */
32
+ readonly asideRelative?: ReadonlySet<string>;
31
33
  };
32
34
 
33
35
  const LIST_CONJUNCTION: ReadonlySet<string> = new Set(["and", "or"]);
@@ -82,15 +82,36 @@ const sidedFinding = (item: Sided, values: Finding["values"], variant?: string):
82
82
  values: { ...values, offset: item.offset },
83
83
  });
84
84
 
85
- /** The less common way, one finding each, or one finding for a document written both ways (spacing-minority.ts). */
86
- const minorityFindings = <T extends Sided>(items: readonly T[], limit: number, valuesOf: (item: T) => Finding["values"]): Finding[] => {
85
+ /** The odd items, each its own slip, or with the one before it when joins says they are one slip. */
86
+ const slipsOf = <T>(odd: readonly T[], joins: (previous: T, item: T) => boolean): T[][] =>
87
+ odd.reduce<T[][]>((slips, item) => {
88
+ const last = slips.at(-1);
89
+ const previous = last?.at(-1);
90
+ if (last !== undefined && previous !== undefined && last.length === 1 && joins(previous, item)) last.push(item);
91
+ else slips.push([item]);
92
+ return slips;
93
+ }, []);
94
+
95
+ /**
96
+ * The less common way, one finding per slip, or one finding for a document written both ways (spacing-minority.ts). The
97
+ * counts stay in items: a slip of two items is two of the places that differ.
98
+ */
99
+ const minorityFindings = <T extends Sided>(
100
+ items: readonly T[],
101
+ limit: number,
102
+ valuesOf: (slip: readonly T[]) => Finding["values"],
103
+ joins: (previous: T, item: T) => boolean = () => false,
104
+ ): Finding[] => {
87
105
  const report = minorityReport(items, limit);
88
106
  if (report === undefined) return [];
89
107
  if (report.mode === "mixed") {
90
108
  const { first, odd, spaced, touching } = report;
91
- return [sidedFinding(first, { ...valuesOf(first), spaced, touching, count: odd, of: items.length, limit }, "mixed")];
109
+ return [sidedFinding(first, { ...valuesOf([first]), spaced, touching, count: odd, of: items.length, limit }, "mixed")];
92
110
  }
93
- return report.odd.map((item) => sidedFinding(item, { ...valuesOf(item), count: report.odd.length, of: items.length, limit }));
111
+ return slipsOf(report.odd, joins).flatMap((slip) => {
112
+ const first = slip[0];
113
+ return first === undefined ? [] : [sidedFinding(first, { ...valuesOf(slip), count: report.odd.length, of: items.length, limit })];
114
+ });
94
115
  };
95
116
 
96
117
  /** Sentences written in the document's own language; a quoted sentence in another language follows its own marks. */
@@ -203,6 +224,12 @@ const withNoteAddressKind = (mark: Mark, addresses: ReadonlySet<number>): Mark =
203
224
  const withNoteKind = (mark: Mark, notes: ReadonlySet<number>): Mark =>
204
225
  notes.has(mark.offset) && !mark.form.kind.endsWith(ENUMERATOR_KIND) ? { ...mark, form: { ...mark.form, kind: `${mark.form.kind}${NOTE_KIND}` } } : mark;
205
226
 
227
+ /** A closing bracket of the same width right after its opening one, with no bracket between (資料(案)): one slip, not two. */
228
+ const closesPair = (source: string, opening: Mark, closing: Mark): boolean =>
229
+ opening.sentence === closing.sentence &&
230
+ CLOSER_OF[opening.char] === closing.char &&
231
+ !/[()()[\][]]/u.test(source.slice(opening.offset + 1, closing.offset));
232
+
206
233
  /**
207
234
  * A mark written two ways in one document (( and (, “ and "), the less common way reported. The two ways come from the
208
235
  * lexicon; neither is called right. Only marks next to a letter of the document's script count, so a bracket in code-like
@@ -229,7 +256,8 @@ export const markConsistency: Detector = (doc, options): Finding[] => {
229
256
  minorityFindings(
230
257
  marks.filter((mark) => mark.form.kind === kind && !isWithinAny(titles, { start: mark.offset, end: mark.offset + 1 })),
231
258
  options.limit,
232
- (mark) => ({ mark: mark.char, usual: mark.form.other }),
259
+ (slip) => ({ mark: slip.map((mark) => mark.char).join(""), usual: slip.map((mark) => mark.form.other).join("") }),
260
+ (opening, closing) => closesPair(doc.source, opening, closing),
233
261
  ),
234
262
  );
235
263
  };
@@ -263,9 +291,9 @@ export const sentenceGaps = (doc: ProseDocument): Sided[] => {
263
291
 
264
292
  /** One space between sentences and two, mixed in one document: the less common is reported. */
265
293
  export const sentenceSpacing: Detector = (doc, options): Finding[] =>
266
- minorityFindings(sentenceGaps(doc), options.limit, (gap) => ({
267
- spaces: gap.spaced ? TWO_SPACES.length : ONE_SPACE.length,
268
- usual: gap.spaced ? ONE_SPACE.length : TWO_SPACES.length,
294
+ minorityFindings(sentenceGaps(doc), options.limit, ([gap]) => ({
295
+ spaces: gap?.spaced === true ? TWO_SPACES.length : ONE_SPACE.length,
296
+ usual: gap?.spaced === true ? ONE_SPACE.length : TWO_SPACES.length,
269
297
  }));
270
298
 
271
299
  type Hit = { readonly sentence: Sentence; readonly matched: string; readonly offset: number };
@@ -1,6 +1,7 @@
1
1
  import type { Detector, Finding, LexiconEntry, Paragraph, ProseDocument, Token } from "../plugin.ts";
2
2
  import { formMinority } from "./form-minority.ts";
3
3
  import { captionParagraphs, slotParagraphs } from "./final-period-captions.ts";
4
+ import { isHeaderField } from "./email-letter.ts";
4
5
 
5
6
  // A paragraph whose last sentence stops without its closing mark, in a document whose other paragraphs end with one. It
6
7
  // takes no side: a document that ends none of its paragraphs with the mark (slides, labels) is not reported. The marks
@@ -113,16 +114,25 @@ const marksOf = (lexicon: readonly LexiconEntry[]): PeriodMarks => ({
113
114
  labels: lexicon.filter((entry) => entry.group === "label").map((entry) => entry.pattern),
114
115
  });
115
116
 
117
+ /** A paragraph of one line opened by a header field (件名:…, Subject: …): a label and its value, not a sentence. Read from the source line, since the paragraph may start past the label. */
118
+ const isFieldLine = (source: string, paragraph: Paragraph, fields: readonly string[]): boolean => {
119
+ const line = source.slice(source.lastIndexOf("\n", paragraph.span.start - 1) + 1, paragraph.span.end).trim();
120
+ return !line.includes("\n") && isHeaderField(line, fields);
121
+ };
122
+
116
123
  export const missingFinalPeriod: Detector = (doc: ProseDocument, options): Finding[] => {
117
124
  const text = doc.prose ?? doc.source;
118
125
  const marks = marksOf(doc.lexicons["final-period"] ?? []);
126
+ const fields = (doc.lexicons["email-header-field"] ?? []).map((entry) => entry.pattern);
119
127
  const captions = captionParagraphs(
120
128
  text,
121
129
  doc.sections,
122
130
  slotParagraphs(text, doc.paragraphs, (line) => isClosed(line, marks.ends)),
123
131
  );
124
132
  const ends = doc.paragraphs.flatMap((paragraph, index) =>
125
- captions.has(index) ? [] : (paragraphEnd(text, paragraph, marks, doc.paragraphs[index + 1], doc.paragraphs[index - 1]) ?? []),
133
+ captions.has(index) || isFieldLine(doc.source, paragraph, fields)
134
+ ? []
135
+ : (paragraphEnd(text, paragraph, marks, doc.paragraphs[index + 1], doc.paragraphs[index - 1]) ?? []),
126
136
  );
127
137
  const minority = formMinority(ends, options.limit);
128
138
  if (minority === undefined || minority.usual.form !== "closed") return [];
@@ -3,10 +3,12 @@ import { escapeRegExp } from "../orthography.ts";
3
3
  import { isKnownWord, type Speller } from "../spelling.ts";
4
4
  import {
5
5
  isAcronymPair,
6
+ isAfterCountArticle,
6
7
  isContractionPair,
7
8
  isInFileName,
8
9
  isInverseOrder,
9
10
  isListedPair,
11
+ isMarkedWrong,
10
12
  isNameAndWord,
11
13
  isOtherEnding,
12
14
  type WordEnding,
@@ -90,6 +92,19 @@ type Reading = {
90
92
  readonly tokenAt: ReadonlyMap<number, Token>;
91
93
  readonly speller: Speller | undefined;
92
94
  readonly ordinary: ReadonlySet<string>;
95
+ readonly countArticles: readonly string[];
96
+ readonly wrongMarks: readonly string[];
97
+ };
98
+
99
+ /** Where a form is written, as written, inside a longer run of letters too (RSpecで). */
100
+ const placesOf = (text: string, surface: string): number[] =>
101
+ surface === "" ? [] : [...text.matchAll(new RegExp(escapeRegExp(surface), "gu"))].map((found) => found.index ?? 0);
102
+
103
+ /** Whether one side of the pair is shown as wrong on purpose: the pointed form, or every place the usual form is written, after a wrong mark (× Rspec / ○ RSpec). */
104
+ const isShownWrong = (reading: Reading, found: Found): boolean => {
105
+ const isMarked = (offset: number): boolean => isMarkedWrong(reading.text, offset, reading.wrongMarks);
106
+ const usualPlaces = placesOf(reading.text, found.usual);
107
+ return isMarked(found.offset) || (usualPlaces.length > 0 && usualPlaces.every(isMarked));
93
108
  };
94
109
 
95
110
  const inOneSentence = (sentences: readonly Span[], offset: number, other: number): boolean =>
@@ -98,8 +113,8 @@ const inOneSentence = (sentences: readonly Span[], offset: number, other: number
98
113
  /**
99
114
  * A one-letter variant (near) that is two names: another form of the word (Texan), the usual form in the same sentence
100
115
  * (Constantinus and Constantius, two sons), the differing word written twice or more (Bandle, of Richard Bandle and
101
- * Mrs. Bandle), a word the document also writes in small letters (Stain, Vigil), two plural acronyms (SBLCs, SBDCs), or a
102
- * word capitalised by its place (Sprang).
116
+ * Mrs. Bandle), a word the document also writes in small letters (Stain, Vigil), two plural acronyms (SBLCs, SBDCs), a
117
+ * dictionary word after a or an (A Coiner), or a word capitalised by its place (Sprang).
103
118
  */
104
119
  const isNearPair = (reading: Reading, found: Found): boolean => {
105
120
  const word = differingWord(found.name, found.usual);
@@ -109,6 +124,13 @@ const isNearPair = (reading: Reading, found: Found): boolean => {
109
124
  (word !== undefined && offsetsOf(reading.text, word).length >= 2) ||
110
125
  isNameAndWord(found.name, found.usual, reading.text, (word) => reading.speller !== undefined && isKnownWord(word, reading.speller)) ||
111
126
  isAcronymPair(found.name, found.usual) ||
127
+ isAfterCountArticle(
128
+ reading.text,
129
+ found.offset,
130
+ found.name,
131
+ reading.countArticles,
132
+ (word) => reading.speller !== undefined && isKnownWord(word, reading.speller),
133
+ ) ||
112
134
  isCapitalisedByPlace(found, reading.text, reading.sentenceStarts, reading.speller, reading.ordinary)
113
135
  );
114
136
  };
@@ -116,7 +138,7 @@ const isNearPair = (reading: Reading, found: Found): boolean => {
116
138
  /**
117
139
  * The finding is not two forms of one name: a one-letter variant that is two names (isNearPair), ・ listing two words, a
118
140
  * direction and its inverse, a title quoted in capitals, a contraction printed with and without its apostrophe, a piece of
119
- * a file name or URL, a verb stem. ordinary holds the words read as names that are
141
+ * a file name or URL, a form shown as wrong on purpose, a verb stem. ordinary holds the words read as names that are
120
142
  * ordinary words in small letters (name-ordinary-word.ts).
121
143
  */
122
144
  export const twoThingsIn = (
@@ -135,6 +157,8 @@ export const twoThingsIn = (
135
157
  tokenAt: new Map(tokens.map((token) => [token.span.start, token])),
136
158
  speller,
137
159
  ordinary,
160
+ countArticles: patternsOf(doc, "name-count-article"),
161
+ wrongMarks: patternsOf(doc, "name-wrong-mark"),
138
162
  };
139
163
  return (found) =>
140
164
  (found.kind === "near" && isNearPair(reading, found)) ||
@@ -143,6 +167,7 @@ export const twoThingsIn = (
143
167
  isQuotedTitleCase(found, reading.text) ||
144
168
  (found.kind === "spelling" && isContractionPair(found.name, found.usual, reading.text)) ||
145
169
  isInFileName(reading.text, found.offset, found.name.length) ||
170
+ isShownWrong(reading, found) ||
146
171
  (found.kind === "reading" && isVerbStem(found, reading.tokenAt, reading.copulas));
147
172
  };
148
173
 
@@ -32,17 +32,27 @@ const phrasesIn = (sentence: Sentence, source: string, phrases: Lexicon): Hidden
32
32
  })),
33
33
  );
34
34
 
35
+ const touches = (left: Token | undefined, right: Token | undefined): boolean => left !== undefined && right !== undefined && left.span.end === right.span.start;
36
+
37
+ /**
38
+ * The first token of the compound noun the verbal noun ends: 塗り + 直し is 塗り直し, and 直しする is not a verb to write.
39
+ * Nouns written straight before it, with no space, are one word.
40
+ */
41
+ const compoundStart = (tokens: readonly Token[], at: number): number =>
42
+ tokens[at - 1]?.pos === "NOUN" && touches(tokens[at - 1], tokens[at]) ? compoundStart(tokens, at - 1) : at;
43
+
35
44
  /**
36
- * A carrying verb right after a verbal noun: 調査 + を実施した. Both sides are named in the dictionary form, the noun and the
45
+ * A carrying verb right after a verbal noun: 調査 + を実施した, the noun read with the compound it ends (塗り直し). Both sides are named in the dictionary form, the noun and the
37
46
  * entry (調査を実施する), and the verb to write is the noun and the entry's instead_of (調査 + する).
38
47
  */
39
- const lightVerbsIn = (sentence: Sentence, lightVerbs: Lexicon, eventNouns: ReadonlySet<string>): Hidden[] => {
48
+ const lightVerbsIn = (sentence: Sentence, source: string, lightVerbs: Lexicon, eventNouns: ReadonlySet<string>): Hidden[] => {
40
49
  const tokens = sentence.tokens ?? [];
41
50
  return lightVerbs.flatMap((entry) =>
42
51
  entryRanges(sentence, entry).flatMap((range): Hidden[] => {
43
52
  const noun = tokens[range.start - 1];
44
53
  if (!isVerbalNoun(noun) || eventNouns.has(noun.surface)) return [];
45
- return [{ sentence, offset: noun.span.start, matched: `${noun.surface}${entry.pattern}`, preferred: `${noun.surface}${entry.instead_of ?? ""}` }];
54
+ const compound = source.slice(tokens[compoundStart(tokens, range.start - 1)]?.span.start ?? noun.span.start, noun.span.end);
55
+ return [{ sentence, offset: noun.span.start, matched: `${compound}${entry.pattern}`, preferred: `${compound}${entry.instead_of ?? ""}` }];
46
56
  }),
47
57
  );
48
58
  };
@@ -53,7 +63,7 @@ export const hiddenVerbs = (doc: Pick<ProseDocument, "sentences" | "source" | "l
53
63
  return doc.sentences
54
64
  .flatMap((sentence) => [
55
65
  ...phrasesIn(sentence, doc.source, doc.lexicons[PHRASES] ?? []),
56
- ...lightVerbsIn(sentence, doc.lexicons[LIGHT_VERBS] ?? [], eventNouns),
66
+ ...lightVerbsIn(sentence, doc.source, doc.lexicons[LIGHT_VERBS] ?? [], eventNouns),
57
67
  ])
58
68
  .toSorted((left, right) => left.offset - right.offset);
59
69
  };
@@ -1,6 +1,6 @@
1
1
  import type { Detector, Finding, Lexicon } from "../plugin.ts";
2
2
  import { escapeRegExp } from "../orthography.ts";
3
- import { quoteAround } from "./quote-around.ts";
3
+ import { quoteAround, sentenceQuoteAt } from "./quote-around.ts";
4
4
 
5
5
  // 数と序数の字が合わない所(3th、22th、11st)。どの数の終わりにどの字が付くかは語彙表 ordinal-suffix が言う。
6
6
 
@@ -34,7 +34,7 @@ export const ordinalSuffix: Detector = (doc): Finding[] => {
34
34
  severity: "warning",
35
35
  line: 0,
36
36
  column: 0,
37
- quote: quoteAround(text, slip.offset, slip.offset + slip.written.length),
37
+ quote: sentenceQuoteAt(doc.sentences, slip.offset) ?? quoteAround(text, slip.offset, slip.offset + slip.written.length),
38
38
  values: { written: slip.written, expected: `${slip.number}${slip.expected[0] ?? ""}`, offset: slip.offset },
39
39
  }));
40
40
  };
@@ -29,6 +29,7 @@ import { bracketedTitleRuns, titleCaseNameRuns } from "../title-case-name.ts";
29
29
  import { withoutQuotedSpellings, type Quoted } from "../quoted-spelling.ts";
30
30
  import { teFormOf, withTeFormFullVerbs, type TeForm } from "../te-form-helper.ts";
31
31
  import { citedSpans, isOpenIn, namesOf, patternsOf, type IsOpen, type Names } from "./orthographic-variant-open.ts";
32
+ import { headingSentences } from "./heading-sentences.ts";
32
33
 
33
34
  /**
34
35
  * A word found in the document: where it is, which sentence it is in, its key and spelling, how it is written when that differs, and
@@ -302,8 +303,17 @@ const findingOf = (words: readonly Placed[], odd: OddSpelling<Placed>): Finding
302
303
  /** A cell that is one Latin word in lower case (openapi, contentType): a field name or a value, spelled by the data and not by the writer. */
303
304
  const DATA_KEY_CELL = /^\p{Ll}[A-Za-z0-9]*$/u;
304
305
 
305
- /** A sentence or a table cell, where its words are the writer's, whether its Latin words are read, and its cited works. */
306
- type Place = { readonly sentence: Sentence; readonly isOpen: IsOpen; readonly readsLatin: boolean; readonly cited: readonly Span[] };
306
+ /**
307
+ * A sentence, a heading or a table cell, where its words are the writer's, whether its Latin and its Japanese words are
308
+ * read, and its cited works.
309
+ */
310
+ type Place = {
311
+ readonly sentence: Sentence;
312
+ readonly isOpen: IsOpen;
313
+ readonly readsLatin: boolean;
314
+ readonly readsJapanese: boolean;
315
+ readonly cited: readonly Span[];
316
+ };
307
317
 
308
318
  /** What the words of a document are read with besides the lexicons of uses: the dictionary, and the small words inside a name (of). */
309
319
  type Reading = { readonly isWord: (word: string) => boolean; readonly nameJoiners: readonly string[] };
@@ -317,16 +327,41 @@ const withoutLinkChrome = (text: string): string => text.replaceAll(LINK_CHROME,
317
327
  const cellPlace = (cell: TableCell, names: Names): Place => {
318
328
  const text = withoutLinkChrome(cell.text);
319
329
  const sentence: Sentence = { span: { start: cell.start, end: cell.end }, text, tokens: cell.tokens ?? [] };
320
- return { sentence, isOpen: isOpenIn(sentence, names), readsLatin: !DATA_KEY_CELL.test(text.trim()), cited: citedSpans(sentence, names) };
330
+ return {
331
+ sentence,
332
+ isOpen: isOpenIn(sentence, names),
333
+ readsLatin: !DATA_KEY_CELL.test(text.trim()),
334
+ readsJapanese: true,
335
+ cited: citedSpans(sentence, names),
336
+ };
321
337
  };
322
338
 
339
+ /**
340
+ * A body sentence, read whole; or a heading, read for its Latin words only. An English heading spells its words as the
341
+ * body does (e-mail, email); a Japanese heading is a label, whose compound nouns drop okurigana (申込受付期間 beside 申込み)
342
+ * and whose category word (コーヒー) stands beside names in the body (大坊珈琲店).
343
+ */
344
+ const textPlace = (written: Sentence, names: Names, heading: boolean): Place => {
345
+ const sentence = heading ? withoutInlineCode(written) : written;
346
+ return { sentence, isOpen: isOpenIn(sentence, names), readsLatin: true, readsJapanese: !heading, cited: citedSpans(sentence, names) };
347
+ };
348
+
349
+ const INLINE_CODE = /`[^`]*`/gu;
350
+
351
+ /** A heading with its code blanked out (`kubectl create configmap`): the body's prose masks code, a heading's text keeps it. */
352
+ const withoutInlineCode = (sentence: Sentence): Sentence => ({
353
+ ...sentence,
354
+ text: sentence.text.replaceAll(INLINE_CODE, (code) => " ".repeat(code.length)),
355
+ });
356
+
323
357
  /** The odd spellings among places that speak in one voice. */
324
358
  const findingsIn = (placed: readonly Place[], skips: Skips, { isWord, nameJoiners }: Reading, limit: number): Finding[] => {
359
+ const japanese = placed.filter((place) => place.readsJapanese);
325
360
  const reading = byKanji(
326
- withTeFormFullVerbs(placed.flatMap(({ sentence, isOpen }) => readingWords(withCutNounsJoined(sentence, skips.nouns), isOpen, skips))),
361
+ withTeFormFullVerbs(japanese.flatMap(({ sentence, isOpen }) => readingWords(withCutNounsJoined(sentence, skips.nouns), isOpen, skips))),
327
362
  );
328
- const katakana = placed.flatMap(({ sentence, isOpen }) => katakanaWords(sentence, isOpen));
329
- const runs = placed.flatMap(({ sentence, isOpen }) => katakanaRunWords(sentence, isOpen));
363
+ const katakana = japanese.flatMap(({ sentence, isOpen }) => katakanaWords(sentence, isOpen));
364
+ const runs = japanese.flatMap(({ sentence, isOpen }) => katakanaRunWords(sentence, isOpen));
330
365
  const latin = withoutQuotedSpellings(
331
366
  withoutCoinedNames(
332
367
  placed.flatMap((place) => (place.readsLatin ? latinWords(place, skips.skip, nameJoiners) : [])),
@@ -349,7 +384,8 @@ const findingsIn = (placed: readonly Place[], skips: Skips, { isWord, nameJoiner
349
384
  export const orthographicVariant: Detector = (doc, options): Finding[] => {
350
385
  const names = namesOf(doc, options.genre);
351
386
  const placed: Place[] = [
352
- ...doc.sentences.map((sentence) => ({ sentence, isOpen: isOpenIn(sentence, names), readsLatin: true, cited: citedSpans(sentence, names) })),
387
+ ...doc.sentences.map((sentence) => textPlace(sentence, names, false)),
388
+ ...headingSentences(doc).map((sentence) => textPlace(sentence, names, true)),
353
389
  ...(doc.tableCells?.() ?? []).map((cell) => cellPlace(cell, names)),
354
390
  ];
355
391
  const phraseSuffixes = new Set(patternsOf(doc, PHRASE_SUFFIX, options.genre));
@@ -366,7 +402,7 @@ export const orthographicVariant: Detector = (doc, options): Finding[] => {
366
402
  phraseSuffixes,
367
403
  twoReadings: new Map(entriesForGenre(doc.lexicons[TWO_READINGS] ?? [], options.genre).map((entry) => [entry.pattern, entry.group ?? ""])),
368
404
  nouns: documentNounKeys(
369
- placed.map(({ sentence }) => sentence.tokens ?? []),
405
+ placed.flatMap(({ sentence, readsJapanese }) => (readsJapanese ? [sentence.tokens ?? []] : [])),
370
406
  phraseSuffixes,
371
407
  ),
372
408
  };
@@ -1,5 +1,5 @@
1
1
  import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span } from "../plugin.ts";
2
- import { conjugatedStartsOutside } from "./conjugated-entry.ts";
2
+ import { conjugatedSpansOutside } from "./conjugated-entry.ts";
3
3
  import { calendarRuns, calendarUnitsOf, type CalendarUnits } from "../calendar-number.ts";
4
4
  import { escapeRegExp, latinBoundaries, occurrencesOutside, type Boundary, type SpacingKind } from "../orthography.ts";
5
5
  import { minorityReport, withoutSideOnTie } from "../spacing-minority.ts";
@@ -13,18 +13,28 @@ import { licenceNoticeSentences } from "./licence-notice.ts";
13
13
  import { followsCaptionLabel, isCitedEntryLine, isNumberTableBoundary, lineAt } from "../latin-spacing-source.ts";
14
14
 
15
15
  /** 書いた形の出現に、動詞の活用した形(行う → 行います)を足したもの。同じ位置は一度だけ。 */
16
- const avoidedStarts = (sentence: Sentence, entry: LexiconEntry, use: string): number[] => {
17
- const written = occurrencesOutside(sentence.text, entry.pattern, use);
18
- const conjugated = conjugatedStartsOutside(sentence, entry, use).filter((at) => !written.includes(at));
19
- return [...written, ...conjugated].toSorted((left, right) => left - right);
16
+ const avoidedSpans = (sentence: Sentence, entry: LexiconEntry, use: string): Span[] => {
17
+ const written = occurrencesOutside(sentence.text, entry.pattern, use).map((start) => ({ start, end: start + entry.pattern.length }));
18
+ const conjugated = conjugatedSpansOutside(sentence, entry, use).filter((span) => !written.some((other) => other.start === span.start));
19
+ return [...written, ...conjugated].toSorted((left, right) => left.start - right.start);
20
+ };
21
+
22
+ type PreferPair = { readonly entry: LexiconEntry; readonly avoid: string; readonly use: string };
23
+ type PreferHit = { readonly sentence: Sentence; readonly span: Span; readonly pair: PreferPair };
24
+
25
+ const isInsideLonger = (hit: PreferHit, other: PreferHit): boolean =>
26
+ other.span.end - other.span.start > hit.span.end - hit.span.start && other.span.start <= hit.span.start && hit.span.end <= other.span.end;
27
+
28
+ /** 並べた書き方が重なれば(e-mail の中の mail)、長い方だけ。短い方は長い方の一部で、別の書き方ではない。 */
29
+ const sentenceHits = (sentence: Sentence, pairs: readonly PreferPair[]): PreferHit[] => {
30
+ const hits = pairs.flatMap((pair) => avoidedSpans(sentence, pair.entry, pair.use).map((span) => ({ sentence, span, pair })));
31
+ return hits.filter((hit) => !hits.some((other) => isInsideLonger(hit, other))).toSorted((left, right) => left.span.start - right.span.start);
20
32
  };
21
33
 
22
34
  /** チームが chaff.yaml の prefer に書いた「使わない書き方」。書いていなければ何も言わない。 */
23
35
  export const preferredTerm: Detector = (doc, options): Finding[] => {
24
36
  const pairs = (options.lexicon ?? []).flatMap((entry) => (entry.instead_of === undefined ? [] : [{ entry, avoid: entry.pattern, use: entry.instead_of }]));
25
- const hits = doc.sentences.flatMap((sentence) =>
26
- pairs.flatMap((pair) => avoidedStarts(sentence, pair.entry, pair.use).map((at) => ({ sentence, at, pair }))),
27
- );
37
+ const hits = doc.sentences.flatMap((sentence) => sentenceHits(sentence, pairs));
28
38
  if (hits.length === 0 || hits.length < options.limit) return [];
29
39
  return hits.map((hit) => ({
30
40
  rule: "",
@@ -32,7 +42,7 @@ export const preferredTerm: Detector = (doc, options): Finding[] => {
32
42
  line: 0,
33
43
  column: 0,
34
44
  quote: hit.sentence.text.trim(),
35
- values: { matched: hit.pair.avoid, preferred: hit.pair.use, count: hits.length, limit: options.limit, offset: hit.sentence.span.start + hit.at },
45
+ values: { matched: hit.pair.avoid, preferred: hit.pair.use, count: hits.length, limit: options.limit, offset: hit.sentence.span.start + hit.span.start },
36
46
  }));
37
47
  };
38
48
 
@@ -167,6 +167,19 @@ const opensAsNoun = (scope: ItemScope, item: TokenRange): boolean => {
167
167
  /** 項目が読点で閉じず、節の終わり(文の終わりか ; : —)まで続く。 */
168
168
  const runsToClauseEnd = (scope: ItemScope, item: TokenRange): boolean => scope.sentence.tokens[item.end]?.surface !== ",";
169
169
 
170
+ /**
171
+ * 名前のすぐ後ろの、関係詞(who / which)で始まる項目は、読点で挟んで名前に添えた節(Tom, who repaired radios for forty years
172
+ * before he retired, gently opened the back and quickly found a loose wire)。名前も節も並びの項目ではなく、並びがあるなら節の後ろから
173
+ * (Alice, who leads design, Bob, Carol, and Dan は Bob からの 3 つ)。関係詞の語は語彙表 aside-relative が言う。
174
+ */
175
+ const afterRelativeAside = (view: View): View => {
176
+ const { scope } = view.list;
177
+ const [name, aside] = [firstOf(view), secondOf(view)];
178
+ if (name === undefined || aside === undefined || !opensAsNoun(scope, name.item)) return view;
179
+ const opening = openingOf(scope, aside.item)?.surface.toLowerCase() ?? "";
180
+ return scope.sentence.words.asideRelative?.has(opening) === true ? after(view, aside) : view;
181
+ };
182
+
170
183
  const opensAsPredicate = (scope: ItemScope, item: TokenRange): boolean => {
171
184
  const opening = openingOf(scope, item);
172
185
  return opening !== undefined && VERBAL.has(opening.pos) && !isParticiple(opening);
@@ -360,7 +373,7 @@ const listAt = (list: ItemList, at: number, walk: Walk): boolean | undefined =>
360
373
  const { scope } = list;
361
374
  if (closesExampleAside(wholeList(list), at)) return undefined;
362
375
  const afterItem = itemAfter(scope, at);
363
- const opened = afterClosedList(withoutLead(afterVerbAside(afterClauseTurn(withoutCoordinateAdjective(wholeList(list)), afterItem))));
376
+ const opened = afterClosedList(withoutLead(afterRelativeAside(afterVerbAside(afterClauseTurn(withoutCoordinateAdjective(wholeList(list)), afterItem)))));
364
377
  const items = fromParticiplePhrase(fromExample(opened, afterItem), afterItem);
365
378
  if (listContinues(scope, afterItem, walk) || isAppositive(scope, at, items, afterItem) || insideLastItem(scope, at, items, afterItem)) return undefined;
366
379
  if (namesDivision(items) || qualifiesPrevious(items)) return undefined;
@@ -420,6 +433,7 @@ export const oxfordComma: Detector = (doc, options): Finding[] => {
420
433
  indefinite: patternsOf(doc.lexicons["indefinite-article"]),
421
434
  elision: (doc.lexicons["elision-mark"] ?? []).map((entry) => entry.pattern),
422
435
  openListEnd: patternsOf(doc.lexicons["open-list-end"]),
436
+ asideRelative: patternsOf(doc.lexicons["aside-relative"]),
423
437
  };
424
438
  const judged = doc.sentences.flatMap((sentence) => {
425
439
  const oxford = oxfordIn(sentence.tokens ?? [], words, doc.source);
@@ -2,7 +2,7 @@ import type { Detector, Finding } from "../plugin.ts";
2
2
  import { oneSentenceRuns } from "../paragraph-runs.ts";
3
3
  import { referenceListSpans } from "../reference-lists.ts";
4
4
 
5
- /** How much of the run's first paragraph the finding quotes. */
5
+ /** How much of the run's first paragraph the finding quotes when it holds no sentence; it never runs past the paragraph. */
6
6
  const QUOTE_LENGTH = 80;
7
7
 
8
8
  /**
@@ -29,7 +29,7 @@ export const oneSentenceParagraphRun: Detector = (doc, options): Finding[] =>
29
29
  severity: "info",
30
30
  line: 0,
31
31
  column: 0,
32
- quote: doc.source.slice(first.span.start, first.span.start + QUOTE_LENGTH).trim(),
32
+ quote: first.sentences[0]?.text.trim() ?? doc.source.slice(first.span.start, Math.min(first.span.start + QUOTE_LENGTH, first.span.end)).trim(),
33
33
  values: { count: run.length, limit: options.limit, offset: first.span.start },
34
34
  },
35
35
  ];
@@ -7,7 +7,8 @@ import type { Detector, Finding } from "../plugin.ts";
7
7
  export const phoneNumberVariant: Detector = (doc, options): Finding[] => {
8
8
  const labels = options.lexicon ?? [];
9
9
  if (labels.length === 0) return [];
10
- return phoneVariants(labelledPhoneNumbers(doc.prose ?? doc.source, labels)).map(({ number, other }) => ({
10
+ const links = (doc.lexicons["phone-label-link"] ?? []).map((entry) => entry.pattern);
11
+ return phoneVariants(labelledPhoneNumbers(doc.prose ?? doc.source, labels, links)).map(({ number, other }) => ({
11
12
  rule: "",
12
13
  severity: "info",
13
14
  line: 0,
@@ -0,0 +1,19 @@
1
+ // A worn phrase whose words also have a plain sense ("Empty the tray at the end of the day", "Every version is on the
2
+ // same page") counts only where its sentence reads it as the figure. The language's word list gives, for each such
3
+ // phrase (group), regular expressions of the figurative use; a phrase without any counts everywhere. Pure.
4
+ import type { LexiconEntry, Sentence } from "../plugin.ts";
5
+
6
+ export type PhraseContexts = ReadonlyMap<string, readonly RegExp[]>;
7
+
8
+ export const phraseContextsOf = (entries: readonly LexiconEntry[]): PhraseContexts =>
9
+ entries.reduce((contexts, entry) => {
10
+ const phrase = entry.group?.toLowerCase();
11
+ if (phrase === undefined) return contexts;
12
+ return new Map([...contexts, [phrase, [...(contexts.get(phrase) ?? []), new RegExp(entry.pattern, "iu")]]]);
13
+ }, new Map<string, readonly RegExp[]>());
14
+
15
+ /** Whether the sentence uses the entry as the figure: no context listed for it, or one of its contexts matches. */
16
+ export const inFigurativeContext = (sentence: Sentence, entry: LexiconEntry, contexts: PhraseContexts): boolean => {
17
+ const patterns = contexts.get(entry.pattern.toLowerCase());
18
+ return patterns === undefined || patterns.some((pattern) => pattern.test(sentence.text));
19
+ };