chaffjs 0.44.0 → 0.46.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 (575) 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/abstract-length.d.ts +5 -1
  18. package/dist/detectors/abstract-length.d.ts.map +1 -1
  19. package/dist/detectors/abstract-length.js +13 -5
  20. package/dist/detectors/abstract-length.js.map +1 -1
  21. package/dist/detectors/acronym-capitals.d.ts +6 -0
  22. package/dist/detectors/acronym-capitals.d.ts.map +1 -0
  23. package/dist/detectors/acronym-capitals.js +30 -0
  24. package/dist/detectors/acronym-capitals.js.map +1 -0
  25. package/dist/detectors/adversative-ga.d.ts +1 -1
  26. package/dist/detectors/adversative-ga.d.ts.map +1 -1
  27. package/dist/detectors/adversative-ga.js +19 -2
  28. package/dist/detectors/adversative-ga.js.map +1 -1
  29. package/dist/detectors/bare-comparative.d.ts +1 -0
  30. package/dist/detectors/bare-comparative.d.ts.map +1 -1
  31. package/dist/detectors/bare-comparative.js +9 -2
  32. package/dist/detectors/bare-comparative.js.map +1 -1
  33. package/dist/detectors/bare-word-list.d.ts +7 -0
  34. package/dist/detectors/bare-word-list.d.ts.map +1 -0
  35. package/dist/detectors/bare-word-list.js +43 -0
  36. package/dist/detectors/bare-word-list.js.map +1 -0
  37. package/dist/detectors/bold-field-label.d.ts +8 -0
  38. package/dist/detectors/bold-field-label.d.ts.map +1 -0
  39. package/dist/detectors/bold-field-label.js +31 -0
  40. package/dist/detectors/bold-field-label.js.map +1 -0
  41. package/dist/detectors/bold-label.d.ts +15 -1
  42. package/dist/detectors/bold-label.d.ts.map +1 -1
  43. package/dist/detectors/bold-label.js +103 -20
  44. package/dist/detectors/bold-label.js.map +1 -1
  45. package/dist/detectors/broken-link.d.ts.map +1 -1
  46. package/dist/detectors/broken-link.js +22 -4
  47. package/dist/detectors/broken-link.js.map +1 -1
  48. package/dist/detectors/byline-list.d.ts +4 -0
  49. package/dist/detectors/byline-list.d.ts.map +1 -0
  50. package/dist/detectors/byline-list.js +19 -0
  51. package/dist/detectors/byline-list.js.map +1 -0
  52. package/dist/detectors/caps-screen-label.d.ts +3 -0
  53. package/dist/detectors/caps-screen-label.d.ts.map +1 -0
  54. package/dist/detectors/caps-screen-label.js +13 -0
  55. package/dist/detectors/caps-screen-label.js.map +1 -0
  56. package/dist/detectors/casual-voice.d.ts +8 -0
  57. package/dist/detectors/casual-voice.d.ts.map +1 -0
  58. package/dist/detectors/casual-voice.js +22 -0
  59. package/dist/detectors/casual-voice.js.map +1 -0
  60. package/dist/detectors/char-shape.d.ts +0 -6
  61. package/dist/detectors/char-shape.d.ts.map +1 -1
  62. package/dist/detectors/char-shape.js +4 -21
  63. package/dist/detectors/char-shape.js.map +1 -1
  64. package/dist/detectors/clause-shape.d.ts +2 -0
  65. package/dist/detectors/clause-shape.d.ts.map +1 -1
  66. package/dist/detectors/clause-shape.js +11 -2
  67. package/dist/detectors/clause-shape.js.map +1 -1
  68. package/dist/detectors/cleft-focus.d.ts +4 -0
  69. package/dist/detectors/cleft-focus.d.ts.map +1 -0
  70. package/dist/detectors/cleft-focus.js +31 -0
  71. package/dist/detectors/cleft-focus.js.map +1 -0
  72. package/dist/detectors/count-per-section.d.ts.map +1 -1
  73. package/dist/detectors/count-per-section.js +6 -2
  74. package/dist/detectors/count-per-section.js.map +1 -1
  75. package/dist/detectors/dangling-opener.d.ts.map +1 -1
  76. package/dist/detectors/dangling-opener.js +10 -1
  77. package/dist/detectors/dangling-opener.js.map +1 -1
  78. package/dist/detectors/date-year.d.ts.map +1 -1
  79. package/dist/detectors/date-year.js +11 -1
  80. package/dist/detectors/date-year.js.map +1 -1
  81. package/dist/detectors/defined-term-form.d.ts.map +1 -1
  82. package/dist/detectors/defined-term-form.js +17 -3
  83. package/dist/detectors/defined-term-form.js.map +1 -1
  84. package/dist/detectors/definition-use.d.ts.map +1 -1
  85. package/dist/detectors/definition-use.js +13 -3
  86. package/dist/detectors/definition-use.js.map +1 -1
  87. package/dist/detectors/document-shape.d.ts +4 -1
  88. package/dist/detectors/document-shape.d.ts.map +1 -1
  89. package/dist/detectors/document-shape.js +12 -2
  90. package/dist/detectors/document-shape.js.map +1 -1
  91. package/dist/detectors/doubled-punctuation.d.ts.map +1 -1
  92. package/dist/detectors/doubled-punctuation.js +24 -1
  93. package/dist/detectors/doubled-punctuation.js.map +1 -1
  94. package/dist/detectors/email-letter.d.ts.map +1 -1
  95. package/dist/detectors/email-letter.js +5 -2
  96. package/dist/detectors/email-letter.js.map +1 -1
  97. package/dist/detectors/email-subject-reference.d.ts +6 -0
  98. package/dist/detectors/email-subject-reference.d.ts.map +1 -0
  99. package/dist/detectors/email-subject-reference.js +31 -0
  100. package/dist/detectors/email-subject-reference.js.map +1 -0
  101. package/dist/detectors/empty-section.d.ts +1 -1
  102. package/dist/detectors/empty-section.d.ts.map +1 -1
  103. package/dist/detectors/empty-section.js +3 -2
  104. package/dist/detectors/empty-section.js.map +1 -1
  105. package/dist/detectors/fact-consistency.js +2 -2
  106. package/dist/detectors/fact-consistency.js.map +1 -1
  107. package/dist/detectors/figure-order.d.ts +1 -1
  108. package/dist/detectors/figure-order.d.ts.map +1 -1
  109. package/dist/detectors/figure-order.js +7 -2
  110. package/dist/detectors/figure-order.js.map +1 -1
  111. package/dist/detectors/fullwidth-alnum.d.ts +2 -2
  112. package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
  113. package/dist/detectors/fullwidth-alnum.js +19 -3
  114. package/dist/detectors/fullwidth-alnum.js.map +1 -1
  115. package/dist/detectors/gram-heading.d.ts.map +1 -1
  116. package/dist/detectors/gram-heading.js +13 -1
  117. package/dist/detectors/gram-heading.js.map +1 -1
  118. package/dist/detectors/heading-case.d.ts.map +1 -1
  119. package/dist/detectors/heading-case.js +6 -1
  120. package/dist/detectors/heading-case.js.map +1 -1
  121. package/dist/detectors/heading-echo.d.ts.map +1 -1
  122. package/dist/detectors/heading-echo.js +20 -7
  123. package/dist/detectors/heading-echo.js.map +1 -1
  124. package/dist/detectors/heading-number.d.ts +7 -0
  125. package/dist/detectors/heading-number.d.ts.map +1 -0
  126. package/dist/detectors/heading-number.js +21 -0
  127. package/dist/detectors/heading-number.js.map +1 -0
  128. package/dist/detectors/heading-numbering.d.ts.map +1 -1
  129. package/dist/detectors/heading-numbering.js +1 -7
  130. package/dist/detectors/heading-numbering.js.map +1 -1
  131. package/dist/detectors/hyphen-name-suffix.d.ts +3 -0
  132. package/dist/detectors/hyphen-name-suffix.d.ts.map +1 -0
  133. package/dist/detectors/hyphen-name-suffix.js +24 -0
  134. package/dist/detectors/hyphen-name-suffix.js.map +1 -0
  135. package/dist/detectors/katakana-density.d.ts.map +1 -1
  136. package/dist/detectors/katakana-density.js +7 -4
  137. package/dist/detectors/katakana-density.js.map +1 -1
  138. package/dist/detectors/lexicon.d.ts +1 -0
  139. package/dist/detectors/lexicon.d.ts.map +1 -1
  140. package/dist/detectors/lexicon.js +19 -1
  141. package/dist/detectors/lexicon.js.map +1 -1
  142. package/dist/detectors/link-shape.d.ts.map +1 -1
  143. package/dist/detectors/link-shape.js +10 -2
  144. package/dist/detectors/link-shape.js.map +1 -1
  145. package/dist/detectors/list-item-phrase.d.ts +20 -0
  146. package/dist/detectors/list-item-phrase.d.ts.map +1 -0
  147. package/dist/detectors/list-item-phrase.js +73 -0
  148. package/dist/detectors/list-item-phrase.js.map +1 -0
  149. package/dist/detectors/list-layout.d.ts +5 -0
  150. package/dist/detectors/list-layout.d.ts.map +1 -1
  151. package/dist/detectors/list-layout.js +12 -0
  152. package/dist/detectors/list-layout.js.map +1 -1
  153. package/dist/detectors/list-lead-in.d.ts.map +1 -1
  154. package/dist/detectors/list-lead-in.js +1 -17
  155. package/dist/detectors/list-lead-in.js.map +1 -1
  156. package/dist/detectors/list-parallel.d.ts.map +1 -1
  157. package/dist/detectors/list-parallel.js +29 -24
  158. package/dist/detectors/list-parallel.js.map +1 -1
  159. package/dist/detectors/lookalike-character.d.ts +2 -1
  160. package/dist/detectors/lookalike-character.d.ts.map +1 -1
  161. package/dist/detectors/lookalike-character.js +14 -1
  162. package/dist/detectors/lookalike-character.js.map +1 -1
  163. package/dist/detectors/mark-shape.d.ts +7 -2
  164. package/dist/detectors/mark-shape.d.ts.map +1 -1
  165. package/dist/detectors/mark-shape.js +41 -14
  166. package/dist/detectors/mark-shape.js.map +1 -1
  167. package/dist/detectors/measured-facts.d.ts +5 -1
  168. package/dist/detectors/measured-facts.d.ts.map +1 -1
  169. package/dist/detectors/measured-facts.js +7 -3
  170. package/dist/detectors/measured-facts.js.map +1 -1
  171. package/dist/detectors/middle-dot.d.ts +12 -0
  172. package/dist/detectors/middle-dot.d.ts.map +1 -1
  173. package/dist/detectors/middle-dot.js +46 -0
  174. package/dist/detectors/middle-dot.js.map +1 -1
  175. package/dist/detectors/missing-final-period.d.ts.map +1 -1
  176. package/dist/detectors/missing-final-period.js +13 -1
  177. package/dist/detectors/missing-final-period.js.map +1 -1
  178. package/dist/detectors/name-variant.d.ts.map +1 -1
  179. package/dist/detectors/name-variant.js +2 -1
  180. package/dist/detectors/name-variant.js.map +1 -1
  181. package/dist/detectors/named-by-context.d.ts +13 -0
  182. package/dist/detectors/named-by-context.d.ts.map +1 -0
  183. package/dist/detectors/named-by-context.js +10 -0
  184. package/dist/detectors/named-by-context.js.map +1 -0
  185. package/dist/detectors/number-style.d.ts +2 -0
  186. package/dist/detectors/number-style.d.ts.map +1 -1
  187. package/dist/detectors/number-style.js +19 -4
  188. package/dist/detectors/number-style.js.map +1 -1
  189. package/dist/detectors/numeral-opener.d.ts +1 -1
  190. package/dist/detectors/numeral-opener.d.ts.map +1 -1
  191. package/dist/detectors/numeral-opener.js +4 -2
  192. package/dist/detectors/numeral-opener.js.map +1 -1
  193. package/dist/detectors/open-end-names.d.ts +2 -0
  194. package/dist/detectors/open-end-names.d.ts.map +1 -1
  195. package/dist/detectors/open-end-names.js +8 -1
  196. package/dist/detectors/open-end-names.js.map +1 -1
  197. package/dist/detectors/ordinary-phrase.d.ts +5 -0
  198. package/dist/detectors/ordinary-phrase.d.ts.map +1 -1
  199. package/dist/detectors/ordinary-phrase.js +10 -0
  200. package/dist/detectors/ordinary-phrase.js.map +1 -1
  201. package/dist/detectors/orthographic-variant.js +2 -2
  202. package/dist/detectors/orthographic-variant.js.map +1 -1
  203. package/dist/detectors/output-lead-in.d.ts +3 -0
  204. package/dist/detectors/output-lead-in.d.ts.map +1 -0
  205. package/dist/detectors/output-lead-in.js +26 -0
  206. package/dist/detectors/output-lead-in.js.map +1 -0
  207. package/dist/detectors/outside-announced-list.d.ts.map +1 -1
  208. package/dist/detectors/outside-announced-list.js +6 -1
  209. package/dist/detectors/outside-announced-list.js.map +1 -1
  210. package/dist/detectors/oxford-comma.d.ts.map +1 -1
  211. package/dist/detectors/oxford-comma.js +3 -1
  212. package/dist/detectors/oxford-comma.js.map +1 -1
  213. package/dist/detectors/paragraph-restatement.d.ts +4 -1
  214. package/dist/detectors/paragraph-restatement.d.ts.map +1 -1
  215. package/dist/detectors/paragraph-restatement.js +17 -2
  216. package/dist/detectors/paragraph-restatement.js.map +1 -1
  217. package/dist/detectors/person-consistency.d.ts +2 -1
  218. package/dist/detectors/person-consistency.d.ts.map +1 -1
  219. package/dist/detectors/person-consistency.js +11 -2
  220. package/dist/detectors/person-consistency.js.map +1 -1
  221. package/dist/detectors/placeholder-context.d.ts +16 -0
  222. package/dist/detectors/placeholder-context.d.ts.map +1 -0
  223. package/dist/detectors/placeholder-context.js +57 -0
  224. package/dist/detectors/placeholder-context.js.map +1 -0
  225. package/dist/detectors/placeholder-text.d.ts +2 -0
  226. package/dist/detectors/placeholder-text.d.ts.map +1 -1
  227. package/dist/detectors/placeholder-text.js +1 -1
  228. package/dist/detectors/placeholder-text.js.map +1 -1
  229. package/dist/detectors/quoted-title-line.d.ts +6 -0
  230. package/dist/detectors/quoted-title-line.d.ts.map +1 -0
  231. package/dist/detectors/quoted-title-line.js +14 -0
  232. package/dist/detectors/quoted-title-line.js.map +1 -0
  233. package/dist/detectors/register-interview.d.ts +4 -0
  234. package/dist/detectors/register-interview.d.ts.map +1 -0
  235. package/dist/detectors/register-interview.js +19 -0
  236. package/dist/detectors/register-interview.js.map +1 -0
  237. package/dist/detectors/registry/colloquial-opener-pile.d.ts +3 -0
  238. package/dist/detectors/registry/colloquial-opener-pile.d.ts.map +1 -0
  239. package/dist/detectors/registry/colloquial-opener-pile.js +3 -0
  240. package/dist/detectors/registry/colloquial-opener-pile.js.map +1 -0
  241. package/dist/detectors/registry/middle-dot.js +1 -1
  242. package/dist/detectors/repeated-head.d.ts.map +1 -1
  243. package/dist/detectors/repeated-head.js +23 -4
  244. package/dist/detectors/repeated-head.js.map +1 -1
  245. package/dist/detectors/request-owner.d.ts +3 -1
  246. package/dist/detectors/request-owner.d.ts.map +1 -1
  247. package/dist/detectors/request-owner.js +5 -2
  248. package/dist/detectors/request-owner.js.map +1 -1
  249. package/dist/detectors/run-together.d.ts +3 -0
  250. package/dist/detectors/run-together.d.ts.map +1 -0
  251. package/dist/detectors/run-together.js +13 -0
  252. package/dist/detectors/run-together.js.map +1 -0
  253. package/dist/detectors/sentence-counts.d.ts +8 -2
  254. package/dist/detectors/sentence-counts.d.ts.map +1 -1
  255. package/dist/detectors/sentence-counts.js +32 -7
  256. package/dist/detectors/sentence-counts.js.map +1 -1
  257. package/dist/detectors/sentence-ending.d.ts +2 -0
  258. package/dist/detectors/sentence-ending.d.ts.map +1 -1
  259. package/dist/detectors/sentence-ending.js +8 -2
  260. package/dist/detectors/sentence-ending.js.map +1 -1
  261. package/dist/detectors/sentence-parts.d.ts +10 -1
  262. package/dist/detectors/sentence-parts.d.ts.map +1 -1
  263. package/dist/detectors/sentence-parts.js +17 -2
  264. package/dist/detectors/sentence-parts.js.map +1 -1
  265. package/dist/detectors/signals.d.ts.map +1 -1
  266. package/dist/detectors/signals.js +10 -1
  267. package/dist/detectors/signals.js.map +1 -1
  268. package/dist/detectors/space-before-punctuation.d.ts +2 -2
  269. package/dist/detectors/space-before-punctuation.d.ts.map +1 -1
  270. package/dist/detectors/space-before-punctuation.js +13 -2
  271. package/dist/detectors/space-before-punctuation.js.map +1 -1
  272. package/dist/detectors/stray-space.js +1 -1
  273. package/dist/detectors/stray-space.js.map +1 -1
  274. package/dist/detectors/structure-tree.d.ts.map +1 -1
  275. package/dist/detectors/structure-tree.js +2 -1
  276. package/dist/detectors/structure-tree.js.map +1 -1
  277. package/dist/detectors/structure.d.ts +1 -0
  278. package/dist/detectors/structure.d.ts.map +1 -1
  279. package/dist/detectors/structure.js +8 -3
  280. package/dist/detectors/structure.js.map +1 -1
  281. package/dist/detectors/superlative-context.d.ts +7 -0
  282. package/dist/detectors/superlative-context.d.ts.map +1 -1
  283. package/dist/detectors/superlative-context.js +6 -0
  284. package/dist/detectors/superlative-context.js.map +1 -1
  285. package/dist/detectors/technical-docs.d.ts.map +1 -1
  286. package/dist/detectors/technical-docs.js +5 -1
  287. package/dist/detectors/technical-docs.js.map +1 -1
  288. package/dist/detectors/template-sections.d.ts +1 -0
  289. package/dist/detectors/template-sections.d.ts.map +1 -1
  290. package/dist/detectors/template-sections.js +1 -1
  291. package/dist/detectors/template-sections.js.map +1 -1
  292. package/dist/detectors/token-shape.d.ts.map +1 -1
  293. package/dist/detectors/token-shape.js +16 -3
  294. package/dist/detectors/token-shape.js.map +1 -1
  295. package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
  296. package/dist/detectors/unbalanced-bracket.js +5 -1
  297. package/dist/detectors/unbalanced-bracket.js.map +1 -1
  298. package/dist/detectors/undefined-term.d.ts.map +1 -1
  299. package/dist/detectors/undefined-term.js +5 -1
  300. package/dist/detectors/undefined-term.js.map +1 -1
  301. package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
  302. package/dist/detectors/unfilled-placeholder.js +18 -1
  303. package/dist/detectors/unfilled-placeholder.js.map +1 -1
  304. package/dist/detectors/vague-density.d.ts.map +1 -1
  305. package/dist/detectors/vague-density.js +13 -1
  306. package/dist/detectors/vague-density.js.map +1 -1
  307. package/dist/detectors/verse-block.d.ts +4 -0
  308. package/dist/detectors/verse-block.d.ts.map +1 -0
  309. package/dist/detectors/verse-block.js +40 -0
  310. package/dist/detectors/verse-block.js.map +1 -0
  311. package/dist/document.d.ts.map +1 -1
  312. package/dist/document.js +1 -0
  313. package/dist/document.js.map +1 -1
  314. package/dist/email-parts.d.ts +2 -0
  315. package/dist/email-parts.d.ts.map +1 -1
  316. package/dist/email-parts.js +10 -7
  317. package/dist/email-parts.js.map +1 -1
  318. package/dist/eval.d.ts.map +1 -1
  319. package/dist/eval.js +3 -0
  320. package/dist/eval.js.map +1 -1
  321. package/dist/front-matter.d.ts +3 -0
  322. package/dist/front-matter.d.ts.map +1 -0
  323. package/dist/front-matter.js +13 -0
  324. package/dist/front-matter.js.map +1 -0
  325. package/dist/genre-check.js +1 -1
  326. package/dist/genre-check.js.map +1 -1
  327. package/dist/genre.d.ts +0 -2
  328. package/dist/genre.d.ts.map +1 -1
  329. package/dist/genre.js +1 -12
  330. package/dist/genre.js.map +1 -1
  331. package/dist/labelled-note-paragraphs.d.ts +4 -0
  332. package/dist/labelled-note-paragraphs.d.ts.map +1 -0
  333. package/dist/labelled-note-paragraphs.js +21 -0
  334. package/dist/labelled-note-paragraphs.js.map +1 -0
  335. package/dist/list-lead-sentence.d.ts +6 -0
  336. package/dist/list-lead-sentence.d.ts.map +1 -0
  337. package/dist/list-lead-sentence.js +20 -0
  338. package/dist/list-lead-sentence.js.map +1 -0
  339. package/dist/paragraph-runs.d.ts +2 -1
  340. package/dist/paragraph-runs.d.ts.map +1 -1
  341. package/dist/paragraph-runs.js +19 -2
  342. package/dist/paragraph-runs.js.map +1 -1
  343. package/dist/plugin.d.ts +2 -0
  344. package/dist/plugin.d.ts.map +1 -1
  345. package/dist/reasons.d.ts +2 -0
  346. package/dist/reasons.d.ts.map +1 -1
  347. package/dist/reasons.js +2 -0
  348. package/dist/reasons.js.map +1 -1
  349. package/dist/recording-title.d.ts +5 -0
  350. package/dist/recording-title.d.ts.map +1 -0
  351. package/dist/recording-title.js +11 -0
  352. package/dist/recording-title.js.map +1 -0
  353. package/dist/rule-of-three.d.ts +7 -2
  354. package/dist/rule-of-three.d.ts.map +1 -1
  355. package/dist/rule-of-three.js +11 -3
  356. package/dist/rule-of-three.js.map +1 -1
  357. package/dist/run.d.ts.map +1 -1
  358. package/dist/run.js +4 -1
  359. package/dist/run.js.map +1 -1
  360. package/dist/sentence-load.d.ts +2 -1
  361. package/dist/sentence-load.d.ts.map +1 -1
  362. package/dist/sentence-load.js +56 -2
  363. package/dist/sentence-load.js.map +1 -1
  364. package/dist/stray-space.d.ts +5 -2
  365. package/dist/stray-space.d.ts.map +1 -1
  366. package/dist/stray-space.js +24 -2
  367. package/dist/stray-space.js.map +1 -1
  368. package/dist/structure/cited-elsewhere.d.ts +5 -2
  369. package/dist/structure/cited-elsewhere.d.ts.map +1 -1
  370. package/dist/structure/cited-elsewhere.js +16 -6
  371. package/dist/structure/cited-elsewhere.js.map +1 -1
  372. package/dist/structure/definition-use.d.ts +2 -1
  373. package/dist/structure/definition-use.d.ts.map +1 -1
  374. package/dist/structure/definition-use.js +10 -2
  375. package/dist/structure/definition-use.js.map +1 -1
  376. package/dist/structure/due-column.d.ts +5 -0
  377. package/dist/structure/due-column.d.ts.map +1 -0
  378. package/dist/structure/due-column.js +30 -0
  379. package/dist/structure/due-column.js.map +1 -0
  380. package/dist/structure/generic-role.d.ts +1 -0
  381. package/dist/structure/generic-role.d.ts.map +1 -1
  382. package/dist/structure/generic-role.js +6 -0
  383. package/dist/structure/generic-role.js.map +1 -1
  384. package/dist/structure/issues.js +1 -1
  385. package/dist/structure/issues.js.map +1 -1
  386. package/dist/structure/party-role.d.ts.map +1 -1
  387. package/dist/structure/party-role.js +4 -2
  388. package/dist/structure/party-role.js.map +1 -1
  389. package/dist/title-case-name.d.ts +5 -0
  390. package/dist/title-case-name.d.ts.map +1 -1
  391. package/dist/title-case-name.js +14 -0
  392. package/dist/title-case-name.js.map +1 -1
  393. package/package.json +3 -3
  394. package/rules/abstract-length.yaml +2 -2
  395. package/rules/adversative-ga-repeat.yaml +2 -2
  396. package/rules/all-caps-shouting.yaml +2 -2
  397. package/rules/attachment-not-attached.yaml +11 -6
  398. package/rules/bare-url-mix.yaml +2 -2
  399. package/rules/bold-density.yaml +2 -2
  400. package/rules/bold-label-list.yaml +22 -6
  401. package/rules/bracket-width-consistency.yaml +2 -2
  402. package/rules/clause-chain.yaml +2 -2
  403. package/rules/closing-cliche.yaml +2 -2
  404. package/rules/code-fence-language-mix.yaml +2 -2
  405. package/rules/colloquial-opener.yaml +3 -3
  406. package/rules/comparative-without-baseline.yaml +2 -2
  407. package/rules/dangling-participle.yaml +2 -2
  408. package/rules/date-order.yaml +2 -2
  409. package/rules/defined-term-form.yaml +2 -2
  410. package/rules/demonstrative-opener-run.yaml +2 -2
  411. package/rules/doubled-punctuation.yaml +2 -2
  412. package/rules/duration-mismatch.yaml +2 -2
  413. package/rules/email-subject-length.yaml +2 -2
  414. package/rules/emoji-density.yaml +2 -2
  415. package/rules/empty-intensifier.yaml +2 -2
  416. package/rules/empty-section.yaml +2 -2
  417. package/rules/figure-reference-order.yaml +2 -2
  418. package/rules/fullwidth-alnum-consistency.yaml +2 -2
  419. package/rules/hyphen-as-dash.yaml +2 -2
  420. package/rules/katakana-density.yaml +2 -2
  421. package/rules/list-item-form-mix.yaml +2 -2
  422. package/rules/lookalike-character.yaml +8 -5
  423. package/rules/max-kanji-continuous.yaml +4 -0
  424. package/rules/max-ten.yaml +3 -3
  425. package/rules/missing-final-period.yaml +2 -2
  426. package/rules/name-variant.yaml +2 -2
  427. package/rules/ngram-repetition.yaml +2 -2
  428. package/rules/no-lead.yaml +2 -2
  429. package/rules/no-mixed-desumasu.yaml +3 -2
  430. package/rules/no-nakaguro-parallel.yaml +2 -2
  431. package/rules/number-style-consistency.yaml +2 -2
  432. package/rules/numeral-sentence-start.yaml +2 -2
  433. package/rules/one-sentence-paragraph-run.yaml +2 -2
  434. package/rules/orthographic-variant.yaml +2 -2
  435. package/rules/outside-announced-list.yaml +2 -2
  436. package/rules/oxford-comma-consistency.yaml +2 -2
  437. package/rules/paragraph-length-variance.yaml +27 -3
  438. package/rules/paragraph-restatement.yaml +2 -2
  439. package/rules/party-role-name.yaml +2 -2
  440. package/rules/person-consistency.yaml +2 -2
  441. package/rules/preamble-length.yaml +2 -2
  442. package/rules/repeated-conjunction.yaml +2 -2
  443. package/rules/repeated-sentence-ending.yaml +2 -2
  444. package/rules/repeated-sentence-head.yaml +2 -2
  445. package/rules/request-without-deadline.yaml +2 -2
  446. package/rules/requirement-smell.yaml +2 -2
  447. package/rules/rule-of-three.yaml +2 -2
  448. package/rules/sentence-spacing-consistency.yaml +2 -2
  449. package/rules/space-before-punctuation.yaml +2 -2
  450. package/rules/stray-space.yaml +7 -4
  451. package/rules/summary-fact-mismatch.yaml +2 -2
  452. package/rules/taigen-dome-in-prose.yaml +2 -2
  453. package/rules/teki-overuse.yaml +4 -2
  454. package/rules/title-case-consistency.yaml +2 -2
  455. package/rules/title-length.yaml +2 -2
  456. package/rules/total-mismatch.yaml +1 -1
  457. package/rules/unbalanced-bracket.yaml +3 -3
  458. package/rules/undefined-term.yaml +2 -2
  459. package/rules/unfilled-placeholder.yaml +2 -2
  460. package/rules/unqualified-superlative.yaml +2 -2
  461. package/rules/use-before-definition.yaml +2 -2
  462. package/rules/vague-word-density.yaml +2 -2
  463. package/rules/very-adjective.yaml +1 -1
  464. package/rules/warning-without-action.yaml +2 -2
  465. package/rules/yori-as-from.yaml +1 -0
  466. package/src/announced-list.ts +12 -3
  467. package/src/body-section.ts +19 -0
  468. package/src/derived/durations.ts +3 -2
  469. package/src/derived/marked-dates.ts +4 -0
  470. package/src/detectors/abstract-length.ts +16 -6
  471. package/src/detectors/acronym-capitals.ts +30 -0
  472. package/src/detectors/adversative-ga.ts +24 -2
  473. package/src/detectors/bare-comparative.ts +12 -2
  474. package/src/detectors/bare-word-list.ts +61 -0
  475. package/src/detectors/bold-field-label.ts +33 -0
  476. package/src/detectors/bold-label.ts +129 -20
  477. package/src/detectors/broken-link.ts +23 -2
  478. package/src/detectors/byline-list.ts +24 -0
  479. package/src/detectors/caps-screen-label.ts +15 -0
  480. package/src/detectors/casual-voice.ts +30 -0
  481. package/src/detectors/char-shape.ts +8 -22
  482. package/src/detectors/clause-shape.ts +14 -3
  483. package/src/detectors/cleft-focus.ts +40 -0
  484. package/src/detectors/count-per-section.ts +6 -2
  485. package/src/detectors/dangling-opener.ts +12 -1
  486. package/src/detectors/date-year.ts +12 -1
  487. package/src/detectors/defined-term-form.ts +19 -3
  488. package/src/detectors/definition-use.ts +23 -4
  489. package/src/detectors/document-shape.ts +16 -2
  490. package/src/detectors/doubled-punctuation.ts +26 -1
  491. package/src/detectors/email-letter.ts +5 -3
  492. package/src/detectors/email-subject-reference.ts +36 -0
  493. package/src/detectors/empty-section.ts +3 -2
  494. package/src/detectors/fact-consistency.ts +2 -2
  495. package/src/detectors/figure-order.ts +8 -2
  496. package/src/detectors/fullwidth-alnum.ts +24 -3
  497. package/src/detectors/gram-heading.ts +15 -1
  498. package/src/detectors/heading-case.ts +7 -1
  499. package/src/detectors/heading-echo.ts +21 -8
  500. package/src/detectors/heading-number.ts +20 -0
  501. package/src/detectors/heading-numbering.ts +1 -9
  502. package/src/detectors/hyphen-name-suffix.ts +30 -0
  503. package/src/detectors/katakana-density.ts +8 -4
  504. package/src/detectors/lexicon.ts +18 -1
  505. package/src/detectors/link-shape.ts +16 -2
  506. package/src/detectors/list-item-phrase.ts +86 -0
  507. package/src/detectors/list-layout.ts +17 -0
  508. package/src/detectors/list-lead-in.ts +1 -19
  509. package/src/detectors/list-parallel.ts +31 -28
  510. package/src/detectors/lookalike-character.ts +19 -2
  511. package/src/detectors/mark-shape.ts +46 -9
  512. package/src/detectors/measured-facts.ts +11 -4
  513. package/src/detectors/middle-dot.ts +54 -0
  514. package/src/detectors/missing-final-period.ts +14 -1
  515. package/src/detectors/name-variant.ts +2 -1
  516. package/src/detectors/named-by-context.ts +15 -0
  517. package/src/detectors/number-style.ts +26 -4
  518. package/src/detectors/numeral-opener.ts +4 -2
  519. package/src/detectors/open-end-names.ts +11 -1
  520. package/src/detectors/ordinary-phrase.ts +10 -0
  521. package/src/detectors/orthographic-variant.ts +2 -2
  522. package/src/detectors/output-lead-in.ts +28 -0
  523. package/src/detectors/outside-announced-list.ts +6 -1
  524. package/src/detectors/oxford-comma.ts +3 -1
  525. package/src/detectors/paragraph-restatement.ts +17 -2
  526. package/src/detectors/person-consistency.ts +14 -2
  527. package/src/detectors/placeholder-context.ts +72 -0
  528. package/src/detectors/placeholder-text.ts +1 -1
  529. package/src/detectors/quoted-title-line.ts +13 -0
  530. package/src/detectors/register-interview.ts +22 -0
  531. package/src/detectors/registry/colloquial-opener-pile.ts +4 -0
  532. package/src/detectors/registry/middle-dot.ts +1 -1
  533. package/src/detectors/repeated-head.ts +32 -6
  534. package/src/detectors/request-owner.ts +5 -2
  535. package/src/detectors/run-together.ts +15 -0
  536. package/src/detectors/sentence-counts.ts +34 -7
  537. package/src/detectors/sentence-ending.ts +13 -2
  538. package/src/detectors/sentence-parts.ts +20 -2
  539. package/src/detectors/signals.ts +11 -1
  540. package/src/detectors/space-before-punctuation.ts +24 -4
  541. package/src/detectors/stray-space.ts +1 -1
  542. package/src/detectors/structure-tree.ts +12 -9
  543. package/src/detectors/structure.ts +7 -3
  544. package/src/detectors/superlative-context.ts +10 -0
  545. package/src/detectors/technical-docs.ts +5 -3
  546. package/src/detectors/template-sections.ts +1 -1
  547. package/src/detectors/token-shape.ts +19 -4
  548. package/src/detectors/unbalanced-bracket.ts +9 -1
  549. package/src/detectors/undefined-term.ts +5 -1
  550. package/src/detectors/unfilled-placeholder.ts +22 -1
  551. package/src/detectors/vague-density.ts +15 -2
  552. package/src/detectors/verse-block.ts +48 -0
  553. package/src/document.ts +1 -0
  554. package/src/email-parts.ts +16 -7
  555. package/src/eval.ts +2 -0
  556. package/src/front-matter.ts +14 -0
  557. package/src/genre-check.ts +1 -1
  558. package/src/genre.ts +1 -15
  559. package/src/labelled-note-paragraphs.ts +30 -0
  560. package/src/list-lead-sentence.ts +24 -0
  561. package/src/paragraph-runs.ts +25 -2
  562. package/src/plugin.ts +2 -0
  563. package/src/reasons.ts +4 -0
  564. package/src/recording-title.ts +16 -0
  565. package/src/rule-of-three.ts +22 -5
  566. package/src/run.ts +3 -1
  567. package/src/sentence-load.ts +68 -2
  568. package/src/stray-space.ts +37 -6
  569. package/src/structure/cited-elsewhere.ts +18 -6
  570. package/src/structure/definition-use.ts +10 -1
  571. package/src/structure/due-column.ts +33 -0
  572. package/src/structure/generic-role.ts +8 -0
  573. package/src/structure/issues.ts +1 -1
  574. package/src/structure/party-role.ts +3 -2
  575. package/src/title-case-name.ts +19 -0
