chaffjs 0.45.0 → 0.47.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 (460) hide show
  1. package/dist/announced-list.d.ts +2 -1
  2. package/dist/announced-list.d.ts.map +1 -1
  3. package/dist/announced-list.js +3 -1
  4. package/dist/announced-list.js.map +1 -1
  5. package/dist/body-section.d.ts +7 -0
  6. package/dist/body-section.d.ts.map +1 -1
  7. package/dist/body-section.js +15 -0
  8. package/dist/body-section.js.map +1 -1
  9. package/dist/derived/durations.d.ts +1 -0
  10. package/dist/derived/durations.d.ts.map +1 -1
  11. package/dist/derived/durations.js +2 -2
  12. package/dist/derived/durations.js.map +1 -1
  13. package/dist/derived/marked-dates.d.ts +2 -0
  14. package/dist/derived/marked-dates.d.ts.map +1 -1
  15. package/dist/derived/marked-dates.js +2 -0
  16. package/dist/derived/marked-dates.js.map +1 -1
  17. package/dist/detectors/acronym-capitals.d.ts +6 -0
  18. package/dist/detectors/acronym-capitals.d.ts.map +1 -0
  19. package/dist/detectors/acronym-capitals.js +30 -0
  20. package/dist/detectors/acronym-capitals.js.map +1 -0
  21. package/dist/detectors/bare-comparative.d.ts +1 -0
  22. package/dist/detectors/bare-comparative.d.ts.map +1 -1
  23. package/dist/detectors/bare-comparative.js +9 -2
  24. package/dist/detectors/bare-comparative.js.map +1 -1
  25. package/dist/detectors/bare-word-list.d.ts +7 -0
  26. package/dist/detectors/bare-word-list.d.ts.map +1 -0
  27. package/dist/detectors/bare-word-list.js +43 -0
  28. package/dist/detectors/bare-word-list.js.map +1 -0
  29. package/dist/detectors/bold-field-label.d.ts +8 -0
  30. package/dist/detectors/bold-field-label.d.ts.map +1 -0
  31. package/dist/detectors/bold-field-label.js +31 -0
  32. package/dist/detectors/bold-field-label.js.map +1 -0
  33. package/dist/detectors/bold-label.d.ts +21 -2
  34. package/dist/detectors/bold-label.d.ts.map +1 -1
  35. package/dist/detectors/bold-label.js +66 -13
  36. package/dist/detectors/bold-label.js.map +1 -1
  37. package/dist/detectors/broken-link.d.ts.map +1 -1
  38. package/dist/detectors/broken-link.js +22 -4
  39. package/dist/detectors/broken-link.js.map +1 -1
  40. package/dist/detectors/byline-list.d.ts +4 -0
  41. package/dist/detectors/byline-list.d.ts.map +1 -0
  42. package/dist/detectors/byline-list.js +19 -0
  43. package/dist/detectors/byline-list.js.map +1 -0
  44. package/dist/detectors/caps-screen-label.d.ts +3 -0
  45. package/dist/detectors/caps-screen-label.d.ts.map +1 -0
  46. package/dist/detectors/caps-screen-label.js +13 -0
  47. package/dist/detectors/caps-screen-label.js.map +1 -0
  48. package/dist/detectors/casual-voice.d.ts +8 -0
  49. package/dist/detectors/casual-voice.d.ts.map +1 -0
  50. package/dist/detectors/casual-voice.js +22 -0
  51. package/dist/detectors/casual-voice.js.map +1 -0
  52. package/dist/detectors/char-shape.js +1 -1
  53. package/dist/detectors/char-shape.js.map +1 -1
  54. package/dist/detectors/closing-cliche.d.ts +2 -1
  55. package/dist/detectors/closing-cliche.d.ts.map +1 -1
  56. package/dist/detectors/closing-cliche.js +10 -2
  57. package/dist/detectors/closing-cliche.js.map +1 -1
  58. package/dist/detectors/count-per-section.d.ts.map +1 -1
  59. package/dist/detectors/count-per-section.js +6 -2
  60. package/dist/detectors/count-per-section.js.map +1 -1
  61. package/dist/detectors/dangling-opener.d.ts.map +1 -1
  62. package/dist/detectors/dangling-opener.js +10 -1
  63. package/dist/detectors/dangling-opener.js.map +1 -1
  64. package/dist/detectors/date-year.d.ts.map +1 -1
  65. package/dist/detectors/date-year.js +11 -1
  66. package/dist/detectors/date-year.js.map +1 -1
  67. package/dist/detectors/defined-term-form.d.ts.map +1 -1
  68. package/dist/detectors/defined-term-form.js +17 -3
  69. package/dist/detectors/defined-term-form.js.map +1 -1
  70. package/dist/detectors/document-shape.d.ts +4 -1
  71. package/dist/detectors/document-shape.d.ts.map +1 -1
  72. package/dist/detectors/document-shape.js +12 -2
  73. package/dist/detectors/document-shape.js.map +1 -1
  74. package/dist/detectors/doubled-punctuation.d.ts.map +1 -1
  75. package/dist/detectors/doubled-punctuation.js +24 -1
  76. package/dist/detectors/doubled-punctuation.js.map +1 -1
  77. package/dist/detectors/email-letter.d.ts.map +1 -1
  78. package/dist/detectors/email-letter.js +5 -2
  79. package/dist/detectors/email-letter.js.map +1 -1
  80. package/dist/detectors/email-subject-reference.d.ts +6 -0
  81. package/dist/detectors/email-subject-reference.d.ts.map +1 -0
  82. package/dist/detectors/email-subject-reference.js +31 -0
  83. package/dist/detectors/email-subject-reference.js.map +1 -0
  84. package/dist/detectors/en-shape.d.ts.map +1 -1
  85. package/dist/detectors/en-shape.js +5 -4
  86. package/dist/detectors/en-shape.js.map +1 -1
  87. package/dist/detectors/fact-consistency.js +2 -2
  88. package/dist/detectors/fact-consistency.js.map +1 -1
  89. package/dist/detectors/figure-order.d.ts +1 -1
  90. package/dist/detectors/figure-order.d.ts.map +1 -1
  91. package/dist/detectors/figure-order.js +7 -2
  92. package/dist/detectors/figure-order.js.map +1 -1
  93. package/dist/detectors/fullwidth-alnum.d.ts +4 -0
  94. package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
  95. package/dist/detectors/fullwidth-alnum.js +31 -9
  96. package/dist/detectors/fullwidth-alnum.js.map +1 -1
  97. package/dist/detectors/gram-heading.d.ts.map +1 -1
  98. package/dist/detectors/gram-heading.js +13 -1
  99. package/dist/detectors/gram-heading.js.map +1 -1
  100. package/dist/detectors/heading-case.d.ts.map +1 -1
  101. package/dist/detectors/heading-case.js +6 -1
  102. package/dist/detectors/heading-case.js.map +1 -1
  103. package/dist/detectors/heading-numbering.d.ts.map +1 -1
  104. package/dist/detectors/heading-numbering.js +1 -7
  105. package/dist/detectors/heading-numbering.js.map +1 -1
  106. package/dist/detectors/hyphen-name-suffix.d.ts +3 -0
  107. package/dist/detectors/hyphen-name-suffix.d.ts.map +1 -0
  108. package/dist/detectors/hyphen-name-suffix.js +24 -0
  109. package/dist/detectors/hyphen-name-suffix.js.map +1 -0
  110. package/dist/detectors/katakana-density.d.ts.map +1 -1
  111. package/dist/detectors/katakana-density.js +7 -4
  112. package/dist/detectors/katakana-density.js.map +1 -1
  113. package/dist/detectors/lexicon.d.ts +1 -0
  114. package/dist/detectors/lexicon.d.ts.map +1 -1
  115. package/dist/detectors/lexicon.js +36 -4
  116. package/dist/detectors/lexicon.js.map +1 -1
  117. package/dist/detectors/link-shape.d.ts.map +1 -1
  118. package/dist/detectors/link-shape.js +10 -2
  119. package/dist/detectors/link-shape.js.map +1 -1
  120. package/dist/detectors/list-item-phrase.d.ts +20 -0
  121. package/dist/detectors/list-item-phrase.d.ts.map +1 -0
  122. package/dist/detectors/list-item-phrase.js +73 -0
  123. package/dist/detectors/list-item-phrase.js.map +1 -0
  124. package/dist/detectors/list-layout.d.ts +5 -0
  125. package/dist/detectors/list-layout.d.ts.map +1 -1
  126. package/dist/detectors/list-layout.js +12 -0
  127. package/dist/detectors/list-layout.js.map +1 -1
  128. package/dist/detectors/list-lead-in.d.ts.map +1 -1
  129. package/dist/detectors/list-lead-in.js +1 -17
  130. package/dist/detectors/list-lead-in.js.map +1 -1
  131. package/dist/detectors/list-parallel.d.ts.map +1 -1
  132. package/dist/detectors/list-parallel.js +29 -24
  133. package/dist/detectors/list-parallel.js.map +1 -1
  134. package/dist/detectors/mark-shape.d.ts +1 -1
  135. package/dist/detectors/mark-shape.d.ts.map +1 -1
  136. package/dist/detectors/mark-shape.js +10 -3
  137. package/dist/detectors/mark-shape.js.map +1 -1
  138. package/dist/detectors/measured-facts.d.ts +5 -1
  139. package/dist/detectors/measured-facts.d.ts.map +1 -1
  140. package/dist/detectors/measured-facts.js +7 -3
  141. package/dist/detectors/measured-facts.js.map +1 -1
  142. package/dist/detectors/middle-dot.d.ts +5 -0
  143. package/dist/detectors/middle-dot.d.ts.map +1 -1
  144. package/dist/detectors/middle-dot.js +27 -0
  145. package/dist/detectors/middle-dot.js.map +1 -1
  146. package/dist/detectors/missing-final-period.d.ts.map +1 -1
  147. package/dist/detectors/missing-final-period.js +13 -1
  148. package/dist/detectors/missing-final-period.js.map +1 -1
  149. package/dist/detectors/name-variant.d.ts.map +1 -1
  150. package/dist/detectors/name-variant.js +2 -1
  151. package/dist/detectors/name-variant.js.map +1 -1
  152. package/dist/detectors/number-style.d.ts +2 -0
  153. package/dist/detectors/number-style.d.ts.map +1 -1
  154. package/dist/detectors/number-style.js +19 -4
  155. package/dist/detectors/number-style.js.map +1 -1
  156. package/dist/detectors/numeral-opener.d.ts +1 -1
  157. package/dist/detectors/numeral-opener.d.ts.map +1 -1
  158. package/dist/detectors/numeral-opener.js +4 -2
  159. package/dist/detectors/numeral-opener.js.map +1 -1
  160. package/dist/detectors/open-end-names.d.ts +2 -0
  161. package/dist/detectors/open-end-names.d.ts.map +1 -1
  162. package/dist/detectors/open-end-names.js +8 -1
  163. package/dist/detectors/open-end-names.js.map +1 -1
  164. package/dist/detectors/ordinary-phrase.d.ts +5 -0
  165. package/dist/detectors/ordinary-phrase.d.ts.map +1 -1
  166. package/dist/detectors/ordinary-phrase.js +10 -0
  167. package/dist/detectors/ordinary-phrase.js.map +1 -1
  168. package/dist/detectors/orthographic-variant.js +2 -2
  169. package/dist/detectors/orthographic-variant.js.map +1 -1
  170. package/dist/detectors/output-lead-in.d.ts +3 -0
  171. package/dist/detectors/output-lead-in.d.ts.map +1 -0
  172. package/dist/detectors/output-lead-in.js +26 -0
  173. package/dist/detectors/output-lead-in.js.map +1 -0
  174. package/dist/detectors/outside-announced-list.d.ts.map +1 -1
  175. package/dist/detectors/outside-announced-list.js +6 -1
  176. package/dist/detectors/outside-announced-list.js.map +1 -1
  177. package/dist/detectors/oxford-comma.d.ts.map +1 -1
  178. package/dist/detectors/oxford-comma.js +3 -1
  179. package/dist/detectors/oxford-comma.js.map +1 -1
  180. package/dist/detectors/paragraph-restatement.d.ts +4 -1
  181. package/dist/detectors/paragraph-restatement.d.ts.map +1 -1
  182. package/dist/detectors/paragraph-restatement.js +17 -2
  183. package/dist/detectors/paragraph-restatement.js.map +1 -1
  184. package/dist/detectors/person-consistency.d.ts +2 -1
  185. package/dist/detectors/person-consistency.d.ts.map +1 -1
  186. package/dist/detectors/person-consistency.js +11 -2
  187. package/dist/detectors/person-consistency.js.map +1 -1
  188. package/dist/detectors/quoted-title-line.d.ts +6 -0
  189. package/dist/detectors/quoted-title-line.d.ts.map +1 -0
  190. package/dist/detectors/quoted-title-line.js +14 -0
  191. package/dist/detectors/quoted-title-line.js.map +1 -0
  192. package/dist/detectors/register-interview.d.ts +4 -0
  193. package/dist/detectors/register-interview.d.ts.map +1 -0
  194. package/dist/detectors/register-interview.js +19 -0
  195. package/dist/detectors/register-interview.js.map +1 -0
  196. package/dist/detectors/registry/colloquial-opener-pile.d.ts +3 -0
  197. package/dist/detectors/registry/colloquial-opener-pile.d.ts.map +1 -0
  198. package/dist/detectors/registry/colloquial-opener-pile.js +3 -0
  199. package/dist/detectors/registry/colloquial-opener-pile.js.map +1 -0
  200. package/dist/detectors/repeated-head.d.ts.map +1 -1
  201. package/dist/detectors/repeated-head.js +23 -4
  202. package/dist/detectors/repeated-head.js.map +1 -1
  203. package/dist/detectors/request-owner.d.ts +3 -1
  204. package/dist/detectors/request-owner.d.ts.map +1 -1
  205. package/dist/detectors/request-owner.js +5 -2
  206. package/dist/detectors/request-owner.js.map +1 -1
  207. package/dist/detectors/run-together.d.ts +3 -0
  208. package/dist/detectors/run-together.d.ts.map +1 -0
  209. package/dist/detectors/run-together.js +13 -0
  210. package/dist/detectors/run-together.js.map +1 -0
  211. package/dist/detectors/sentence-counts.d.ts +6 -2
  212. package/dist/detectors/sentence-counts.d.ts.map +1 -1
  213. package/dist/detectors/sentence-counts.js +19 -3
  214. package/dist/detectors/sentence-counts.js.map +1 -1
  215. package/dist/detectors/sentence-ending.d.ts +2 -0
  216. package/dist/detectors/sentence-ending.d.ts.map +1 -1
  217. package/dist/detectors/sentence-ending.js +8 -2
  218. package/dist/detectors/sentence-ending.js.map +1 -1
  219. package/dist/detectors/sentence-parts.d.ts +10 -1
  220. package/dist/detectors/sentence-parts.d.ts.map +1 -1
  221. package/dist/detectors/sentence-parts.js +17 -2
  222. package/dist/detectors/sentence-parts.js.map +1 -1
  223. package/dist/detectors/space-before-punctuation.d.ts +2 -2
  224. package/dist/detectors/space-before-punctuation.d.ts.map +1 -1
  225. package/dist/detectors/space-before-punctuation.js +13 -2
  226. package/dist/detectors/space-before-punctuation.js.map +1 -1
  227. package/dist/detectors/stray-space.js +1 -1
  228. package/dist/detectors/stray-space.js.map +1 -1
  229. package/dist/detectors/structure-tree.d.ts.map +1 -1
  230. package/dist/detectors/structure-tree.js +2 -1
  231. package/dist/detectors/structure-tree.js.map +1 -1
  232. package/dist/detectors/structure.d.ts +1 -0
  233. package/dist/detectors/structure.d.ts.map +1 -1
  234. package/dist/detectors/structure.js +5 -1
  235. package/dist/detectors/structure.js.map +1 -1
  236. package/dist/detectors/superlative-context.d.ts +7 -0
  237. package/dist/detectors/superlative-context.d.ts.map +1 -1
  238. package/dist/detectors/superlative-context.js +6 -0
  239. package/dist/detectors/superlative-context.js.map +1 -1
  240. package/dist/detectors/technical-docs.d.ts.map +1 -1
  241. package/dist/detectors/technical-docs.js +5 -1
  242. package/dist/detectors/technical-docs.js.map +1 -1
  243. package/dist/detectors/token-shape.d.ts.map +1 -1
  244. package/dist/detectors/token-shape.js +16 -3
  245. package/dist/detectors/token-shape.js.map +1 -1
  246. package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
  247. package/dist/detectors/unbalanced-bracket.js +5 -1
  248. package/dist/detectors/unbalanced-bracket.js.map +1 -1
  249. package/dist/detectors/undefined-term.d.ts.map +1 -1
  250. package/dist/detectors/undefined-term.js +5 -1
  251. package/dist/detectors/undefined-term.js.map +1 -1
  252. package/dist/detectors/unknown-word-context.d.ts +8 -0
  253. package/dist/detectors/unknown-word-context.d.ts.map +1 -1
  254. package/dist/detectors/unknown-word-context.js +38 -6
  255. package/dist/detectors/unknown-word-context.js.map +1 -1
  256. package/dist/detectors/unknown-word.d.ts.map +1 -1
  257. package/dist/detectors/unknown-word.js +11 -4
  258. package/dist/detectors/unknown-word.js.map +1 -1
  259. package/dist/detectors/vague-density.d.ts.map +1 -1
  260. package/dist/detectors/vague-density.js +13 -1
  261. package/dist/detectors/vague-density.js.map +1 -1
  262. package/dist/front-matter.d.ts +3 -0
  263. package/dist/front-matter.d.ts.map +1 -0
  264. package/dist/front-matter.js +13 -0
  265. package/dist/front-matter.js.map +1 -0
  266. package/dist/genre-check.js +1 -1
  267. package/dist/genre-check.js.map +1 -1
  268. package/dist/genre.d.ts +0 -2
  269. package/dist/genre.d.ts.map +1 -1
  270. package/dist/genre.js +1 -12
  271. package/dist/genre.js.map +1 -1
  272. package/dist/labelled-note-paragraphs.d.ts +4 -0
  273. package/dist/labelled-note-paragraphs.d.ts.map +1 -0
  274. package/dist/labelled-note-paragraphs.js +21 -0
  275. package/dist/labelled-note-paragraphs.js.map +1 -0
  276. package/dist/list-lead-sentence.d.ts +6 -0
  277. package/dist/list-lead-sentence.d.ts.map +1 -0
  278. package/dist/list-lead-sentence.js +20 -0
  279. package/dist/list-lead-sentence.js.map +1 -0
  280. package/dist/paragraph-runs.d.ts +2 -1
  281. package/dist/paragraph-runs.d.ts.map +1 -1
  282. package/dist/paragraph-runs.js +19 -2
  283. package/dist/paragraph-runs.js.map +1 -1
  284. package/dist/recording-title.d.ts +5 -0
  285. package/dist/recording-title.d.ts.map +1 -0
  286. package/dist/recording-title.js +11 -0
  287. package/dist/recording-title.js.map +1 -0
  288. package/dist/sentence-load.d.ts +2 -1
  289. package/dist/sentence-load.d.ts.map +1 -1
  290. package/dist/sentence-load.js +56 -2
  291. package/dist/sentence-load.js.map +1 -1
  292. package/dist/stray-space.d.ts +5 -2
  293. package/dist/stray-space.d.ts.map +1 -1
  294. package/dist/stray-space.js +24 -2
  295. package/dist/stray-space.js.map +1 -1
  296. package/dist/structure/due-column.d.ts +5 -0
  297. package/dist/structure/due-column.d.ts.map +1 -0
  298. package/dist/structure/due-column.js +30 -0
  299. package/dist/structure/due-column.js.map +1 -0
  300. package/dist/structure/generic-role.d.ts +1 -0
  301. package/dist/structure/generic-role.d.ts.map +1 -1
  302. package/dist/structure/generic-role.js +6 -0
  303. package/dist/structure/generic-role.js.map +1 -1
  304. package/dist/structure/party-role.d.ts.map +1 -1
  305. package/dist/structure/party-role.js +4 -2
  306. package/dist/structure/party-role.js.map +1 -1
  307. package/dist/title-case-name.d.ts +5 -0
  308. package/dist/title-case-name.d.ts.map +1 -1
  309. package/dist/title-case-name.js +14 -0
  310. package/dist/title-case-name.js.map +1 -1
  311. package/package.json +3 -3
  312. package/rules/adverb-overuse.yaml +2 -2
  313. package/rules/ai-tell.yaml +2 -2
  314. package/rules/all-caps-shouting.yaml +2 -2
  315. package/rules/bare-url-mix.yaml +2 -2
  316. package/rules/bold-density.yaml +2 -2
  317. package/rules/bold-label-list.yaml +6 -6
  318. package/rules/clause-chain.yaml +2 -2
  319. package/rules/closing-cliche.yaml +2 -2
  320. package/rules/code-fence-language-mix.yaml +2 -2
  321. package/rules/colloquial-opener.yaml +3 -3
  322. package/rules/comparative-without-baseline.yaml +2 -2
  323. package/rules/dangling-participle.yaml +2 -2
  324. package/rules/date-order.yaml +2 -2
  325. package/rules/date-outside-period.yaml +1 -1
  326. package/rules/defined-term-form.yaml +2 -2
  327. package/rules/doubled-punctuation.yaml +2 -2
  328. package/rules/duration-mismatch.yaml +2 -2
  329. package/rules/email-subject-length.yaml +2 -2
  330. package/rules/empty-intensifier.yaml +2 -2
  331. package/rules/figure-reference-order.yaml +2 -2
  332. package/rules/fullwidth-alnum-consistency.yaml +2 -2
  333. package/rules/hyphen-as-dash.yaml +2 -2
  334. package/rules/katakana-density.yaml +2 -2
  335. package/rules/list-item-form-mix.yaml +2 -2
  336. package/rules/max-kanji-continuous.yaml +4 -3
  337. package/rules/max-ten.yaml +3 -3
  338. package/rules/missing-final-period.yaml +2 -2
  339. package/rules/name-variant.yaml +2 -2
  340. package/rules/ngram-repetition.yaml +2 -2
  341. package/rules/no-lead.yaml +2 -2
  342. package/rules/no-mixed-desumasu.yaml +3 -2
  343. package/rules/no-nakaguro-parallel.yaml +2 -2
  344. package/rules/number-style-consistency.yaml +2 -2
  345. package/rules/numeral-sentence-start.yaml +2 -2
  346. package/rules/one-sentence-paragraph-run.yaml +2 -2
  347. package/rules/orthographic-variant.yaml +2 -2
  348. package/rules/outside-announced-list.yaml +2 -2
  349. package/rules/oxford-comma-consistency.yaml +2 -2
  350. package/rules/paragraph-restatement.yaml +2 -2
  351. package/rules/party-role-name.yaml +2 -2
  352. package/rules/person-consistency.yaml +2 -2
  353. package/rules/preamble-length.yaml +2 -2
  354. package/rules/repeated-conjunction.yaml +2 -2
  355. package/rules/repeated-sentence-head.yaml +2 -2
  356. package/rules/request-without-deadline.yaml +2 -2
  357. package/rules/requirement-smell.yaml +2 -2
  358. package/rules/space-before-punctuation.yaml +2 -2
  359. package/rules/stray-space.yaml +7 -4
  360. package/rules/summary-fact-mismatch.yaml +2 -2
  361. package/rules/taigen-dome-in-prose.yaml +2 -2
  362. package/rules/teki-overuse.yaml +2 -2
  363. package/rules/title-case-consistency.yaml +2 -2
  364. package/rules/title-length.yaml +2 -2
  365. package/rules/total-mismatch.yaml +1 -1
  366. package/rules/unbalanced-bracket.yaml +3 -3
  367. package/rules/undefined-term.yaml +2 -2
  368. package/rules/unknown-word.yaml +2 -2
  369. package/rules/unqualified-superlative.yaml +2 -2
  370. package/rules/vague-word-density.yaml +2 -2
  371. package/rules/very-adjective.yaml +1 -1
  372. package/rules/warning-without-action.yaml +2 -2
  373. package/rules/yori-as-from.yaml +1 -0
  374. package/src/announced-list.ts +12 -3
  375. package/src/body-section.ts +19 -0
  376. package/src/derived/durations.ts +3 -2
  377. package/src/derived/marked-dates.ts +4 -0
  378. package/src/detectors/acronym-capitals.ts +30 -0
  379. package/src/detectors/bare-comparative.ts +12 -2
  380. package/src/detectors/bare-word-list.ts +61 -0
  381. package/src/detectors/bold-field-label.ts +33 -0
  382. package/src/detectors/bold-label.ts +91 -14
  383. package/src/detectors/broken-link.ts +23 -2
  384. package/src/detectors/byline-list.ts +24 -0
  385. package/src/detectors/caps-screen-label.ts +15 -0
  386. package/src/detectors/casual-voice.ts +30 -0
  387. package/src/detectors/char-shape.ts +2 -2
  388. package/src/detectors/closing-cliche.ts +19 -3
  389. package/src/detectors/count-per-section.ts +6 -2
  390. package/src/detectors/dangling-opener.ts +12 -1
  391. package/src/detectors/date-year.ts +12 -1
  392. package/src/detectors/defined-term-form.ts +19 -3
  393. package/src/detectors/document-shape.ts +16 -2
  394. package/src/detectors/doubled-punctuation.ts +26 -1
  395. package/src/detectors/email-letter.ts +5 -3
  396. package/src/detectors/email-subject-reference.ts +36 -0
  397. package/src/detectors/en-shape.ts +5 -4
  398. package/src/detectors/fact-consistency.ts +2 -2
  399. package/src/detectors/figure-order.ts +8 -2
  400. package/src/detectors/fullwidth-alnum.ts +39 -10
  401. package/src/detectors/gram-heading.ts +15 -1
  402. package/src/detectors/heading-case.ts +7 -1
  403. package/src/detectors/heading-numbering.ts +1 -9
  404. package/src/detectors/hyphen-name-suffix.ts +30 -0
  405. package/src/detectors/katakana-density.ts +8 -4
  406. package/src/detectors/lexicon.ts +37 -5
  407. package/src/detectors/link-shape.ts +16 -2
  408. package/src/detectors/list-item-phrase.ts +86 -0
  409. package/src/detectors/list-layout.ts +17 -0
  410. package/src/detectors/list-lead-in.ts +1 -19
  411. package/src/detectors/list-parallel.ts +31 -28
  412. package/src/detectors/mark-shape.ts +13 -3
  413. package/src/detectors/measured-facts.ts +11 -4
  414. package/src/detectors/middle-dot.ts +32 -0
  415. package/src/detectors/missing-final-period.ts +14 -1
  416. package/src/detectors/name-variant.ts +2 -1
  417. package/src/detectors/number-style.ts +26 -4
  418. package/src/detectors/numeral-opener.ts +4 -2
  419. package/src/detectors/open-end-names.ts +11 -1
  420. package/src/detectors/ordinary-phrase.ts +10 -0
  421. package/src/detectors/orthographic-variant.ts +2 -2
  422. package/src/detectors/output-lead-in.ts +28 -0
  423. package/src/detectors/outside-announced-list.ts +6 -1
  424. package/src/detectors/oxford-comma.ts +3 -1
  425. package/src/detectors/paragraph-restatement.ts +17 -2
  426. package/src/detectors/person-consistency.ts +14 -2
  427. package/src/detectors/quoted-title-line.ts +13 -0
  428. package/src/detectors/register-interview.ts +22 -0
  429. package/src/detectors/registry/colloquial-opener-pile.ts +4 -0
  430. package/src/detectors/repeated-head.ts +32 -6
  431. package/src/detectors/request-owner.ts +5 -2
  432. package/src/detectors/run-together.ts +15 -0
  433. package/src/detectors/sentence-counts.ts +18 -3
  434. package/src/detectors/sentence-ending.ts +13 -2
  435. package/src/detectors/sentence-parts.ts +20 -2
  436. package/src/detectors/space-before-punctuation.ts +24 -4
  437. package/src/detectors/stray-space.ts +1 -1
  438. package/src/detectors/structure-tree.ts +12 -9
  439. package/src/detectors/structure.ts +4 -1
  440. package/src/detectors/superlative-context.ts +10 -0
  441. package/src/detectors/technical-docs.ts +5 -3
  442. package/src/detectors/token-shape.ts +19 -4
  443. package/src/detectors/unbalanced-bracket.ts +9 -1
  444. package/src/detectors/undefined-term.ts +5 -1
  445. package/src/detectors/unknown-word-context.ts +44 -6
  446. package/src/detectors/unknown-word.ts +16 -3
  447. package/src/detectors/vague-density.ts +15 -2
  448. package/src/front-matter.ts +14 -0
  449. package/src/genre-check.ts +1 -1
  450. package/src/genre.ts +1 -15
  451. package/src/labelled-note-paragraphs.ts +30 -0
  452. package/src/list-lead-sentence.ts +24 -0
  453. package/src/paragraph-runs.ts +25 -2
  454. package/src/recording-title.ts +16 -0
  455. package/src/sentence-load.ts +68 -2
  456. package/src/stray-space.ts +37 -6
  457. package/src/structure/due-column.ts +33 -0
  458. package/src/structure/generic-role.ts +8 -0
  459. package/src/structure/party-role.ts +3 -2
  460. package/src/title-case-name.ts +19 -0