@@ -59,3 +59,7 @@ export const markedPair = <T extends Span>(text: MarkText, sentence: Span, dates
59
59
  const [end] = ends;
60
60
  return starts.length === 1 && ends.length === 1 && start !== undefined && end !== undefined && start !== end ? [start, end] : undefined;
61
61
  };
62
+
63
+ /** 二つの日付がどちらも始まりの印で、終わりの印が無い(new tenancies from 1 July 2020 and existing ones from 1 April 2021): 二つの組の始まりで、期間の両端ではない。 */
64
+ export const bothStarts = (text: MarkText, dates: readonly [Span, Span], length: Span): boolean =>
65
+ dates.every((date) => isStart(text, date)) && !dates.some((date) => isEnd(text, date, length));
@@ -41,11 +41,15 @@ export const headLabel = (text: string): { readonly label: string; readonly leng
41
41
 
42
42
  export type AbstractSpan = { readonly label: number; readonly body: Span };
43
43
 
44
- type Words = { readonly abstracts: ReadonlySet<string>; readonly sections: ReadonlySet<string> };
44
+ type Words = { readonly abstracts: ReadonlySet<string>; readonly sections: ReadonlySet<string>; readonly bookends: ReadonlySet<string> };
45
+
46
+ /** The lexicon group of a section that only opens or closes a text (はじめに, おわりに), which an essay has as well as a paper. */
47
+ const BOOKEND = "bookend";
45
48
 
46
49
  const wordsOf = (doc: ProseDocument): Words => {
47
- const set = (id: string): ReadonlySet<string> => new Set((doc.lexicons[id] ?? []).map((entry) => entry.pattern.toLowerCase()));
48
- return { abstracts: set("abstract-heading"), sections: set("paper-section-heading") };
50
+ const set = (id: string, group?: string): ReadonlySet<string> =>
51
+ new Set((doc.lexicons[id] ?? []).filter((entry) => group === undefined || entry.group === group).map((entry) => entry.pattern.toLowerCase()));
52
+ return { abstracts: set("abstract-heading"), sections: set("paper-section-heading"), bookends: set("paper-section-heading", BOOKEND) };
49
53
  };
50
54
 
51
55
  /** Abstracts under a heading of their own: the text up to the next heading. */
@@ -75,11 +79,17 @@ export const abstractsOf = (doc: ProseDocument): AbstractSpan[] => {
75
79
  return found.filter((abstract, index) => found.findIndex((other) => other.label === abstract.label) === index);
76
80
  };
77
81
 
78
- /** The first heading that names a paper's section, when there are MIN_SECTIONS of them; undefined otherwise. */
82
+ /**
83
+ * The first heading that names a paper's section, when there are MIN_SECTIONS of them and one is more than an opening or a
84
+ * closing; undefined otherwise. An article with only はじめに and おわりに around its own sections is an essay or a review,
85
+ * which carries no abstract.
86
+ */
79
87
  export const firstSectionHeading = (doc: ProseDocument): number | undefined => {
80
88
  const words = wordsOf(doc);
81
- const sections = (doc.markup?.headings ?? []).filter((heading) => words.sections.has(labelOf(heading.text)));
82
- return sections.length >= MIN_SECTIONS ? sections[0]?.start : undefined;
89
+ const labels = (doc.markup?.headings ?? []).map((heading) => ({ start: heading.start, label: labelOf(heading.text) }));
90
+ const sections = labels.filter(({ label }) => words.sections.has(label));
91
+ const hasBody = sections.some(({ label }) => !words.bookends.has(label));
92
+ return sections.length >= MIN_SECTIONS && hasBody ? sections[0]?.start : undefined;
83
93
  };
84
94
 
85
95
  type Measure = { readonly size: number; readonly limit: number | undefined; readonly unit: LengthUnit };
@@ -0,0 +1,30 @@
1
+ // A word whose inner capitals spell out an acronym in the bracket after it: "axle (Axis-guided eXperience ELicitation)".
2
+ // The writer capitalised those letters on purpose to show where the acronym comes from; the word is not a variant of the
3
+ // same word written plainly elsewhere. Pure.
4
+
5
+ const INNER_CAPITAL = /^.\p{Ll}*\p{Lu}/u;
6
+ const ACRONYM_BEFORE = /(?:^|[^\p{L}])(\p{L}{2,8})\s*\($/u;
7
+ const CAPITAL = /\p{Lu}/gu;
8
+
9
+ const sortedLetters = (letters: string): string => [...letters.toLowerCase()].toSorted((left, right) => left.localeCompare(right)).join("");
10
+
11
+ /** The bracket that holds `offset` on its line: where it opens, and its text up to the closing bracket. */
12
+ const bracketAround = (source: string, offset: number): { readonly open: number; readonly text: string } | undefined => {
13
+ const lineStart = source.lastIndexOf("\n", offset - 1) + 1;
14
+ const open = source.lastIndexOf("(", offset);
15
+ const close = source.indexOf(")", offset);
16
+ if (open < lineStart || close === -1 || source.slice(open + 1, offset).includes(")") || source.slice(open, close).includes("\n")) return undefined;
17
+ return { open, text: source.slice(open + 1, close) };
18
+ };
19
+
20
+ /**
21
+ * Whether the word at `offset` has a capital past its first letter and sits in a bracket right after a short word whose
22
+ * letters are the bracket's capitals (axle and Axis-guided eXperience ELicitation: a, x, e, l).
23
+ */
24
+ export const spellsAcronym = (source: string, offset: number, word: string): boolean => {
25
+ if (!INNER_CAPITAL.test(word)) return false;
26
+ const bracket = bracketAround(source, offset);
27
+ if (bracket === undefined) return false;
28
+ const acronym = ACRONYM_BEFORE.exec(source.slice(Math.max(0, bracket.open - 12), bracket.open + 1))?.[1];
29
+ return acronym !== undefined && sortedLetters(acronym) === sortedLetters((bracket.text.match(CAPITAL) ?? []).join(""));
30
+ };
@@ -22,5 +22,27 @@ const followsVolitional = (at: number, tokens: readonly Token[]): boolean => {
22
22
  /** A が with only punctuation after it (思えるんですが……。) softens the sentence's end; it joins no second clause. */
23
23
  const endsSentence = (at: number, tokens: readonly Token[]): boolean => tokens.slice(at + 1).every((token) => isSpace(token) || CLOSING_POS.has(token.pos));
24
24
 
25
- /** The conjunctive が at `at` contrasts two clauses: not a volitional's concession, not a softened end. */
26
- export const isContrastiveGa = (at: number, tokens: readonly Token[]): boolean => !followsVolitional(at, tokens) && !endsSentence(at, tokens);
25
+ const NOMINAL_POS: ReadonlySet<string> = new Set(["NOUN", "PRON", "PROPN"]);
26
+
27
+ const isNominal = (token: Token | undefined): boolean => token !== undefined && NOMINAL_POS.has(token.pos);
28
+ const isComma = (token: Token | undefined): boolean => token?.surface === "、" || token?.surface === ",";
29
+
30
+ /**
31
+ * A Kyushu dialect topic しや (あんたしやが, ムツシユウしやが): the parser reads a verb し with no particle after a bare noun,
32
+ * then が as conjunctive; the が marks the noun.
33
+ */
34
+ const followsDialectTopic = (at: number, tokens: readonly Token[]): boolean => {
35
+ const [noun, verb, auxiliary] = [tokens[at - 3], tokens[at - 2], tokens[at - 1]];
36
+ return isNominal(noun) && verb?.surface === "し" && verb.pos === "VERB" && auxiliary?.surface === "や" && auxiliary.pos === "AUX";
37
+ };
38
+
39
+ /** A copula cut from its noun by a comma (恋、では無いが): the writer takes back the word just said; no clause is contrasted. */
40
+ const takesBackWord = (at: number, tokens: readonly Token[]): boolean => {
41
+ const comma = tokens.findLastIndex((token, index) => index < at && isComma(token));
42
+ const [copula, topic] = [tokens[comma + 1], tokens[comma + 2]];
43
+ return comma > 0 && isNominal(tokens[comma - 1]) && copula?.surface === "で" && copula.pos === "AUX" && topic?.surface === "は";
44
+ };
45
+
46
+ /** The conjunctive が at `at` contrasts two clauses: not a volitional's concession, not a softened end, not a misread particle. */
47
+ export const isContrastiveGa = (at: number, tokens: readonly Token[]): boolean =>
48
+ !followsVolitional(at, tokens) && !endsSentence(at, tokens) && !followsDialectTopic(at, tokens) && !takesBackWord(at, tokens);
@@ -34,6 +34,7 @@ export type ComparativeLists = {
34
34
  readonly pointers: ReadonlySet<string>;
35
35
  readonly causes: ReadonlySet<string>;
36
36
  readonly openers: ReadonlySet<string>;
37
+ readonly layers: ReadonlySet<string>;
37
38
  };
38
39
 
39
40
  /** head は英語の比べた形の前の述語(is faster の is)。 */
@@ -102,9 +103,16 @@ const aimAfterOf = (tokens: readonly Token[], at: number, aims: ReadonlySet<stri
102
103
  return length > 0 && tokens[of]?.surface === "の" && runsFrom(tokens, of + 1).some(({ run }) => aims.has(run));
103
104
  };
104
105
 
106
+ /** 程度を言う語(at)の後ろの語の位置。形容動詞の語幹なら、語尾(な、に)を飛ばす。 */
107
+ const afterGradable = (tokens: readonly Token[], at: number): number =>
108
+ tokens[at]?.pos === "NOUN" && ADJECTIVAL_TAIL.has(tokens[at + 1]?.surface ?? "") ? at + 2 : at + 1;
109
+
110
+ /** 程度を言う語(at)の後ろが、層の並びの中の位置を言う語か(より低い層)。相手は、いま述べている層。 */
111
+ const namesLayer = (tokens: readonly Token[], at: number, layers: ReadonlySet<string>): boolean => layers.has(tokens[afterGradable(tokens, at)]?.surface ?? "");
112
+
105
113
  /** 程度を言う語(at)の後ろが、今より良くする目当てか(より良い社会、より豊かな暮らし、より良いものにする、より良い共生の実現)。 */
106
114
  const namesAim = (tokens: readonly Token[], at: number, aims: ReadonlySet<string>): boolean => {
107
- const next = tokens[at]?.pos === "NOUN" && ADJECTIVAL_TAIL.has(tokens[at + 1]?.surface ?? "") ? at + 2 : at + 1;
115
+ const next = afterGradable(tokens, at);
108
116
  return (
109
117
  runsFrom(tokens, next).some(({ run, after }) => aims.has(run) && !headsCompound(tokens, after)) ||
110
118
  endsInAim(tokens, next, aims) ||
@@ -118,7 +126,8 @@ const markedAt = (tokens: readonly Token[], at: number, lists: ComparativeLists)
118
126
  if (marker?.pos !== "ADV" || !lists.markers.has(marker.surface) || word === undefined || lists.exempt.has(word.surface)) return undefined;
119
127
  const previous = tokens[at - 1];
120
128
  if (previous !== undefined && !OPENS_WORD.has(previous.pos)) return undefined;
121
- return isGradable(tokens, at + 1) && !namesAim(tokens, at + 1, lists.aims) ? { first: marker, last: word } : undefined;
129
+ if (!isGradable(tokens, at + 1) || namesAim(tokens, at + 1, lists.aims) || namesLayer(tokens, at + 1, lists.layers)) return undefined;
130
+ return { first: marker, last: word };
122
131
  };
123
132
 
124
133
  /** 比べた形の後ろで節が終わるか。読点の後ろに形容詞が続けば、名詞の前に並べた修飾語(better, more predictable results)。 */
@@ -245,6 +254,7 @@ export const listsOf = (lexicon: Lexicon): ComparativeLists => ({
245
254
  pointers: new Set(groupOf(lexicon, "pointer")),
246
255
  causes: new Set(groupOf(lexicon, "cause")),
247
256
  openers: new Set(groupOf(lexicon, "opener")),
257
+ layers: new Set(groupOf(lexicon, "layer")),
248
258
  });
249
259
 
250
260
  /** 鉤括弧の中の比較(「給与所得の確定申告がさらに簡単に!」ページ)は題や語を挙げたもので、書き手の比較ではない。 */
@@ -0,0 +1,61 @@
1
+ import type { Token } from "../plugin.ts";
2
+
3
+ /** An item longer than this, in characters, is a phrase of its own, not one word of a list (砂じん嵐 and 地ふぶき are short). */
4
+ const BARE_ITEM_MAX_CHARS = 6;
5
+ /** Fewer items than this in a row are a pair or a triple a clause may hold, not a list. */
6
+ const MIN_LIST_ITEMS = 4;
7
+
8
+ /** A particle or a conjunction ties the item to the clause around it (会議室で、新人に): a clause, not a bare word. */
9
+ const CLAUSAL: ReadonlySet<string> = new Set(["ADP", "SCONJ", "CCONJ", "PART"]);
10
+ const NOMINAL: ReadonlySet<string> = new Set(["NOUN", "PROPN", "NUM"]);
11
+
12
+ type Item = { readonly tokens: readonly Token[]; readonly commaAfter: number | undefined };
13
+
14
+ const isWord = (token: Token): boolean => token.pos !== "PUNCT" && token.surface.trim() !== "";
15
+
16
+ /** The tokens between the commas, each with the index of the comma that ends it; the last item ends with the sentence. */
17
+ const itemsOf = (tokens: readonly Token[], isComma: (token: Token) => boolean): Item[] => {
18
+ const commas = tokens.flatMap((token, at) => (isComma(token) ? [at] : []));
19
+ const starts = [0, ...commas.map((at) => at + 1)];
20
+ return starts.map((start, index) => ({ tokens: tokens.slice(start, commas[index] ?? tokens.length), commaAfter: commas[index] }));
21
+ };
22
+
23
+ const wordsOf = (item: Item): readonly Token[] => item.tokens.filter(isWord);
24
+
25
+ /** One short word with no particle: 快晴, 晴れ, 地ふぶき. The parser may read a weather word as a verb (晴れ), so any part of speech goes. */
26
+ const isBare = (item: Item): boolean => {
27
+ const words = wordsOf(item);
28
+ const length = words.reduce((sum, token) => sum + token.surface.length, 0);
29
+ return words.length > 0 && length <= BARE_ITEM_MAX_CHARS && !words.some((token) => CLAUSAL.has(token.pos));
30
+ };
31
+
32
+ /** A noun, maybe with a copula after it (雷です), and no verb (調査し). The parser may cut a noun into a noun and an auxiliary (みぞ・れ). */
33
+ const isNominal = (item: Item): boolean => {
34
+ const words = wordsOf(item);
35
+ return NOMINAL.has(words[0]?.pos ?? "") && !words.some((token) => token.pos === "VERB");
36
+ };
37
+
38
+ /** Consecutive bare items, split where an item is not bare. */
39
+ const bareRuns = (items: readonly Item[]): Item[][] =>
40
+ items.reduce<Item[][]>(
41
+ (runs, item) => {
42
+ if (!isBare(item)) return [...runs, []];
43
+ const last = runs.at(-1) ?? [];
44
+ return [...runs.slice(0, -1), [...last, item]];
45
+ },
46
+ [[]],
47
+ );
48
+
49
+ /** A run of bare words is a list when it is long enough and most of its words are nouns (調査し、分析し、検討し is a chain of clauses). */
50
+ const isList = (run: readonly Item[]): boolean => run.length >= MIN_LIST_ITEMS && run.filter(isNominal).length * 2 > run.length;
51
+
52
+ /**
53
+ * The indices of the commas that only separate the words of a list written as bare short words (快晴、晴れ、薄曇り、曇り、…),
54
+ * where the parser may not read every word as a noun.
55
+ */
56
+ export const bareListCommas = (tokens: readonly Token[], isComma: (token: Token) => boolean): ReadonlySet<number> =>
57
+ new Set(
58
+ bareRuns(itemsOf(tokens, isComma))
59
+ .filter(isList)
60
+ .flatMap((run) => run.slice(0, -1).flatMap((item) => (item.commaAfter === undefined ? [] : [item.commaAfter]))),
61
+ );
@@ -0,0 +1,33 @@
1
+ import type { Span } from "../plugin.ts";
2
+
3
+ /** The bold marks around a run, and a colon inside them or right after (**Date:** or **Date**:). */
4
+ const LABEL = /^(?:\*\*|__)([^*_\n]+?)[::]?(?:\*\*|__)$/u;
5
+ const COLON_AFTER = /^[::]/u;
6
+ const COLON_INSIDE = /[::]$/u;
7
+
8
+ /** A field label is a name, not a sentence: a few words at most (Date, Also present, Prepared by). */
9
+ const LABEL_WORDS = 4;
10
+ const LABEL_CHARS = 12;
11
+
12
+ const LATIN_WORD = /^\p{Script=Latin}+$/u;
13
+
14
+ const isShortLabel = (text: string): boolean => {
15
+ const words = text.trim().split(/\s+/u);
16
+ if (words.length > 1) return words.length <= LABEL_WORDS;
17
+ const word = words[0] ?? "";
18
+ return LATIN_WORD.test(word) || Array.from(word).length <= LABEL_CHARS;
19
+ };
20
+
21
+ /**
22
+ * Whether the bold run is a field label opening a line of its own (**Date:** Tuesday, **Motion:** To approve): the name of
23
+ * the value after it, as a memo or minutes header writes it, not emphasis. A label opening a list item is left counted: a
24
+ * list of bold labels is the shape bold-label-list reads, and its density is what stands out.
25
+ */
26
+ export const isFieldLabel = (source: string, span: Span): boolean => {
27
+ const lineStart = source.lastIndexOf("\n", span.start - 1) + 1;
28
+ if (source.slice(lineStart, span.start).trim() !== "") return false;
29
+ const run = source.slice(span.start, span.end);
30
+ const inner = LABEL.exec(run)?.[1];
31
+ if (inner === undefined || !isShortLabel(inner)) return false;
32
+ return COLON_INSIDE.test(run.slice(0, -2)) || COLON_AFTER.test(source.slice(span.end));
33
+ };
@@ -1,4 +1,4 @@
1
- import type { Detector, DetectorOptions, Finding, ProseDocument, Span } from "../plugin.ts";
1
+ import type { Detector, DetectorOptions, Finding, Paragraph, ProseDocument, Span, Token } from "../plugin.ts";
2
2
 
3
3
  /** A bold run longer than this is a bold sentence, not a label. */
4
4
  const MAX_LABEL_CHARS = 40;
@@ -52,10 +52,47 @@ export const boldLeadOf = (item: string): string | undefined =>
52
52
 
53
53
  const labelOrLeadOf = (item: string): string | undefined => boldLabelOf(item) ?? boldLeadOf(item);
54
54
 
55
+ const unquotedItemsOf = (doc: ProseDocument, spans: readonly Span[], opens: (item: string) => string | undefined): Span[] =>
56
+ spans.filter((span) => !isQuotedAt(doc.source, span.start) && opens(doc.source.slice(span.start, span.end)) !== undefined);
57
+
55
58
  const unquotedItems = (doc: ProseDocument, opens: (item: string) => string | undefined): Span[] =>
59
+ unquotedItemsOf(
60
+ doc,
61
+ doc.lists.flatMap((list) => list.itemSpans),
62
+ opens,
63
+ ).toSorted((left, right) => left.start - right.start);
64
+
65
+ /**
66
+ * How long an item's text after its bold opening runs before it counts as a paragraph, in words or, for a language
67
+ * written without spaces, characters (the 2.5 characters a word that MIN_DOCUMENT_LENGTH uses).
68
+ */
69
+ export const PARAGRAPH_ITEM_LENGTH = { word: 40, char: 100 };
70
+
71
+ const OPENING_BOLD = /^(\*\*|__).*?\1/su;
72
+
73
+ /** The length of an item's text after its marker and its bold opening, in the document's unit. */
74
+ const explanationLength = (item: string, unit: "word" | "char"): number => {
75
+ const rest = item.replace(ITEM_MARKER, "").replace(TASK_BOX, "").replace(OPENING_BOLD, "").trim();
76
+ return unit === "char" ? rest.replace(/\s+/gu, "").length : rest.split(/\s+/u).filter((word) => /[\p{L}\p{N}]/u.test(word)).length;
77
+ };
78
+
79
+ const median = (values: readonly number[]): number => values.toSorted((left, right) => left - right)[Math.floor(values.length / 2)] ?? 0;
80
+
81
+ /**
82
+ * Whether a list's bold-opened items each run a paragraph (- **Get feedback early.** and forty words more): a handbook's
83
+ * tips, the advice in bold and the item explaining it at length. Generated lists keep each item to a sentence or two.
84
+ */
85
+ export const isParagraphList = (doc: ProseDocument, items: readonly Span[]): boolean =>
86
+ items.length > 0 &&
87
+ median(items.map((span) => explanationLength(doc.source.slice(span.start, span.end), doc.lengthUnit))) >= PARAGRAPH_ITEM_LENGTH[doc.lengthUnit];
88
+
89
+ /** The bold-opened items of lists that are captions, not paragraphs, in document order. */
90
+ const captionItems = (doc: ProseDocument, opens: (item: string) => string | undefined): Span[] =>
56
91
  doc.lists
57
- .flatMap((list) => list.itemSpans)
58
- .filter((span) => !isQuotedAt(doc.source, span.start) && opens(doc.source.slice(span.start, span.end)) !== undefined)
92
+ .flatMap((list) => {
93
+ const items = unquotedItemsOf(doc, list.itemSpans, opens);
94
+ return isParagraphList(doc, items) ? [] : items;
95
+ })
59
96
  .toSorted((left, right) => left.start - right.start);
60
97
 
61
98
  /** The list items, in document order, that open with a bold label and are not quoted. */
@@ -64,9 +101,64 @@ export const boldLabelItems = (doc: ProseDocument): Span[] => unquotedItems(doc,
64
101
  /** Bold lead sentences that report on their own (the rule's min_leads). */
65
102
  const DEFAULT_MIN_LEADS = 3;
66
103
 
67
- const minLeads = (options: DetectorOptions): number => {
68
- const value = options.settings?.["min_leads"];
69
- return typeof value === "number" ? value : DEFAULT_MIN_LEADS;
104
+ /** Paragraphs opened by a bold statement that report on their own (the rule's min_clause_paragraphs). */
105
+ const DEFAULT_MIN_CLAUSE_PARAGRAPHS = 3;
106
+
107
+ const countSetting = (options: DetectorOptions, name: string, fallback: number): number => {
108
+ const value = options.settings?.[name];
109
+ return typeof value === "number" ? value : fallback;
110
+ };
111
+
112
+ const minLeads = (options: DetectorOptions): number => countSetting(options, "min_leads", DEFAULT_MIN_LEADS);
113
+
114
+ const VERBAL = new Set(["VERB", "AUX"]);
115
+
116
+ /** Words that state something: a verb after a first word that is not one. An imperative (Talk to …), a term (Work schedule) or a gerund heading is not. */
117
+ const isStatement = (tokens: readonly Token[]): boolean => {
118
+ const words = tokens.filter((token) => token.pos !== "PUNCT" && token.pos !== "SYM");
119
+ const head = words[0];
120
+ return head !== undefined && !VERBAL.has(head.pos) && words.slice(1).some((token) => VERBAL.has(token.pos));
121
+ };
122
+
123
+ /**
124
+ * A whole instruction in bold, closed by its own stop (**Pick the quietest room you can.**): a verb in its plain form first
125
+ * and words after it. A run-in head closed by a colon (**Talk to the people:**) or a gerund (**Examining who is involved.**)
126
+ * is not one.
127
+ */
128
+ const OBJECT_OPENERS = new Set(["DET", "PRON"]);
129
+
130
+ /** The tagger reads an opening verb it also knows as a noun as a noun (Face the window); a determiner right after it says verb. */
131
+ const readsAsVerb = (head: Token, next: Token | undefined): boolean =>
132
+ head.pos === "VERB" || (head.pos === "NOUN" && next !== undefined && OBJECT_OPENERS.has(next.pos));
133
+
134
+ const isImperativeSentence = (tokens: readonly Token[]): boolean => {
135
+ const words = tokens.filter((token) => token.pos !== "PUNCT" && token.pos !== "SYM");
136
+ const head = words[0];
137
+ return head !== undefined && !/ing$/iu.test(head.surface) && readsAsVerb(head, words[1]);
138
+ };
139
+
140
+ type OpeningRun = { readonly words: string; readonly end: number; readonly stopped: boolean };
141
+
142
+ /** The bold run a paragraph opens with, as a label or lead sentence, where in the paragraph its words end, and whether a stop closes it. */
143
+ const openingRunOf = (text: string): OpeningRun | undefined => {
144
+ const label = BOLD_LABEL.exec(text);
145
+ const match = label ?? BOLD_LEAD.exec(text);
146
+ const words = match?.[2];
147
+ if (match?.[1] === undefined || words === undefined || isCodeOnly(words.trim())) return undefined;
148
+ return { words: words.trim(), end: match[1].length + words.length, stopped: label === null };
149
+ };
150
+
151
+ /**
152
+ * The statement a paragraph opens with in bold (**Usage grew each week**: …), or a whole instruction closed by its stop
153
+ * (**Pick the quietest room you can.** …), or undefined. A question (an FAQ's) is not a statement.
154
+ */
155
+ const boldStatementOf = (doc: ProseDocument, paragraph: Paragraph): string | undefined => {
156
+ const { start, end } = paragraph.span;
157
+ const run = isQuotedAt(doc.source, start) ? undefined : openingRunOf(doc.source.slice(start, end));
158
+ if (run === undefined || /[??]$/u.test(run.words)) return undefined;
159
+ const runEnd = start + run.end;
160
+ const tokens = paragraph.sentences.flatMap((sentence) => sentence.tokens ?? []).filter((token) => token.span.start >= start && token.span.start < runEnd);
161
+ return isStatement(tokens) || (run.stopped && isImperativeSentence(tokens)) ? run.words.replace(/[.!。!]$/u, "") : undefined;
70
162
  };
71
163
 
72
164
  /** The count reported and the limit it reached: all the labelled items, or else the bold lead sentences alone, or undefined. */
@@ -76,26 +168,43 @@ const reached = (items: readonly Span[], leads: number, options: DetectorOptions
76
168
  return leads >= least ? { count: leads, limit: least } : undefined;
77
169
  };
78
170
 
171
+ const finding = (doc: ProseDocument, span: Span, label: string, found: { count: number; limit: number }, variant?: string): Finding => ({
172
+ rule: "bold-label-list",
173
+ severity: "info",
174
+ line: 0,
175
+ column: 0,
176
+ quote: (doc.source.slice(span.start, span.end).split("\n")[0] ?? "").trim(),
177
+ values: { label, count: found.count, limit: found.limit, offset: span.start },
178
+ ...(variant === undefined ? {} : { variant }),
179
+ });
180
+
181
+ /**
182
+ * Paragraphs that each open with a bold statement (**Usage grew each week**: …) or a whole bold instruction (**Pick a quiet
183
+ * room.** …): findings or tips set as captions. Human run-in heads are terms, imperatives closed by a colon, gerunds or
184
+ * questions (**Work schedule**:, **Talk to the people:**, **Examining the risks.**, **Who is my audience?**), and are not counted.
185
+ */
186
+ const statementParagraphs = (doc: ProseDocument, options: DetectorOptions): Finding[] => {
187
+ const statements = doc.paragraphs.flatMap((paragraph) => {
188
+ const label = boldStatementOf(doc, paragraph);
189
+ return label === undefined ? [] : [{ span: paragraph.span, label }];
190
+ });
191
+ const first = statements[0];
192
+ const limit = countSetting(options, "min_clause_paragraphs", DEFAULT_MIN_CLAUSE_PARAGRAPHS);
193
+ return first === undefined || statements.length < limit ? [] : [finding(doc, first.span, first.label, { count: statements.length, limit }, "paragraphs")];
194
+ };
195
+
79
196
  /**
80
197
  * A count, not a density: a person writes one or two labels even in a long article. A bold lead sentence counts as a label.
81
198
  * Bold lead sentences (- **Check one result by hand.** …) report at fewer items than colon labels: human documents write a few
82
- * colon labels for steps or fields (- **Gather input**: …), but rarely make a list of bold lead sentences.
199
+ * colon labels for steps or fields (- **Gather input**: …), but rarely make a list of bold lead sentences. A list whose items
200
+ * each run a paragraph after the bold is a handbook's tips and is not counted.
83
201
  */
84
202
  export const boldLabelList: Detector = (doc, options): Finding[] => {
85
- const items = unquotedItems(doc, labelOrLeadOf);
203
+ const items = captionItems(doc, labelOrLeadOf);
86
204
  const first = items[0];
87
205
  const leads = items.filter((span) => boldLabelOf(doc.source.slice(span.start, span.end)) === undefined).length;
88
206
  const found = reached(items, leads, options);
89
- if (first === undefined || found === undefined) return [];
90
- const written = doc.source.slice(first.start, first.end);
91
- return [
92
- {
93
- rule: "bold-label-list",
94
- severity: "info",
95
- line: 0,
96
- column: 0,
97
- quote: (written.split("\n")[0] ?? "").trim(),
98
- values: { label: labelOrLeadOf(written) ?? "", count: found.count, limit: found.limit, offset: first.start },
99
- },
100
- ];
207
+ const paragraphs = statementParagraphs(doc, options);
208
+ if (first === undefined || found === undefined) return paragraphs;
209
+ return [finding(doc, first, labelOrLeadOf(doc.source.slice(first.start, first.end)) ?? "", found)];
101
210
  };
@@ -95,13 +95,34 @@ const imageAt = (source: string, start: number): boolean => {
95
95
  */
96
96
  export const siteDefinedImage = (source: string, start: number, label: string): boolean => label === "" && imageAt(source, start);
97
97
 
98
- export const unresolvedReferences = (source: string, markup: Markup): Span[] =>
99
- markup.texts.flatMap((text) =>
98
+ /**
99
+ * 正規表現の文字クラス([A-Za-z0-9][\\w.-]*)。範囲(A-Z)と逃がし(\\.)と記号だけでできていて、範囲を一つは含む。
100
+ * 文の中にコードの印を付けずに書いた正規表現で、参照の記法ではない。
101
+ */
102
+ const CHARACTER_CLASS = /^\^?(?:[A-Za-z0-9]-[A-Za-z0-9]|\\.|[^\sA-Za-z0-9\\])*[A-Za-z0-9]-[A-Za-z0-9](?:[A-Za-z0-9]-[A-Za-z0-9]|\\.|[^\sA-Za-z0-9\\])*$/u;
103
+
104
+ /** mdBook の規則の印(r[type.trait-object])だけの行。この印のある本は、印の名前で呼ぶ参照の定義を本全体に足す。 */
105
+ const RULE_MARKER_LINE = /^r\[([a-z0-9_-]+(?:\.[a-z0-9_-]+)+)\]$/mu;
106
+
107
+ /** 規則の印の形の名前(type.trait-object)。 */
108
+ const RULE_ID = /^[a-z0-9_-]+(?:\.[a-z0-9_-]+)+$/u;
109
+
110
+ /** 本が定義を足す名前: 規則の印を書いた本で、その印の形をした名前。 */
111
+ const bookDefinedLabel = (source: string): ((label: string) => boolean) => {
112
+ const marked = RULE_MARKER_LINE.test(source);
113
+ return (label) => marked && RULE_ID.test(label);
114
+ };
115
+
116
+ export const unresolvedReferences = (source: string, markup: Markup): Span[] => {
117
+ const bookDefined = bookDefinedLabel(source);
118
+ return markup.texts.flatMap((text) =>
100
119
  [...source.slice(text.start, text.end).matchAll(REFERENCE_LIKE)]
101
120
  .filter((match) => !CITATION_NUMBERS.test(match[1] ?? "") && !siteDefinedImage(source, text.start + match.index, match[2] ?? ""))
121
+ .filter((match) => !CHARACTER_CLASS.test(match[1] ?? "") && !CHARACTER_CLASS.test(match[2] ?? "") && !bookDefined(match[2] ?? ""))
102
122
  .map((match) => ({ start: text.start + match.index, end: text.start + match.index + match[0].length }))
103
123
  .map((span) => (imageAt(source, span.start) ? { start: span.start - 1, end: span.end } : span)),
104
124
  );
125
+ };
105
126
 
106
127
  const emptyLinks = (doc: ProseDocument, markup: Markup): Finding[] =>
107
128
  markup.links.filter((link) => link.destination.trim() === "").map((link) => findingAt(doc, link, { link: quoteOf(doc.source, link) }, "empty"));
@@ -0,0 +1,24 @@
1
+ // A list inside a byline (By Jason Wells, Section Chief for State, Local, Tribal and Territorial, Infrastructure Security
2
+ // Division): the writer's name and title of office, whose commas belong to the office's name, not to the writer's style. Pure.
3
+ import type { Token } from "../plugin.ts";
4
+
5
+ const VERBS: ReadonlySet<string> = new Set(["VERB", "AUX"]);
6
+ const SENTENCE_END = /^[.!?]$/u;
7
+
8
+ const isCapitalised = (token: Token | undefined): boolean => /^\p{Lu}/u.test(token?.surface ?? "");
9
+
10
+ /**
11
+ * A line that opens with By and a name, has no verb and does not close like a sentence. Other lines of names (a list of
12
+ * attendees) are not taken: their votes stand until the list reader tells their clauses from items on its own.
13
+ */
14
+ const isByline = (tokens: readonly Token[]): boolean => {
15
+ const [by, name, last] = [tokens[0], tokens[1], tokens.at(-1)];
16
+ if (by?.surface !== "By" || name?.pos !== "PROPN" || last === undefined || SENTENCE_END.test(last.surface)) return false;
17
+ return !tokens.some((token) => VERBS.has(token.pos));
18
+ };
19
+
20
+ /** Whether the and / or at `at` joins capitalised words of the title in a byline. */
21
+ export const insideByline = (tokens: readonly Token[]): ((at: number) => boolean) => {
22
+ const byline = isByline(tokens);
23
+ return (at) => byline && isCapitalised(tokens[at - 1]) && isCapitalised(tokens[at + 1]);
24
+ };
@@ -0,0 +1,15 @@
1
+ // A capital run that a sentence names as a label on a screen: "your authorization is in SUBMIT TO APPROVER status", "press
2
+ // the SAVE AND CLOSE button". The run quotes the label as the screen shows it. Pure; the nouns come from the lexicon.
3
+
4
+ /** A word in lower case: the word right before the run, when the run sits inside a sentence rather than at its head. */
5
+ const LOWER_WORD = /^\p{Ll}[\p{L}'’]*$/u;
6
+
7
+ /** The word right after the run, in lower case. */
8
+ const WORD_AFTER = /^ (\p{Ll}+)(?!\p{L})/u;
9
+
10
+ /** Whether the run at start..end of `source` sits in a sentence and is followed by one of `nouns` ("status", "button"). */
11
+ export const namesScreenLabel = (source: string, start: number, end: number, nouns: ReadonlySet<string>): boolean => {
12
+ const after = WORD_AFTER.exec(source.slice(end))?.[1];
13
+ const before = source.slice(0, start);
14
+ return after !== undefined && nouns.has(after) && before.endsWith(" ") && LOWER_WORD.test(before.slice(0, -1).split(" ").at(-1) ?? "");
15
+ };
@@ -0,0 +1,30 @@
1
+ import type { Detector, ProseDocument } from "../plugin.ts";
2
+ import { openerPile } from "./ai-phrasing.ts";
3
+
4
+ // A document written in a casual voice on purpose: headings asked as questions (なんで植物?) and sentences ending in an
5
+ // exclamation mark. There a spoken word fits the voice the writer chose, and is no slip. Pure.
6
+
7
+ const EXCLAMATION = /[!!]$/u;
8
+ const QUESTION = /[??]$/u;
9
+ /** One mark may be a slip or a quotation; two set the voice of the whole document. */
10
+ const MIN_CASUAL_MARKS = 2;
11
+
12
+ const CLOSERS = new Set(["」", "』", ")", ")"]);
13
+
14
+ /** The text without the closing brackets at its end, so that 「…!」 ends in its mark. */
15
+ const closingMark = (text: string): string => {
16
+ const chars = [...text.trim()];
17
+ const end = chars.findLastIndex((char) => !CLOSERS.has(char));
18
+ return chars.slice(0, end + 1).join("");
19
+ };
20
+
21
+ /** The marks of a casual voice: sentences ending in "!" and headings ending in "?". */
22
+ export const casualMarks = (doc: ProseDocument): number =>
23
+ doc.sentences.filter((sentence) => sentence.embeddedLanguage === undefined && EXCLAMATION.test(closingMark(sentence.text))).length +
24
+ doc.sections.filter((section) => section.depth > 0 && QUESTION.test(section.heading.trim())).length;
25
+
26
+ /** Whether the writer chose a casual voice for the whole document. */
27
+ export const writesCasually = (doc: ProseDocument): boolean => casualMarks(doc) >= MIN_CASUAL_MARKS;
28
+
29
+ /** A spoken conjunction at a sentence's head (なので、), unless the whole document is written in a casual voice that it fits. */
30
+ export const colloquialOpenerPile: Detector = (doc, options) => (writesCasually(doc) ? [] : openerPile(doc, options));
@@ -21,13 +21,13 @@ import { isOneName } from "./name-run.ts";
21
21
  import { isOrganisationHead, isOrganisationRun, type OrganisationWords } from "./organisation-run.ts";
22
22
  import { endsInTitle, inStatuteTitle, isTitlePosition, isTitledName, repeatedRuns, titleBody, type TitleWords } from "./titled-run.ts";
23
23
  import { proseText } from "../measure.ts";
24
- import { parallelDotCount } from "./middle-dot.ts";
25
24
  import { maskSpans } from "../mask.ts";
26
25
  import { quotedSpans } from "../quoted-span.ts";
27
26
  import { nameSpans } from "../team-names.ts";
28
27
  import { isIn } from "../lexicon-genres.ts";
29
28
  import { holdsKnown, isInnerSuffix, isTitledPerson, standaloneNames, unknownPieces } from "./kanji-run-pieces.ts";
30
29
  import { isBibliographyEntry } from "./bibliography-entry.ts";
30
+ import { isNamedByContext } from "./named-by-context.ts";
31
31
 
32
32
  /**
33
33
  * 文字の並びを見る検出。漢字の連なりが住所か名前かだけは、形態素解析の固有名詞と数で決める。
@@ -142,6 +142,10 @@ type NameWords = {
142
142
  readonly listSuffixes: readonly string[];
143
143
  /** 連なりを閉じる、読み手が一つの語と知っている長い語(内閣総理大臣、許可事業者)。その前で連なりを割る。 */
144
144
  readonly knownWords: ReadonlySet<string>;
145
+ /** 制度が区分に入れることを言う句(として認定)。連なりのすぐ後ろに続けば、連なりは区分の名前。 */
146
+ readonly designations: readonly string[];
147
+ /** お知らせやメールの題を閉じる語(お知らせ、ご案内)。 */
148
+ readonly noticeEndings: readonly string[];
145
149
  };
146
150
 
147
151
  type Tail = AddresseeSuffix;
@@ -253,7 +257,7 @@ const measuredOf = (tokens: readonly Token[], run: KanjiRun, span: Span, words:
253
257
  * 住所か名前かは、それを外した残りで決める(1日日本銀行の「日本銀行」)。品詞が無ければ判定しない。
254
258
  */
255
259
  const measuredRun = (tokens: readonly Token[] | undefined, run: KanjiRun, context: RunContext): string => {
256
- if (run.quoted || (context.headwords && run.alone)) return "";
260
+ if (run.quoted || (context.headwords && run.alone) || isNamedByContext(run, context.words)) return "";
257
261
  if (tokens === undefined || run.span === undefined) return run.text;
258
262
  const { rest, text, keptHead } = measuredOf(tokens, run, run.span, context.words);
259
263
  if (context.presented.has(text) || inStatuteTitle(tokens, run.brackets, context.words.fixedName)) return "";
@@ -361,6 +365,8 @@ const nameWordsOf = (doc: ProseDocument): NameWords => {
361
365
  references: patterns("reference-prefix"),
362
366
  listSuffixes: patterns("list-suffix"),
363
367
  knownWords: new Set(patterns("kanji-known-word")),
368
+ designations: patterns("designation-phrase"),
369
+ noticeEndings: patterns("notice-title-ending"),
364
370
  };
365
371
  };
366
372
 
@@ -405,23 +411,3 @@ export const kanjiRun: Detector = (doc, options): Finding[] => {
405
411
  values: { word: run, count: run.length, limit: options.limit, offset: sentence.span.start },
406
412
  }));
407
413
  };
408
-
409
- /**
410
- * 中黒で並べると、どこまでが 1 つの項目か分からなくなる。
411
- * 「企画・開発・運用・保守体制」は、保守体制が 1 つなのか保守と体制なのか読めない。
412
- * 語彙表(nakaguro-word)の、中黒を含めて 1 語の語(キャッシュ・フロー)の中黒は並べていないので数えない。
413
- */
414
- export const middleDot: Detector = (doc, options): Finding[] => {
415
- const words = (options.lexicon ?? []).map((entry) => entry.pattern).toSorted((left, right) => right.length - left.length);
416
- return doc.sentences
417
- .map((sentence) => ({ sentence, count: parallelDotCount(sentence.text, words) }))
418
- .filter(({ count }) => count > options.limit)
419
- .map(({ sentence, count }) => ({
420
- rule: "no-nakaguro-parallel",
421
- severity: "info",
422
- line: 0,
423
- column: 0,
424
- quote: sentence.text.trim(),
425
- values: { count, limit: options.limit, offset: sentence.span.start },
426
- }));
427
- };