@@ -83,6 +83,24 @@ const UNIT_HEADER = /[((](?:%|%|人|名|株|件|台|社|円|千円|百万円
83
83
  /** Fewer unit headers than this are a sentence that names a unit or two, not a table's header row. */
84
84
  const MIN_UNIT_HEADERS = 3;
85
85
 
86
- /** Whether a sentence is a table a converter flattened: glued numbers, rows opened by dates, or a header row of cells closed by units. */
86
+ /** Ditto marks in a row (―〃〃〃): cells that repeat the row above, which only a table has. */
87
+ const DITTO_CELLS = /〃\s*〃/u;
88
+
89
+ /**
90
+ * Whether a sentence is a table a converter flattened: glued numbers, rows opened by dates, a header row of cells closed by
91
+ * units, or ditto cells.
92
+ */
87
93
  export const isFlattenedTable = (text: string): boolean =>
88
- flattenedTableParts(text) !== undefined || (text.match(UNIT_HEADER)?.length ?? 0) >= MIN_UNIT_HEADERS;
94
+ flattenedTableParts(text) !== undefined || (text.match(UNIT_HEADER)?.length ?? 0) >= MIN_UNIT_HEADERS || DITTO_CELLS.test(text);
95
+
96
+ /** A decimal cell run in between a bracketed cell and the next cell's word ((日本)100.0自動車関連): where one row's cells meet. */
97
+ const GLUED_DECIMAL_CELL = /[))]\d{1,3}\.\d+(?=\p{L})/gu;
98
+ /** Fewer such joins than this are a version or a figure after a name ((RSL)1.0), not the rows of a table. */
99
+ const MIN_GLUED_ROWS = 3;
100
+
101
+ /**
102
+ * Whether a block of text (a paragraph) is a table a converter flattened: a flattened table by the sentence signals, or a
103
+ * decimal cell glued between a bracketed cell and the next cell in row after row. Its sentences are rows cut at the
104
+ * stops inside cells, not the writer's sentences.
105
+ */
106
+ export const isFlattenedTableBlock = (text: string): boolean => isFlattenedTable(text) || (text.match(GLUED_DECIMAL_CELL)?.length ?? 0) >= MIN_GLUED_ROWS;
@@ -1,4 +1,5 @@
1
- import type { Detector, Finding } from "../plugin.ts";
1
+ import type { Detector, Finding, Span } from "../plugin.ts";
2
+ import { referenceListSpans } from "../reference-lists.ts";
2
3
  import { quoteAround } from "./quote-around.ts";
3
4
 
4
5
  /**
@@ -14,15 +15,34 @@ const DOTS_REACH = 3;
14
15
 
15
16
  const isSpacedEllipsis = (text: string, space: number): boolean => SPACED_DOTS.test(text.slice(space + 1, space + 1 + DOTS_REACH));
16
17
 
18
+ /** 文献一覧で、値を落とした欄の名前("ISBN ,")。大文字だけの名前のすぐ後ろが読点になるのは、文献の書式が空の値を埋めたところ。 */
19
+ const EMPTY_FIELD_LABEL = /(?:^|[^\p{L}])\p{Lu}{2,}$/u;
20
+
21
+ /** 欄の名前を探す字数。どの欄の名前よりも長い。 */
22
+ const LABEL_REACH = 16;
23
+
24
+ const isEmptyField = (text: string, space: number, references: readonly Span[]): boolean =>
25
+ text.charAt(space + 1) === "," &&
26
+ references.some((span) => span.start <= space && space < span.end) &&
27
+ EMPTY_FIELD_LABEL.test(text.slice(Math.max(0, space - LABEL_REACH), space));
28
+
17
29
  /**
18
30
  * 本文(prose)の中の、句読点の前の空白の位置。prose はコード・URL・強調の印を空白で覆うので、覆ってできた空白("*word* ." の "*")は
19
31
  * 書き手が打った空白ではない。source の同じ位置も空白のときだけ数える。
20
32
  */
21
- export const spacesBeforePunctuation = (prose: string, source: string): number[] =>
22
- [...prose.matchAll(SPACED_MARK)].map((match) => match.index).filter((space) => source.charAt(space) === " " && !isSpacedEllipsis(prose, space));
33
+ export const spacesBeforePunctuation = (prose: string, source: string, references: readonly Span[] = []): number[] =>
34
+ [...prose.matchAll(SPACED_MARK)]
35
+ .map((match) => match.index)
36
+ .filter((space) => source.charAt(space) === " " && !isSpacedEllipsis(prose, space) && !isEmptyField(prose, space, references));
37
+
38
+ const referencesOf = (source: string, headingWords: readonly { readonly pattern: string }[] | undefined): Span[] =>
39
+ referenceListSpans(
40
+ source,
41
+ (headingWords ?? []).map((entry) => entry.pattern),
42
+ );
23
43
 
24
44
  export const spaceBeforePunctuation: Detector = (doc): Finding[] =>
25
- spacesBeforePunctuation(doc.prose ?? doc.source, doc.source).map((space) => ({
45
+ spacesBeforePunctuation(doc.prose ?? doc.source, doc.source, referencesOf(doc.source, doc.lexicons["reference-list-heading"])).map((space) => ({
26
46
  rule: "",
27
47
  severity: "warning",
28
48
  line: 0,
@@ -3,7 +3,7 @@ import { minorityStyle } from "../orthography.ts";
3
3
  import { isClosed } from "../sentence-shape.ts";
4
4
  import { phraseJoints, type Joint, type JointKind } from "../stray-space.ts";
5
5
 
6
- const KINDS: readonly JointKind[] = ["between-phrases", "inside-phrase"];
6
+ const KINDS: readonly JointKind[] = ["between-phrases", "inside-phrase", "inside-word"];
7
7
 
8
8
  type Quoted = Joint & { readonly quote: string };
9
9
 
@@ -7,6 +7,7 @@ import { weekdayMismatches } from "../structure/weekday.ts";
7
7
  import { revisionAnchors } from "./revision-date.ts";
8
8
  import { documentDateOf } from "./document-date.ts";
9
9
  import { dateOrderBreaks } from "../structure/date-order.ts";
10
+ import { scheduledPoints } from "../structure/due-column.ts";
10
11
  import { totalMismatches, type Amount } from "../structure/total.ts";
11
12
  import { isListedTotal, isPeriodTotalLine, isTotalLikeLine, isTotalLine } from "../structure/total-line.ts";
12
13
  import { proseTotalMismatches } from "../structure/prose-total.ts";
@@ -174,15 +175,17 @@ export const datedPoints = (tree: NonNullable<ProseDocument["structure"]>): { of
174
175
  export const dateOrder: Detector = (doc): Finding[] =>
175
176
  doc.structure === undefined
176
177
  ? []
177
- : dateOrderBreaks(doc.source, datedPoints(doc.structure), doc.markup?.headings ?? []).map((issue) => ({
178
- rule: "date-order",
179
- severity: "warning",
180
- line: 0,
181
- column: 0,
182
- quote: quoteAt(doc.source, issue.offset),
183
- values: { ...withReadableDates(issue.values, ["date", "previous", "next"], readableDates(doc)), offset: issue.offset },
184
- ...("next" in issue.values ? { variant: "first" } : {}),
185
- }));
178
+ : dateOrderBreaks(doc.source, scheduledPoints(doc.source, datedPoints(doc.structure), patternsOf(doc, "action-due-label")), doc.markup?.headings ?? []).map(
179
+ (issue) => ({
180
+ rule: "date-order",
181
+ severity: "warning",
182
+ line: 0,
183
+ column: 0,
184
+ quote: quoteAt(doc.source, issue.offset),
185
+ values: { ...withReadableDates(issue.values, ["date", "previous", "next"], readableDates(doc)), offset: issue.offset },
186
+ ...("next" in issue.values ? { variant: "first" } : {}),
187
+ }),
188
+ );
186
189
 
187
190
  /** 木の数量を、原文の位置と一緒に並べる。 */
188
191
  export const amountsOf = (tree: NonNullable<ProseDocument["structure"]>): Amount[] =>
@@ -5,7 +5,7 @@ import { dateStampIndexes, stampCandidates } from "../date-stamp.ts";
5
5
  import { inDocumentOrder } from "../structure/issues.ts";
6
6
  import { preambleParagraphs } from "../preamble-paragraphs.ts";
7
7
  import { isTooLongParagraph, labelledBlocks, lostLineBreaks, opensWithFusedHeading } from "../paragraph-length.ts";
8
- import { bodySectionOf } from "../body-section.ts";
8
+ import { bodySectionOf, hasOnlyMatterHeadings } from "../body-section.ts";
9
9
  import { threeShare } from "../rule-of-three.ts";
10
10
  import { isInterview, sectionLevels } from "../section-levels.ts";
11
11
 
@@ -171,10 +171,13 @@ const withoutDateStamps = (doc: ProseDocument, paragraphs: readonly Paragraph[])
171
171
  /**
172
172
  * 本題に入るまでが長い。業務文書では、読み手は結論を探しに来ている。
173
173
  * 「本題」は最初の中見出し。中見出しが無い文書では、rule が requires の headings で動かず、動かなかった理由が出る。
174
+ * 見出しが末尾の問い合わせ先や参考文献だけの文書(手紙の形の諮問)も、本題の見出しが無いので測らない。
174
175
  */
175
176
  export const preambleLength: Detector = (doc, options): Finding[] => {
176
177
  const body = bodySectionOf(doc.sections);
177
178
  if (body === undefined) return [];
179
+ const matter = (doc.lexicons["unnumbered-heading"] ?? []).map((entry) => entry.pattern.toLowerCase());
180
+ if (hasOnlyMatterHeadings(doc.sections, body, matter)) return [];
178
181
  const noteMarks = (doc.lexicons["note-mark"] ?? []).map((entry) => entry.pattern);
179
182
  const all = preambleParagraphs(doc.paragraphs, body.span.start, doc.source, noteMarks);
180
183
  if (all.length <= options.limit) return [];
@@ -14,6 +14,8 @@ export type Context = {
14
14
  readonly parts: Lexicon;
15
15
  /** 前に名指した名詞の代わりに立つ語(one・ones)。 */
16
16
  readonly proForms: Lexicon;
17
+ /** 仮定を開く語(if・もし)。 */
18
+ readonly conditions: Lexicon;
17
19
  };
18
20
 
19
21
  /** 語彙表の語が最上級まで届く語の数。これより離れた動詞は、間に別の目的語や節がある。 */
@@ -36,6 +38,7 @@ export const contextOf = (lexicons: Readonly<Record<string, Lexicon>>): Context
36
38
  viewpoints: lexicons["superlative-viewpoint"] ?? [],
37
39
  parts: lexicons["superlative-part"] ?? [],
38
40
  proForms: lexicons["superlative-pro-form"] ?? [],
41
+ conditions: lexicons["superlative-condition"] ?? [],
39
42
  });
40
43
 
41
44
  const isPunct = (token: Token | undefined): boolean => token === undefined || token.pos === "PUNCT";
@@ -61,6 +64,13 @@ export const sought = (sentence: Sentence, range: TokenRange, goals: Lexicon): b
61
64
  return goals.some((entry) => (entry.position === "after" ? after(sentence, range, entry) : endsBefore(tokens, range, entry, GOAL_REACH)));
62
65
  };
63
66
 
67
+ /**
68
+ * 最上級が、同じ節の前で開いた仮定の中にあるか(If spreadsheet formulas are the most prolific government code, …・もし最も速い
69
+ * 案が通るなら)。仮に置いたもので、何かが一番だという主張ではない。
70
+ */
71
+ export const supposed = (tokens: readonly Token[], range: TokenRange, conditions: Lexicon): boolean =>
72
+ conditions.some((entry) => endsBefore(tokens, range, entry, range.start));
73
+
64
74
  const isWord = (token: Token | undefined, words: Lexicon): boolean =>
65
75
  token !== undefined && words.some((entry) => entry.pattern.toLowerCase() === token.surface.toLowerCase());
66
76
 
@@ -7,6 +7,7 @@ import { opensAsNounPhrase } from "./nominal-step.ts";
7
7
  import { quoteAt } from "./structure-tree.ts";
8
8
  import { escapeRegExp } from "../orthography.ts";
9
9
  import { isFormatTemplate } from "../format-template.ts";
10
+ import { afterOutputLeadIn } from "./output-lead-in.ts";
10
11
  import type { Detector, Finding, ProseDocument, Span, Token } from "../plugin.ts";
11
12
 
12
13
  const patternsOf = (doc: ProseDocument, id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
@@ -37,11 +38,12 @@ export const untaggedFewer = (fences: readonly CodeFence[], limit: number): read
37
38
  };
38
39
 
39
40
  export const codeFenceLanguage: Detector = (doc, options): Finding[] => {
41
+ const outputWords = patternsOf(doc, "output-lead-in");
40
42
  const fences = codeFences(doc.source).filter(wantsLanguage);
41
43
  const tagged = fences.filter((fence) => fence.language !== "").length;
42
- return untaggedFewer(fences, options.limit).map((fence) =>
43
- finding(doc, "code-fence-language-mix", fence.start, { tagged, untagged: fences.length - tagged }),
44
- );
44
+ // A block of plain output (after "we'd expect to see:") is in no language: it still counts, but is not pointed at.
45
+ const reported = untaggedFewer(fences, options.limit).filter((fence) => !afterOutputLeadIn(doc.source, fence.start, outputWords));
46
+ return reported.map((fence) => finding(doc, "code-fence-language-mix", fence.start, { tagged, untagged: fences.length - tagged }));
45
47
  };
46
48
 
47
49
  export type PromptStyle = "prompt" | "bare" | undefined;
@@ -2,11 +2,13 @@ import { hasParticle, isClosed, lastContent } from "../sentence-shape.ts";
2
2
  import { isWithinAny, quotedIn } from "../quoted-span.ts";
3
3
  import { chronologyRows } from "../chronology-rows.ts";
4
4
  import { externalLinkTitleSpans } from "../link-title.ts";
5
- import type { Detector, Finding, Span, Token } from "../plugin.ts";
5
+ import type { Detector, Finding, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
6
6
  import { countedTokens, uncountedWordsOf, type UncountedWords } from "../uncounted-particles.ts";
7
7
  import { boundWordParticles } from "../bound-word-particles.ts";
8
8
  import { setPhraseParticles } from "../set-phrase-particles.ts";
9
9
  import { noteSentences } from "../note-paragraphs.ts";
10
+ import { labelledNoteSentences } from "../labelled-note-paragraphs.ts";
11
+ import { listLeadSentences } from "../list-lead-sentence.ts";
10
12
  import { documentNameSpans } from "./particle-run-names.ts";
11
13
  import { namedLongForms } from "./particle-run-long-forms.ts";
12
14
  import { quotedNameSpans, quotedNames } from "./particle-run-quoted-names.ts";
@@ -24,11 +26,24 @@ const isDependent = (token: Token): boolean => token.features?.["NounType"] ===
24
26
 
25
27
  const inside = (span: Span, spans: readonly Span[]): boolean => spans.some((other) => span.start >= other.start && span.start < other.end);
26
28
 
29
+ /** 表や図の注の段落の頭の語((注1)の「注」)。 */
30
+ const NOTE_LABEL_LEXICON = "note-paragraph-label";
31
+
32
+ /** 名詞で止めるのが書き方の文: 年表の行、注や文献の一覧、(注1)で始まる表の注、箇条書きへ渡す文(以下のとおり説明。)。 */
33
+ const clippedByForm = (doc: ProseDocument): ReadonlySet<Sentence> => {
34
+ const patterns = (id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
35
+ return new Set([
36
+ ...chronologyRows(doc),
37
+ ...noteSentences(doc.source, doc.paragraphs),
38
+ ...labelledNoteSentences(doc.source, doc.paragraphs, patterns(NOTE_LABEL_LEXICON), patterns("note-mark")),
39
+ ...listLeadSentences(doc.sentences, doc.lists, doc.source),
40
+ ]);
41
+ };
42
+
27
43
  export const nounEnding: Detector = (doc, options): Finding[] => {
28
- const rows = chronologyRows(doc);
29
- const notes = noteSentences(doc.source, doc.paragraphs);
44
+ const clipped = clippedByForm(doc);
30
45
  const ended = doc.sentences.filter((sentence) => {
31
- if (inside(sentence.span, doc.listSpans) || rows.has(sentence) || notes.has(sentence) || !isClosed(sentence) || !hasParticle(sentence)) return false;
46
+ if (inside(sentence.span, doc.listSpans) || clipped.has(sentence) || !isClosed(sentence) || !hasParticle(sentence)) return false;
32
47
  const last = lastContent(sentence);
33
48
  return last !== undefined && NOMINAL.has(last.pos) && !isDependent(last);
34
49
  });
@@ -16,6 +16,7 @@ type Bracket = { readonly open: string; readonly close: string; readonly family:
16
16
 
17
17
  const BRACKETS: readonly Bracket[] = [
18
18
  { open: "「", close: "」", family: "kagi" },
19
+ { open: "「", close: "」", family: "kagi" },
19
20
  { open: "『", close: "』", family: "double-kagi" },
20
21
  { open: "(", close: ")", family: "round" },
21
22
  { open: "(", close: ")", family: "round" },
@@ -51,6 +52,12 @@ export type BracketProblem = {
51
52
  type Open = { readonly bracket: Bracket; readonly offset: number };
52
53
  type Scan = { readonly open: Open[]; readonly problems: BracketProblem[] };
53
54
 
55
+ /** 半角の「「」」。幅の違いは hankaku-kana が指すので、全角と組んでも幅の違いとしては指さない。 */
56
+ const HALFWIDTH_KAGI: ReadonlySet<string> = new Set(["「", "」"]);
57
+
58
+ const isWidthSlip = (opened: Bracket, closing: Bracket): boolean =>
59
+ opened !== closing && !HALFWIDTH_KAGI.has(opened.open) && !HALFWIDTH_KAGI.has(closing.close);
60
+
54
61
  const unclosedOf = (entry: Open): BracketProblem => ({ kind: "unclosed", offset: entry.offset, mark: entry.bracket.open });
55
62
 
56
63
  const closeWith = (scan: Scan, text: string, bracket: Bracket, offset: number): void => {
@@ -69,7 +76,8 @@ const closeWith = (scan: Scan, text: string, bracket: Bracket, offset: number):
69
76
  .slice(1)
70
77
  .filter((inner) => !(QUOTATIONS.has(bracket.family) && inner.offset === offset - 1))
71
78
  .forEach((inner) => scan.problems.push(unclosedOf(inner)));
72
- if (opened !== undefined && opened.bracket !== bracket) scan.problems.push({ kind: "mismatch", offset, mark: bracket.close, partner: opened.bracket.open });
79
+ if (opened !== undefined && isWidthSlip(opened.bracket, bracket))
80
+ scan.problems.push({ kind: "mismatch", offset, mark: bracket.close, partner: opened.bracket.open });
73
81
  };
74
82
 
75
83
  /** 段落(空行で区切った塊)の最初の字。 */
@@ -3,6 +3,7 @@
3
3
  // marks a word as one of its terms; a term with that prefix and no definition leaves the reader asking what it is.
4
4
  // Only the document's own references (本条, 本契約: self-reference-noun and document-kind) are left. Pure; the parts of
5
5
  // speech decide where a prefix is a prefix (本 in 本成果物) and not part of a word (本人, 本日).
6
+ import { isRunTogether } from "./run-together.ts";
6
7
  import { definedTerms } from "../structure/definition-use.ts";
7
8
  import { prefixGroupsOf, prefixVariants } from "../structure/term-prefix.ts";
8
9
  import { quoteAt } from "./structure-tree.ts";
@@ -193,5 +194,8 @@ export const undefinedTerm: Detector = (doc): Finding[] => {
193
194
  groupSuffixes: patternsOf(doc, "defined-term-group-suffix"),
194
195
  inheritsDefinitions: patternsOf(doc, "definitions-inherited").some((phrase) => phrase !== "" && doc.source.includes(phrase)),
195
196
  });
196
- return [...prefixed, ...capitalisedUses(doc, sentences, definitions)].map((use) => findingOf(doc, use));
197
+ const dictionary = doc.dictionary?.() ?? new Set<string>();
198
+ // A term holding a run-together word (Space Includingspecified Description) is text a conversion joined, not a term.
199
+ const capitalised = capitalisedUses(doc, sentences, definitions).filter((use) => !use.term.split(/\s+/u).some((word) => isRunTogether(word, dictionary)));
200
+ return [...prefixed, ...capitalised].map((use) => findingOf(doc, use));
197
201
  };
@@ -5,17 +5,55 @@ import { isAddress, isKnownWord, stemsOf, type CheckedWord, type Speller } from
5
5
  /** Each half of a closed compound keeps this many letters: a shorter half (open + end, pip + line) is more often a slip at the joint. */
6
6
  const MIN_COMPOUND_PART = 4;
7
7
 
8
+ /** Where a word splits into the two halves of a closed compound (flag + salute in flagsalute). */
9
+ const compoundSplits = (word: string, speller: Speller): number[] => {
10
+ const listed: Speller = { ...speller, suffixes: [], prefixes: [] };
11
+ const inflected: Speller = { ...listed, suffixes: speller.suffixes.filter(({ inflection }) => inflection === true) };
12
+ return [...Array(Math.max(0, word.length - 2 * MIN_COMPOUND_PART + 1)).keys()]
13
+ .map((index) => index + MIN_COMPOUND_PART)
14
+ .filter((split) => isKnownWord(word.slice(0, split), listed) && isKnownWord(word.slice(split), inflected));
15
+ };
16
+
8
17
  /**
9
18
  * Two dictionary words of four letters or more written as one (crowdwork, crowdworkers): a closed compound, not a slip. The
10
19
  * head is a word as listed and the tail takes only an inflection: a prefix or a derived ending on a half (misre + presenation)
11
20
  * reads too many slips as words.
12
21
  */
13
- export const isClosedCompound = (word: string, speller: Speller): boolean => {
14
- const listed: Speller = { ...speller, suffixes: [], prefixes: [] };
15
- const inflected: Speller = { ...listed, suffixes: speller.suffixes.filter(({ inflection }) => inflection === true) };
16
- return [...Array(Math.max(0, word.length - 2 * MIN_COMPOUND_PART + 1)).keys()]
17
- .map((index) => index + MIN_COMPOUND_PART)
18
- .some((split) => isKnownWord(word.slice(0, split), listed) && isKnownWord(word.slice(split), inflected));
22
+ export const isClosedCompound = (word: string, speller: Speller): boolean => compoundSplits(word, speller).length > 0;
23
+
24
+ const QUOTE_MARK = /["“”‘’']/u;
25
+
26
+ /** Where the line of source around offset starts and ends. */
27
+ const lineAround = (source: string, offset: number): readonly [number, number] => {
28
+ const end = source.indexOf("\n", offset);
29
+ return [source.lastIndexOf("\n", offset - 1) + 1, end === -1 ? source.length : end];
30
+ };
31
+
32
+ /** Text set in quotation marks at either end (Not "user name", "factcheck this"): a spelling named or searched for, not used. */
33
+ export const isQuotedAt = (source: string, start: number, end: number): boolean =>
34
+ QUOTE_MARK.test(source.charAt(start - 1)) || QUOTE_MARK.test(source.charAt(end));
35
+
36
+ /**
37
+ * The fewest uses of the apart form before the joined one counts as a slip. A document that writes a compound both ways a
38
+ * few times (rule making twice, rulemaking once) is choosing between two spellings, which is orthographic-variant's.
39
+ */
40
+ const MIN_APART_USES = 3;
41
+
42
+ /**
43
+ * How the document writes a closed compound apart elsewhere (flag salute, flag-salute beside flagsalute), its most common
44
+ * such form in lower case, or undefined. Written apart three times or more, the joined form is two words run together, not the writer's term.
45
+ * A form in quotation marks or on the word's own line (Do not use white list or whitelist) names spellings, not uses one.
46
+ */
47
+ export const writtenApart = (word: string, speller: Speller, source: string, offset: number): string | undefined => {
48
+ const [lineStart, lineEnd] = lineAround(source, offset);
49
+ const forms = compoundSplits(word, speller).flatMap((split) => {
50
+ const apart = new RegExp(`(?<![\\p{L}-])${word.slice(0, split)}[ -]${word.slice(split)}(?![\\p{L}-])`, "giu");
51
+ return [...source.matchAll(apart)]
52
+ .filter((match) => (match.index < lineStart || match.index >= lineEnd) && !isQuotedAt(source, match.index, match.index + match[0].length))
53
+ .map((match) => match[0].toLowerCase());
54
+ });
55
+ if (forms.length < MIN_APART_USES) return undefined;
56
+ return [...countsOf(forms)].toSorted((left, right) => right[1] - left[1])[0]?.[0];
19
57
  };
20
58
 
21
59
  /**
@@ -13,8 +13,10 @@ import {
13
13
  inSearchTermList,
14
14
  isClosedCompound,
15
15
  isMention,
16
+ isQuotedAt,
16
17
  isNceSpelling,
17
18
  usedOnce,
19
+ writtenApart,
18
20
  } from "./unknown-word-context.ts";
19
21
 
20
22
  /** これより短い語は見ない。短い語は一字違いの語が多すぎて言い直しが決まらず(tost は test か toast か)、略した語(impl)も多い。 */
@@ -52,7 +54,7 @@ export const codeWordsOf = (source: string): Set<string> => {
52
54
  return words;
53
55
  };
54
56
 
55
- /** 辞書の語か、派生した語に活用の語尾を付けた語(operationalises、rightsized)か、四字以上の辞書の語二つを続けた語(crowdwork)か、-nse の語の -nce の綴り(recompence)。 */
57
+ /** 辞書の語か、派生した語に活用の語尾を付けた語(operationalises、rightsized)か、四字以上の辞書の語二つを続けた語(crowdwork。文書が別の所で分けて書いていれば続けた打ち間違い)か、-nse の語の -nce の綴り(recompence)。 */
56
58
  const isFormedWord = (word: string, speller: Speller): boolean =>
57
59
  isKnownWord(word, speller) || hasTwoEndings(word, speller) || isClosedCompound(word, speller) || isNceSpelling(word, speller);
58
60
 
@@ -80,9 +82,20 @@ export const unknownWord: Detector = (doc): Finding[] => {
80
82
  const words = wordsToCheck(doc.prose ?? doc.source, MIN_LENGTH, MAX_LENGTH).filter(({ offset }) => !isSplitWord(doc.source, offset));
81
83
  const used = new Set(words.map(({ word }) => word).filter((word) => isKnownWord(word, speller)));
82
84
  const unformed = new Set(words.map(({ word }) => word).filter((word) => !known.has(word) && !isFormedWord(word, speller)));
85
+ const apartAt = (word: string, offset: number): string | undefined =>
86
+ known.has(word) || isKnownWord(word, speller) || !isClosedCompound(word, speller) || isQuotedAt(doc.source, offset, offset + word.length)
87
+ ? undefined
88
+ : writtenApart(word, speller, doc.prose ?? doc.source, offset);
83
89
  return usedOnce(words, speller).flatMap(({ offset, word }) => {
84
- if (!unformed.has(word) || hasDrugStem(word, drugStems) || hasSiblingName(word, unformed) || isTermByPlace(doc.source, offset, word)) return [];
85
- const suggestion = suggestionFor(word, speller, used);
90
+ const apart = apartAt(word, offset);
91
+ if (
92
+ !(unformed.has(word) || apart !== undefined) ||
93
+ hasDrugStem(word, drugStems) ||
94
+ hasSiblingName(word, unformed) ||
95
+ isTermByPlace(doc.source, offset, word)
96
+ )
97
+ return [];
98
+ const suggestion = apart ?? suggestionFor(word, speller, used);
86
99
  if (suggestion === undefined) return [];
87
100
  return [{ rule: "", severity: "warning", line: 0, column: 0, quote: quoteAt(doc.source, offset), values: { word, suggestion, offset } }];
88
101
  });
@@ -2,10 +2,13 @@
2
2
  // a word inside a longer one ("timely" in "in a timely manner") is that longer word, and a word inside a term of art of the
3
3
  // document's genre ("reasonably" in a contract, "adequately compensate" as the test for an injunction) is not vague
4
4
  // there. The rule speaks once per sentence, about the document's density. Pure: the words come from the language's
5
- // lexicons vague-word and vague-word-term-of-art, the genre from the options.
5
+ // lexicons vague-word and vague-word-term-of-art, the genre from the options. The lines of a table of contents are the
6
+ // sections' names, not the writer's sentences, and are not read.
6
7
  import { entriesForGenre } from "../lexicon-genres.ts";
8
+ import { contentsLineNumbers } from "../structure/contents-lines.ts";
9
+ import { lineNumberAt, linesOf } from "../structure/lines.ts";
7
10
  import { escapeRegExp } from "../orthography.ts";
8
- import type { Detector, Finding, Lexicon, LexiconEntry, Sentence } from "../plugin.ts";
11
+ import type { Detector, Finding, Lexicon, LexiconEntry, ProseDocument, Sentence } from "../plugin.ts";
9
12
  import { comparableText, comparableWords, entryRanges } from "./lexicon-match.ts";
10
13
  import { rateOver } from "./lexicon.ts";
11
14
  import { specifiedByBracket } from "./bracket-specified.ts";
@@ -64,10 +67,20 @@ export const vagueWordsIn = (sentence: Sentence, vague: Lexicon, termsOfArt: Lex
64
67
 
65
68
  type SentenceHits = { readonly sentence: Sentence; readonly words: readonly string[] };
66
69
 
70
+ /** The sentences on a line of a table of contents (the items under a 目次 / Contents heading). */
71
+ const contentsSentences = (doc: ProseDocument): ReadonlySet<Sentence> => {
72
+ const lines = linesOf(doc.source);
73
+ const tocWords = (doc.lexicons["toc-heading"] ?? []).map((entry) => entry.pattern);
74
+ const numbers = contentsLineNumbers(lines, doc.markup?.headings ?? [], tocWords);
75
+ return new Set(doc.sentences.filter((sentence) => numbers.has(lineNumberAt(lines, sentence.span.start) ?? 0)));
76
+ };
77
+
67
78
  export const vagueDensity: Detector = (doc, options): Finding[] => {
68
79
  const termsOfArt = entriesForGenre(doc.lexicons[TERMS_OF_ART] ?? [], options.genre);
69
80
  const nameMarkers = (doc.lexicons[NAME_MARKERS] ?? []).map((entry) => entry.pattern);
81
+ const contents = contentsSentences(doc);
70
82
  const hits: SentenceHits[] = doc.sentences
83
+ .filter((sentence) => !contents.has(sentence))
71
84
  .map((sentence) => ({ sentence, words: vagueWordsIn(sentence, options.lexicon ?? [], termsOfArt, nameMarkers) }))
72
85
  .filter((hit) => hit.words.length > 0);
73
86
  const count = hits.reduce((sum, hit) => sum + hit.words.length, 0);
@@ -0,0 +1,14 @@
1
+ /** YAML の 1 行の値。行末のコメントと、値を囲む引用符を外す。 */
2
+ const scalarOf = (raw: string): string => {
3
+ const comment = raw.search(/\s#/u);
4
+ const value = (comment === -1 ? raw : raw.slice(0, comment)).trim();
5
+ return /^(["'])(.*)\1$/u.exec(value)?.[2] ?? value;
6
+ };
7
+
8
+ const valuesOf = (block: string, key: string): string[] => [...block.matchAll(new RegExp(`^${key}:(.*)$`, "gmu"))].map((line) => scalarOf(line[1] ?? ""));
9
+
10
+ /** front matter の 1 つの欄に書かれた値。front matter が無ければ空。 */
11
+ export const frontMatterValues = (source: string, key: string): string[] => {
12
+ const block = /^---\n([\s\S]*?)\n---/u.exec(source)?.[1];
13
+ return block === undefined ? [] : valuesOf(block, key);
14
+ };
@@ -1,4 +1,4 @@
1
- import { frontMatterValues } from "./genre.ts";
1
+ import { frontMatterValues } from "./front-matter.ts";
2
2
 
3
3
  /** Where a genre was set: the command line, chaff.yaml's genre, or one of its by_path entries. */
4
4
  export type GenreSetting = "--genre" | "config" | "by_path";
package/src/genre.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { frontMatterValues } from "./front-matter.ts";
1
2
  import { loadGenres } from "./genre-load.ts";
2
3
 
3
4
  /** chaff が知っているジャンル。genres.yaml の並び。rule の use_for はこの頭の部分で当てる。 */
@@ -40,21 +41,6 @@ export const guessGenre = (path: string, source: string, front: string | undefin
40
41
  return undefined;
41
42
  };
42
43
 
43
- /** YAML の 1 行の値。行末のコメントと、値を囲む引用符を外す。 */
44
- const scalarOf = (raw: string): string => {
45
- const comment = raw.search(/\s#/u);
46
- const value = (comment === -1 ? raw : raw.slice(0, comment)).trim();
47
- return /^(["'])(.*)\1$/u.exec(value)?.[2] ?? value;
48
- };
49
-
50
- const valuesOf = (block: string, key: string): string[] => [...block.matchAll(new RegExp(`^${key}:(.*)$`, "gmu"))].map((line) => scalarOf(line[1] ?? ""));
51
-
52
- /** front matter の 1 つの欄に書かれた値。front matter が無ければ空。 */
53
- export const frontMatterValues = (source: string, key: string): string[] => {
54
- const block = /^---\n([\s\S]*?)\n---/u.exec(source)?.[1];
55
- return block === undefined ? [] : valuesOf(block, key);
56
- };
57
-
58
44
  /**
59
45
  * front matter の genre / type を拾う。失敗しても落とさない。genre が type より先。
60
46
  * 知っているジャンルだけを返す。Zenn の type(tech / idea)のような別の意味の値をジャンルにすると、どの rule も当てはまらず「指摘なし」になる。
@@ -0,0 +1,30 @@
1
+ import { escapeRegExp } from "./orthography.ts";
2
+ import type { Paragraph, Sentence } from "./plugin.ts";
3
+
4
+ // A paragraph opened by a note's label ((注1)…をもって算定。 / ※ …を計上。) is a note to a table or a figure, written in the
5
+ // clipped style of notes, not body text. Pure.
6
+
7
+ /** The paragraph-head pattern: a label word with an optional number, bracketed or closed by a bracket, a colon or a space; or a mark. */
8
+ const labelPattern = (words: readonly string[], marks: readonly string[]): RegExp | undefined => {
9
+ const alternatives = [
10
+ ...(words.length === 0
11
+ ? []
12
+ : [`[((](?:${words.map(escapeRegExp).join("|")})[\\d0-9]{0,3}[))]`, `(?:${words.map(escapeRegExp).join("|")})[\\d0-9]{0,3}[))::\\u3000 ]`]),
13
+ ...marks.map(escapeRegExp),
14
+ ];
15
+ return alternatives.length === 0 ? undefined : new RegExp(`^[ \\t\\u3000]*(?:${alternatives.join("|")})`, "u");
16
+ };
17
+
18
+ /** The sentences of the paragraphs that open with a note's label. words are label words (注), marks are note marks (※). */
19
+ export const labelledNoteSentences = (
20
+ source: string,
21
+ paragraphs: readonly Paragraph[],
22
+ words: readonly string[],
23
+ marks: readonly string[],
24
+ ): ReadonlySet<Sentence> => {
25
+ const pattern = labelPattern(words, marks);
26
+ if (pattern === undefined) return new Set();
27
+ return new Set(
28
+ paragraphs.filter((paragraph) => pattern.test(source.slice(paragraph.span.start, paragraph.span.end))).flatMap((paragraph) => paragraph.sentences),
29
+ );
30
+ };
@@ -0,0 +1,24 @@
1
+ import type { BulletList, Sentence } from "./plugin.ts";
2
+
3
+ /** Between a lead-in and its list: only blank space. A thematic break (`***`) separates them; bold marks sit inside the sentence. */
4
+ const ONLY_BLANKS = /^\s*$/u;
5
+
6
+ /** How many sentences end at or before an offset. Sentences are in document order, so a binary search. */
7
+ const countEndingBy = (sentences: readonly Sentence[], offset: number): number => {
8
+ const search = (low: number, high: number): number => {
9
+ if (low >= high) return low;
10
+ const middle = Math.floor((low + high) / 2);
11
+ return (sentences[middle]?.span.end ?? Infinity) <= offset ? search(middle + 1, high) : search(low, middle);
12
+ };
13
+ return search(0, sentences.length);
14
+ };
15
+
16
+ /** The sentence that ends last before the list starts, if nothing but blanks lies between them. */
17
+ export const sentenceRightBefore = (sentences: readonly Sentence[], list: BulletList, source: string): Sentence | undefined => {
18
+ const before = sentences[countEndingBy(sentences, list.span.start) - 1];
19
+ return before !== undefined && ONLY_BLANKS.test(source.slice(before.span.end, list.span.start)) ? before : undefined;
20
+ };
21
+
22
+ /** The sentences that hand the reader straight to a list (以下のとおり説明。 / 主な内容は以下の通り。), one per list at most. Pure. */
23
+ export const listLeadSentences = (sentences: readonly Sentence[], lists: readonly BulletList[], source: string): ReadonlySet<Sentence> =>
24
+ new Set(lists.flatMap((list) => sentenceRightBefore(sentences, list, source) ?? []));
@@ -111,10 +111,33 @@ const isParallel = (source: string, run: readonly Paragraph[]): boolean => {
111
111
  return run.length > 1 && first !== undefined && first.split(" ").length === PARALLEL_WORDS && openings.every((opening) => opening === first);
112
112
  };
113
113
 
114
+ /** How many opening words a key term set in bold may sit within (For **jury duty**, use …). */
115
+ const KEY_TERM_WORDS = 6;
116
+
117
+ /** A phrase set in bold, of a few words: **jury duty**, __vote__. */
118
+ const BOLD_PHRASE = /(\*\*|__)(?=\S)[^*_\n]{1,60}?\S\1/u;
119
+
120
+ const wordCount = (text: string): number => text.split(/\s+/u).filter((word) => word !== "").length;
121
+
122
+ /** Whether a paragraph opens with a key term in bold, among its first words: an entry keyed by its subject. */
123
+ const opensWithBoldKey = (source: string, paragraph: Paragraph): boolean => {
124
+ const text = source.slice(paragraph.span.start, paragraph.span.end).trim();
125
+ const match = BOLD_PHRASE.exec(text);
126
+ return match !== null && wordCount(text.slice(0, match.index)) < KEY_TERM_WORDS;
127
+ };
128
+
129
+ /**
130
+ * Whether most paragraphs of a run open with a key term in bold (For **religious observances**, …; For **jury duty**, …): one
131
+ * entry per case, a list in all but markup.
132
+ */
133
+ const isKeyedByBold = (source: string, run: readonly Paragraph[]): boolean =>
134
+ run.filter((paragraph) => opensWithBoldKey(source, paragraph)).length * 2 > run.length;
135
+
114
136
  /**
115
137
  * Each run of adjacent one-sentence paragraphs, in document order, as the paragraphs it holds. A paragraph of two sentences or
116
138
  * more, a paragraph that does not end as a sentence, opens with an item mark or an enumerator, follows a lead-in as its item or
117
- * is a reference list's entry, or anything between two paragraphs, ends the run. A run of parallel entries is a list, not a run.
139
+ * is a reference list's entry, or anything between two paragraphs, ends the run. A run of parallel entries, or of entries keyed
140
+ * by a term in bold, is a list, not a run.
118
141
  */
119
142
  export const oneSentenceRuns = (source: string, paragraphs: readonly Paragraph[], referenceLists: readonly Span[] = []): Paragraph[][] => {
120
143
  const leadInItems = underLeadIn(source, paragraphs);
@@ -128,5 +151,5 @@ export const oneSentenceRuns = (source: string, paragraphs: readonly Paragraph[]
128
151
  else runs.push([paragraph]);
129
152
  return runs;
130
153
  }, [])
131
- .filter((run) => !isParallel(source, run));
154
+ .filter((run) => !isParallel(source, run) && !isKeyedByBold(source, run));
132
155
  };
@@ -0,0 +1,16 @@
1
+ import type { Section, Sentence } from "./plugin.ts";
2
+
3
+ // A heading that ends with a running time in brackets ((3分00秒), (12:30)) is the title of a video or a recording the page
4
+ // shows, and the text under it is that recording's own caption. Neither is the writer's to shorten or to bring into the
5
+ // page's register. Pure.
6
+
7
+ /** Minutes and seconds in brackets ((3分00秒), (45秒)). */
8
+ const MINUTES_END = /[((]\s*[0-90-9]+(?:分(?:[0-90-9]+秒)?|秒)\s*[))]$/u;
9
+ /** A clock time in brackets ((12:30), (1:02:15)). */
10
+ const CLOCK_END = /[((]\s*\d{1,2}(?::\d{2}){1,2}\s*[))]$/u;
11
+
12
+ export const isRecordingTitle = (heading: string): boolean => MINUTES_END.test(heading.trim()) || CLOCK_END.test(heading.trim());
13
+
14
+ /** The sentences of every section a recording's title heads: its caption, in the recording's words. */
15
+ export const recordingCaptionSentences = (sections: readonly Section[]): Set<Sentence> =>
16
+ new Set(sections.filter((section) => isRecordingTitle(section.unlabeledHeading ?? section.heading)).flatMap((section) => section.sentences));