chaffjs 0.45.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 (428) 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 +15 -1
  34. package/dist/detectors/bold-label.d.ts.map +1 -1
  35. package/dist/detectors/bold-label.js +54 -12
  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/count-per-section.d.ts.map +1 -1
  53. package/dist/detectors/count-per-section.js +6 -2
  54. package/dist/detectors/count-per-section.js.map +1 -1
  55. package/dist/detectors/dangling-opener.d.ts.map +1 -1
  56. package/dist/detectors/dangling-opener.js +10 -1
  57. package/dist/detectors/dangling-opener.js.map +1 -1
  58. package/dist/detectors/date-year.d.ts.map +1 -1
  59. package/dist/detectors/date-year.js +11 -1
  60. package/dist/detectors/date-year.js.map +1 -1
  61. package/dist/detectors/defined-term-form.d.ts.map +1 -1
  62. package/dist/detectors/defined-term-form.js +17 -3
  63. package/dist/detectors/defined-term-form.js.map +1 -1
  64. package/dist/detectors/document-shape.d.ts +4 -1
  65. package/dist/detectors/document-shape.d.ts.map +1 -1
  66. package/dist/detectors/document-shape.js +12 -2
  67. package/dist/detectors/document-shape.js.map +1 -1
  68. package/dist/detectors/doubled-punctuation.d.ts.map +1 -1
  69. package/dist/detectors/doubled-punctuation.js +24 -1
  70. package/dist/detectors/doubled-punctuation.js.map +1 -1
  71. package/dist/detectors/email-letter.d.ts.map +1 -1
  72. package/dist/detectors/email-letter.js +5 -2
  73. package/dist/detectors/email-letter.js.map +1 -1
  74. package/dist/detectors/email-subject-reference.d.ts +6 -0
  75. package/dist/detectors/email-subject-reference.d.ts.map +1 -0
  76. package/dist/detectors/email-subject-reference.js +31 -0
  77. package/dist/detectors/email-subject-reference.js.map +1 -0
  78. package/dist/detectors/fact-consistency.js +2 -2
  79. package/dist/detectors/fact-consistency.js.map +1 -1
  80. package/dist/detectors/figure-order.d.ts +1 -1
  81. package/dist/detectors/figure-order.d.ts.map +1 -1
  82. package/dist/detectors/figure-order.js +7 -2
  83. package/dist/detectors/figure-order.js.map +1 -1
  84. package/dist/detectors/gram-heading.d.ts.map +1 -1
  85. package/dist/detectors/gram-heading.js +13 -1
  86. package/dist/detectors/gram-heading.js.map +1 -1
  87. package/dist/detectors/heading-case.d.ts.map +1 -1
  88. package/dist/detectors/heading-case.js +6 -1
  89. package/dist/detectors/heading-case.js.map +1 -1
  90. package/dist/detectors/heading-numbering.d.ts.map +1 -1
  91. package/dist/detectors/heading-numbering.js +1 -7
  92. package/dist/detectors/heading-numbering.js.map +1 -1
  93. package/dist/detectors/hyphen-name-suffix.d.ts +3 -0
  94. package/dist/detectors/hyphen-name-suffix.d.ts.map +1 -0
  95. package/dist/detectors/hyphen-name-suffix.js +24 -0
  96. package/dist/detectors/hyphen-name-suffix.js.map +1 -0
  97. package/dist/detectors/katakana-density.d.ts.map +1 -1
  98. package/dist/detectors/katakana-density.js +7 -4
  99. package/dist/detectors/katakana-density.js.map +1 -1
  100. package/dist/detectors/lexicon.d.ts +1 -0
  101. package/dist/detectors/lexicon.d.ts.map +1 -1
  102. package/dist/detectors/lexicon.js +19 -1
  103. package/dist/detectors/lexicon.js.map +1 -1
  104. package/dist/detectors/link-shape.d.ts.map +1 -1
  105. package/dist/detectors/link-shape.js +10 -2
  106. package/dist/detectors/link-shape.js.map +1 -1
  107. package/dist/detectors/list-item-phrase.d.ts +20 -0
  108. package/dist/detectors/list-item-phrase.d.ts.map +1 -0
  109. package/dist/detectors/list-item-phrase.js +73 -0
  110. package/dist/detectors/list-item-phrase.js.map +1 -0
  111. package/dist/detectors/list-layout.d.ts +5 -0
  112. package/dist/detectors/list-layout.d.ts.map +1 -1
  113. package/dist/detectors/list-layout.js +12 -0
  114. package/dist/detectors/list-layout.js.map +1 -1
  115. package/dist/detectors/list-lead-in.d.ts.map +1 -1
  116. package/dist/detectors/list-lead-in.js +1 -17
  117. package/dist/detectors/list-lead-in.js.map +1 -1
  118. package/dist/detectors/list-parallel.d.ts.map +1 -1
  119. package/dist/detectors/list-parallel.js +29 -24
  120. package/dist/detectors/list-parallel.js.map +1 -1
  121. package/dist/detectors/mark-shape.d.ts +1 -1
  122. package/dist/detectors/mark-shape.d.ts.map +1 -1
  123. package/dist/detectors/mark-shape.js +10 -3
  124. package/dist/detectors/mark-shape.js.map +1 -1
  125. package/dist/detectors/measured-facts.d.ts +5 -1
  126. package/dist/detectors/measured-facts.d.ts.map +1 -1
  127. package/dist/detectors/measured-facts.js +7 -3
  128. package/dist/detectors/measured-facts.js.map +1 -1
  129. package/dist/detectors/middle-dot.d.ts +5 -0
  130. package/dist/detectors/middle-dot.d.ts.map +1 -1
  131. package/dist/detectors/middle-dot.js +27 -0
  132. package/dist/detectors/middle-dot.js.map +1 -1
  133. package/dist/detectors/missing-final-period.d.ts.map +1 -1
  134. package/dist/detectors/missing-final-period.js +13 -1
  135. package/dist/detectors/missing-final-period.js.map +1 -1
  136. package/dist/detectors/name-variant.d.ts.map +1 -1
  137. package/dist/detectors/name-variant.js +2 -1
  138. package/dist/detectors/name-variant.js.map +1 -1
  139. package/dist/detectors/number-style.d.ts +2 -0
  140. package/dist/detectors/number-style.d.ts.map +1 -1
  141. package/dist/detectors/number-style.js +19 -4
  142. package/dist/detectors/number-style.js.map +1 -1
  143. package/dist/detectors/numeral-opener.d.ts +1 -1
  144. package/dist/detectors/numeral-opener.d.ts.map +1 -1
  145. package/dist/detectors/numeral-opener.js +4 -2
  146. package/dist/detectors/numeral-opener.js.map +1 -1
  147. package/dist/detectors/open-end-names.d.ts +2 -0
  148. package/dist/detectors/open-end-names.d.ts.map +1 -1
  149. package/dist/detectors/open-end-names.js +8 -1
  150. package/dist/detectors/open-end-names.js.map +1 -1
  151. package/dist/detectors/ordinary-phrase.d.ts +5 -0
  152. package/dist/detectors/ordinary-phrase.d.ts.map +1 -1
  153. package/dist/detectors/ordinary-phrase.js +10 -0
  154. package/dist/detectors/ordinary-phrase.js.map +1 -1
  155. package/dist/detectors/orthographic-variant.js +2 -2
  156. package/dist/detectors/orthographic-variant.js.map +1 -1
  157. package/dist/detectors/output-lead-in.d.ts +3 -0
  158. package/dist/detectors/output-lead-in.d.ts.map +1 -0
  159. package/dist/detectors/output-lead-in.js +26 -0
  160. package/dist/detectors/output-lead-in.js.map +1 -0
  161. package/dist/detectors/outside-announced-list.d.ts.map +1 -1
  162. package/dist/detectors/outside-announced-list.js +6 -1
  163. package/dist/detectors/outside-announced-list.js.map +1 -1
  164. package/dist/detectors/oxford-comma.d.ts.map +1 -1
  165. package/dist/detectors/oxford-comma.js +3 -1
  166. package/dist/detectors/oxford-comma.js.map +1 -1
  167. package/dist/detectors/paragraph-restatement.d.ts +4 -1
  168. package/dist/detectors/paragraph-restatement.d.ts.map +1 -1
  169. package/dist/detectors/paragraph-restatement.js +17 -2
  170. package/dist/detectors/paragraph-restatement.js.map +1 -1
  171. package/dist/detectors/person-consistency.d.ts +2 -1
  172. package/dist/detectors/person-consistency.d.ts.map +1 -1
  173. package/dist/detectors/person-consistency.js +11 -2
  174. package/dist/detectors/person-consistency.js.map +1 -1
  175. package/dist/detectors/quoted-title-line.d.ts +6 -0
  176. package/dist/detectors/quoted-title-line.d.ts.map +1 -0
  177. package/dist/detectors/quoted-title-line.js +14 -0
  178. package/dist/detectors/quoted-title-line.js.map +1 -0
  179. package/dist/detectors/register-interview.d.ts +4 -0
  180. package/dist/detectors/register-interview.d.ts.map +1 -0
  181. package/dist/detectors/register-interview.js +19 -0
  182. package/dist/detectors/register-interview.js.map +1 -0
  183. package/dist/detectors/registry/colloquial-opener-pile.d.ts +3 -0
  184. package/dist/detectors/registry/colloquial-opener-pile.d.ts.map +1 -0
  185. package/dist/detectors/registry/colloquial-opener-pile.js +3 -0
  186. package/dist/detectors/registry/colloquial-opener-pile.js.map +1 -0
  187. package/dist/detectors/repeated-head.d.ts.map +1 -1
  188. package/dist/detectors/repeated-head.js +23 -4
  189. package/dist/detectors/repeated-head.js.map +1 -1
  190. package/dist/detectors/request-owner.d.ts +3 -1
  191. package/dist/detectors/request-owner.d.ts.map +1 -1
  192. package/dist/detectors/request-owner.js +5 -2
  193. package/dist/detectors/request-owner.js.map +1 -1
  194. package/dist/detectors/run-together.d.ts +3 -0
  195. package/dist/detectors/run-together.d.ts.map +1 -0
  196. package/dist/detectors/run-together.js +13 -0
  197. package/dist/detectors/run-together.js.map +1 -0
  198. package/dist/detectors/sentence-counts.d.ts +6 -2
  199. package/dist/detectors/sentence-counts.d.ts.map +1 -1
  200. package/dist/detectors/sentence-counts.js +19 -3
  201. package/dist/detectors/sentence-counts.js.map +1 -1
  202. package/dist/detectors/sentence-ending.d.ts +2 -0
  203. package/dist/detectors/sentence-ending.d.ts.map +1 -1
  204. package/dist/detectors/sentence-ending.js +8 -2
  205. package/dist/detectors/sentence-ending.js.map +1 -1
  206. package/dist/detectors/sentence-parts.d.ts +10 -1
  207. package/dist/detectors/sentence-parts.d.ts.map +1 -1
  208. package/dist/detectors/sentence-parts.js +17 -2
  209. package/dist/detectors/sentence-parts.js.map +1 -1
  210. package/dist/detectors/space-before-punctuation.d.ts +2 -2
  211. package/dist/detectors/space-before-punctuation.d.ts.map +1 -1
  212. package/dist/detectors/space-before-punctuation.js +13 -2
  213. package/dist/detectors/space-before-punctuation.js.map +1 -1
  214. package/dist/detectors/stray-space.js +1 -1
  215. package/dist/detectors/stray-space.js.map +1 -1
  216. package/dist/detectors/structure-tree.d.ts.map +1 -1
  217. package/dist/detectors/structure-tree.js +2 -1
  218. package/dist/detectors/structure-tree.js.map +1 -1
  219. package/dist/detectors/structure.d.ts +1 -0
  220. package/dist/detectors/structure.d.ts.map +1 -1
  221. package/dist/detectors/structure.js +5 -1
  222. package/dist/detectors/structure.js.map +1 -1
  223. package/dist/detectors/superlative-context.d.ts +7 -0
  224. package/dist/detectors/superlative-context.d.ts.map +1 -1
  225. package/dist/detectors/superlative-context.js +6 -0
  226. package/dist/detectors/superlative-context.js.map +1 -1
  227. package/dist/detectors/technical-docs.d.ts.map +1 -1
  228. package/dist/detectors/technical-docs.js +5 -1
  229. package/dist/detectors/technical-docs.js.map +1 -1
  230. package/dist/detectors/token-shape.d.ts.map +1 -1
  231. package/dist/detectors/token-shape.js +16 -3
  232. package/dist/detectors/token-shape.js.map +1 -1
  233. package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
  234. package/dist/detectors/unbalanced-bracket.js +5 -1
  235. package/dist/detectors/unbalanced-bracket.js.map +1 -1
  236. package/dist/detectors/undefined-term.d.ts.map +1 -1
  237. package/dist/detectors/undefined-term.js +5 -1
  238. package/dist/detectors/undefined-term.js.map +1 -1
  239. package/dist/detectors/vague-density.d.ts.map +1 -1
  240. package/dist/detectors/vague-density.js +13 -1
  241. package/dist/detectors/vague-density.js.map +1 -1
  242. package/dist/front-matter.d.ts +3 -0
  243. package/dist/front-matter.d.ts.map +1 -0
  244. package/dist/front-matter.js +13 -0
  245. package/dist/front-matter.js.map +1 -0
  246. package/dist/genre-check.js +1 -1
  247. package/dist/genre-check.js.map +1 -1
  248. package/dist/genre.d.ts +0 -2
  249. package/dist/genre.d.ts.map +1 -1
  250. package/dist/genre.js +1 -12
  251. package/dist/genre.js.map +1 -1
  252. package/dist/labelled-note-paragraphs.d.ts +4 -0
  253. package/dist/labelled-note-paragraphs.d.ts.map +1 -0
  254. package/dist/labelled-note-paragraphs.js +21 -0
  255. package/dist/labelled-note-paragraphs.js.map +1 -0
  256. package/dist/list-lead-sentence.d.ts +6 -0
  257. package/dist/list-lead-sentence.d.ts.map +1 -0
  258. package/dist/list-lead-sentence.js +20 -0
  259. package/dist/list-lead-sentence.js.map +1 -0
  260. package/dist/paragraph-runs.d.ts +2 -1
  261. package/dist/paragraph-runs.d.ts.map +1 -1
  262. package/dist/paragraph-runs.js +19 -2
  263. package/dist/paragraph-runs.js.map +1 -1
  264. package/dist/recording-title.d.ts +5 -0
  265. package/dist/recording-title.d.ts.map +1 -0
  266. package/dist/recording-title.js +11 -0
  267. package/dist/recording-title.js.map +1 -0
  268. package/dist/sentence-load.d.ts +2 -1
  269. package/dist/sentence-load.d.ts.map +1 -1
  270. package/dist/sentence-load.js +56 -2
  271. package/dist/sentence-load.js.map +1 -1
  272. package/dist/stray-space.d.ts +5 -2
  273. package/dist/stray-space.d.ts.map +1 -1
  274. package/dist/stray-space.js +24 -2
  275. package/dist/stray-space.js.map +1 -1
  276. package/dist/structure/due-column.d.ts +5 -0
  277. package/dist/structure/due-column.d.ts.map +1 -0
  278. package/dist/structure/due-column.js +30 -0
  279. package/dist/structure/due-column.js.map +1 -0
  280. package/dist/structure/generic-role.d.ts +1 -0
  281. package/dist/structure/generic-role.d.ts.map +1 -1
  282. package/dist/structure/generic-role.js +6 -0
  283. package/dist/structure/generic-role.js.map +1 -1
  284. package/dist/structure/party-role.d.ts.map +1 -1
  285. package/dist/structure/party-role.js +4 -2
  286. package/dist/structure/party-role.js.map +1 -1
  287. package/dist/title-case-name.d.ts +5 -0
  288. package/dist/title-case-name.d.ts.map +1 -1
  289. package/dist/title-case-name.js +14 -0
  290. package/dist/title-case-name.js.map +1 -1
  291. package/package.json +3 -3
  292. package/rules/all-caps-shouting.yaml +2 -2
  293. package/rules/bare-url-mix.yaml +2 -2
  294. package/rules/bold-density.yaml +2 -2
  295. package/rules/bold-label-list.yaml +4 -4
  296. package/rules/clause-chain.yaml +2 -2
  297. package/rules/closing-cliche.yaml +2 -2
  298. package/rules/code-fence-language-mix.yaml +2 -2
  299. package/rules/colloquial-opener.yaml +3 -3
  300. package/rules/comparative-without-baseline.yaml +2 -2
  301. package/rules/dangling-participle.yaml +2 -2
  302. package/rules/date-order.yaml +2 -2
  303. package/rules/defined-term-form.yaml +2 -2
  304. package/rules/doubled-punctuation.yaml +2 -2
  305. package/rules/duration-mismatch.yaml +2 -2
  306. package/rules/email-subject-length.yaml +2 -2
  307. package/rules/empty-intensifier.yaml +2 -2
  308. package/rules/figure-reference-order.yaml +2 -2
  309. package/rules/hyphen-as-dash.yaml +2 -2
  310. package/rules/katakana-density.yaml +2 -2
  311. package/rules/list-item-form-mix.yaml +2 -2
  312. package/rules/max-ten.yaml +3 -3
  313. package/rules/missing-final-period.yaml +2 -2
  314. package/rules/name-variant.yaml +2 -2
  315. package/rules/ngram-repetition.yaml +2 -2
  316. package/rules/no-lead.yaml +2 -2
  317. package/rules/no-mixed-desumasu.yaml +3 -2
  318. package/rules/no-nakaguro-parallel.yaml +2 -2
  319. package/rules/number-style-consistency.yaml +2 -2
  320. package/rules/numeral-sentence-start.yaml +2 -2
  321. package/rules/one-sentence-paragraph-run.yaml +2 -2
  322. package/rules/orthographic-variant.yaml +2 -2
  323. package/rules/outside-announced-list.yaml +2 -2
  324. package/rules/oxford-comma-consistency.yaml +2 -2
  325. package/rules/paragraph-restatement.yaml +2 -2
  326. package/rules/party-role-name.yaml +2 -2
  327. package/rules/person-consistency.yaml +2 -2
  328. package/rules/preamble-length.yaml +2 -2
  329. package/rules/repeated-conjunction.yaml +2 -2
  330. package/rules/repeated-sentence-head.yaml +2 -2
  331. package/rules/request-without-deadline.yaml +2 -2
  332. package/rules/requirement-smell.yaml +2 -2
  333. package/rules/space-before-punctuation.yaml +2 -2
  334. package/rules/stray-space.yaml +7 -4
  335. package/rules/summary-fact-mismatch.yaml +2 -2
  336. package/rules/taigen-dome-in-prose.yaml +2 -2
  337. package/rules/teki-overuse.yaml +2 -2
  338. package/rules/title-case-consistency.yaml +2 -2
  339. package/rules/title-length.yaml +2 -2
  340. package/rules/total-mismatch.yaml +1 -1
  341. package/rules/unbalanced-bracket.yaml +3 -3
  342. package/rules/undefined-term.yaml +2 -2
  343. package/rules/unqualified-superlative.yaml +2 -2
  344. package/rules/vague-word-density.yaml +2 -2
  345. package/rules/very-adjective.yaml +1 -1
  346. package/rules/warning-without-action.yaml +2 -2
  347. package/rules/yori-as-from.yaml +1 -0
  348. package/src/announced-list.ts +12 -3
  349. package/src/body-section.ts +19 -0
  350. package/src/derived/durations.ts +3 -2
  351. package/src/derived/marked-dates.ts +4 -0
  352. package/src/detectors/acronym-capitals.ts +30 -0
  353. package/src/detectors/bare-comparative.ts +12 -2
  354. package/src/detectors/bare-word-list.ts +61 -0
  355. package/src/detectors/bold-field-label.ts +33 -0
  356. package/src/detectors/bold-label.ts +74 -12
  357. package/src/detectors/broken-link.ts +23 -2
  358. package/src/detectors/byline-list.ts +24 -0
  359. package/src/detectors/caps-screen-label.ts +15 -0
  360. package/src/detectors/casual-voice.ts +30 -0
  361. package/src/detectors/count-per-section.ts +6 -2
  362. package/src/detectors/dangling-opener.ts +12 -1
  363. package/src/detectors/date-year.ts +12 -1
  364. package/src/detectors/defined-term-form.ts +19 -3
  365. package/src/detectors/document-shape.ts +16 -2
  366. package/src/detectors/doubled-punctuation.ts +26 -1
  367. package/src/detectors/email-letter.ts +5 -3
  368. package/src/detectors/email-subject-reference.ts +36 -0
  369. package/src/detectors/fact-consistency.ts +2 -2
  370. package/src/detectors/figure-order.ts +8 -2
  371. package/src/detectors/gram-heading.ts +15 -1
  372. package/src/detectors/heading-case.ts +7 -1
  373. package/src/detectors/heading-numbering.ts +1 -9
  374. package/src/detectors/hyphen-name-suffix.ts +30 -0
  375. package/src/detectors/katakana-density.ts +8 -4
  376. package/src/detectors/lexicon.ts +18 -1
  377. package/src/detectors/link-shape.ts +16 -2
  378. package/src/detectors/list-item-phrase.ts +86 -0
  379. package/src/detectors/list-layout.ts +17 -0
  380. package/src/detectors/list-lead-in.ts +1 -19
  381. package/src/detectors/list-parallel.ts +31 -28
  382. package/src/detectors/mark-shape.ts +13 -3
  383. package/src/detectors/measured-facts.ts +11 -4
  384. package/src/detectors/middle-dot.ts +32 -0
  385. package/src/detectors/missing-final-period.ts +14 -1
  386. package/src/detectors/name-variant.ts +2 -1
  387. package/src/detectors/number-style.ts +26 -4
  388. package/src/detectors/numeral-opener.ts +4 -2
  389. package/src/detectors/open-end-names.ts +11 -1
  390. package/src/detectors/ordinary-phrase.ts +10 -0
  391. package/src/detectors/orthographic-variant.ts +2 -2
  392. package/src/detectors/output-lead-in.ts +28 -0
  393. package/src/detectors/outside-announced-list.ts +6 -1
  394. package/src/detectors/oxford-comma.ts +3 -1
  395. package/src/detectors/paragraph-restatement.ts +17 -2
  396. package/src/detectors/person-consistency.ts +14 -2
  397. package/src/detectors/quoted-title-line.ts +13 -0
  398. package/src/detectors/register-interview.ts +22 -0
  399. package/src/detectors/registry/colloquial-opener-pile.ts +4 -0
  400. package/src/detectors/repeated-head.ts +32 -6
  401. package/src/detectors/request-owner.ts +5 -2
  402. package/src/detectors/run-together.ts +15 -0
  403. package/src/detectors/sentence-counts.ts +18 -3
  404. package/src/detectors/sentence-ending.ts +13 -2
  405. package/src/detectors/sentence-parts.ts +20 -2
  406. package/src/detectors/space-before-punctuation.ts +24 -4
  407. package/src/detectors/stray-space.ts +1 -1
  408. package/src/detectors/structure-tree.ts +12 -9
  409. package/src/detectors/structure.ts +4 -1
  410. package/src/detectors/superlative-context.ts +10 -0
  411. package/src/detectors/technical-docs.ts +5 -3
  412. package/src/detectors/token-shape.ts +19 -4
  413. package/src/detectors/unbalanced-bracket.ts +9 -1
  414. package/src/detectors/undefined-term.ts +5 -1
  415. package/src/detectors/vague-density.ts +15 -2
  416. package/src/front-matter.ts +14 -0
  417. package/src/genre-check.ts +1 -1
  418. package/src/genre.ts +1 -15
  419. package/src/labelled-note-paragraphs.ts +30 -0
  420. package/src/list-lead-sentence.ts +24 -0
  421. package/src/paragraph-runs.ts +25 -2
  422. package/src/recording-title.ts +16 -0
  423. package/src/sentence-load.ts +68 -2
  424. package/src/stray-space.ts +37 -6
  425. package/src/structure/due-column.ts +33 -0
  426. package/src/structure/generic-role.ts +8 -0
  427. package/src/structure/party-role.ts +3 -2
  428. package/src/title-case-name.ts +19 -0
@@ -1,7 +1,7 @@
1
1
  import type { Span } from "../plugin.ts";
2
2
  import { bySentence } from "./sentence-buckets.ts";
3
3
  import { calendarDateOf, dateOf, shifted, valueOf, type DurationUnit } from "./date-arithmetic.ts";
4
- import { markedPair, type MarkText } from "./marked-dates.ts";
4
+ import { bothStarts, markedPair, type MarkText } from "./marked-dates.ts";
5
5
 
6
6
  /**
7
7
  * 始まりと期間と終わりを一つの文に書いたもの(「4月1日から3か月間(6月30日まで)」"for 3 months from April 1, 2026 (until
@@ -10,6 +10,7 @@ import { markedPair, type MarkText } from "./marked-dates.ts";
10
10
  * (4月16日)」)。どれとも合わないときだけ言う。
11
11
  * 文に期間がちょうど一つのときだけ読む。日付が三つ以上なら、始まりと終わりを語で印した組(「7月1日から」「(7月31日まで)」)だけを
12
12
  * 読む。印が無ければ、どの日付とどの期間が組なのか決まらない。
13
+ * 日付が二つでも、どちらも始まりの印(from、から)なら二つの組の始まりで、組にしない。
13
14
  * 範囲のすぐ後ろの括弧に書いた期間(「9月1日〜9月30日(30日間)」)は範囲そのものの長さで、期間が過ぎた日を終わりに書くことはない。
14
15
  */
15
16
  export type DatedValue = Span & { readonly value: string };
@@ -99,7 +100,7 @@ const reversed = ([start, end]: readonly [DatedValue, DatedValue]): boolean =>
99
100
 
100
101
  const pairOf = (sentence: Span, inDates: readonly DatedValue[], duration: Duration, text: MarkText): readonly [DatedValue, DatedValue] | undefined => {
101
102
  const [first, second] = inDates;
102
- if (inDates.length === 2 && first !== undefined && second !== undefined) return [first, second];
103
+ if (inDates.length === 2 && first !== undefined && second !== undefined) return bothStarts(text, [first, second], duration) ? undefined : [first, second];
103
104
  const marked = inDates.length > 2 ? markedPair(text, sentence, inDates, duration) : undefined;
104
105
  return marked === undefined || reversed(marked) ? undefined : marked;
105
106
  };
@@ -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));
@@ -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
+ };
@@ -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
+ };
@@ -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. */
@@ -83,22 +120,45 @@ const isStatement = (tokens: readonly Token[]): boolean => {
83
120
  return head !== undefined && !VERBAL.has(head.pos) && words.slice(1).some((token) => VERBAL.has(token.pos));
84
121
  };
85
122
 
86
- /** The bold run a paragraph opens with, as a label or lead sentence, and where in the paragraph its words end. */
87
- const openingRunOf = (text: string): { words: string; end: number } | undefined => {
88
- const match = BOLD_LABEL.exec(text) ?? BOLD_LEAD.exec(text);
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);
89
146
  const words = match?.[2];
90
147
  if (match?.[1] === undefined || words === undefined || isCodeOnly(words.trim())) return undefined;
91
- return { words: words.trim(), end: match[1].length + words.length };
148
+ return { words: words.trim(), end: match[1].length + words.length, stopped: label === null };
92
149
  };
93
150
 
94
- /** The statement a paragraph opens with in bold (**Usage grew each week**: …), or undefined. A question (an FAQ's) is not a statement. */
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
+ */
95
155
  const boldStatementOf = (doc: ProseDocument, paragraph: Paragraph): string | undefined => {
96
156
  const { start, end } = paragraph.span;
97
157
  const run = isQuotedAt(doc.source, start) ? undefined : openingRunOf(doc.source.slice(start, end));
98
158
  if (run === undefined || /[??]$/u.test(run.words)) return undefined;
99
159
  const runEnd = start + run.end;
100
160
  const tokens = paragraph.sentences.flatMap((sentence) => sentence.tokens ?? []).filter((token) => token.span.start >= start && token.span.start < runEnd);
101
- return isStatement(tokens) ? run.words.replace(/[.!。!]$/u, "") : undefined;
161
+ return isStatement(tokens) || (run.stopped && isImperativeSentence(tokens)) ? run.words.replace(/[.!。!]$/u, "") : undefined;
102
162
  };
103
163
 
104
164
  /** The count reported and the limit it reached: all the labelled items, or else the bold lead sentences alone, or undefined. */
@@ -119,8 +179,9 @@ const finding = (doc: ProseDocument, span: Span, label: string, found: { count:
119
179
  });
120
180
 
121
181
  /**
122
- * Paragraphs that each open with a bold statement (**Usage grew each week**: …): findings set as captions. Human run-in heads
123
- * are terms, imperatives or questions (**Work schedule**:, **Talk to the people:**, **Who is my audience?**), and are not counted.
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.
124
185
  */
125
186
  const statementParagraphs = (doc: ProseDocument, options: DetectorOptions): Finding[] => {
126
187
  const statements = doc.paragraphs.flatMap((paragraph) => {
@@ -135,10 +196,11 @@ const statementParagraphs = (doc: ProseDocument, options: DetectorOptions): Find
135
196
  /**
136
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.
137
198
  * Bold lead sentences (- **Check one result by hand.** …) report at fewer items than colon labels: human documents write a few
138
- * 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.
139
201
  */
140
202
  export const boldLabelList: Detector = (doc, options): Finding[] => {
141
- const items = unquotedItems(doc, labelOrLeadOf);
203
+ const items = captionItems(doc, labelOrLeadOf);
142
204
  const first = items[0];
143
205
  const leads = items.filter((span) => boldLabelOf(doc.source.slice(span.start, span.end)) === undefined).length;
144
206
  const found = reached(items, leads, options);
@@ -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));
@@ -1,6 +1,7 @@
1
1
  import { charLength, proseText } from "../measure.ts";
2
2
  import type { Detector, Finding, Section } from "../plugin.ts";
3
3
  import { isQuotedMention } from "./bold-quoted.ts";
4
+ import { isFieldLabel } from "./bold-field-label.ts";
4
5
 
5
6
  /** これより短い節では密度が暴れる。43 字に 1 箇所で「1000 字あたり 23」になる。 */
6
7
  const MIN_CHARS = 200;
@@ -9,9 +10,12 @@ const PER = 1000;
9
10
 
10
11
  const charsOf = (section: Section): number => section.sentences.reduce((sum, sentence) => sum + charLength(sentence), 0);
11
12
 
12
- /** The section's bold runs, less those that only quote words: a README bolds the part of an example sentence it talks about. */
13
+ /**
14
+ * The section's bold runs, less those that only quote words (a README bolds the part of an example sentence it talks about)
15
+ * and the field labels opening a line (**Date:** in a memo's header).
16
+ */
13
17
  const boldsOf = (section: Section, source: string): number =>
14
- section.strongs === undefined ? section.strongCount : section.strongs.filter((span) => !isQuotedMention(source, span)).length;
18
+ section.strongs === undefined ? section.strongCount : section.strongs.filter((span) => !isQuotedMention(source, span) && !isFieldLabel(source, span)).length;
15
19
 
16
20
  /**
17
21
  * 節あたりの「密度」を見る。件数ではない。
@@ -14,6 +14,8 @@ const BE = "be";
14
14
  const HAVE = "have";
15
15
  /** be の後ろで読点が来たら、it is … は挿入句(Testing the integration, it is worth noting, requires …)。 */
16
16
  const PARENTHETICAL_REACH = 4;
17
+ /** 節を作らない動詞の形(-ing、分詞、不定詞)。 */
18
+ const NON_FINITE = ["Ger", "Part", "Inf"];
17
19
 
18
20
  const lower = (token: Token | undefined): string => token?.surface.toLowerCase() ?? "";
19
21
 
@@ -33,6 +35,15 @@ const isBeAfter = (tokens: readonly Token[], at: number): boolean => {
33
35
  return (verb?.pos === "AUX" || lemmaOf(verb) === HAVE) && lemmaOf(tokens[at + 1]) === BE;
34
36
  };
35
37
 
38
+ /**
39
+ * 読点より前に定形の動詞がある(Treating masculinity as a pathology isn’t progressivism, it’s prejudice)。-ing の句はその
40
+ * 動詞の主語で、前に置いた分詞の句ではない。
41
+ */
42
+ const hasFiniteVerb = (tokens: readonly Token[], comma: number): boolean =>
43
+ tokens
44
+ .slice(1, comma)
45
+ .some((token) => (token.pos === "AUX" || [BE, HAVE].includes(lemmaOf(token))) && NON_FINITE.every((form) => token.features?.["VerbForm"] !== form));
46
+
36
47
  const isParenthetical = (tokens: readonly Token[], at: number): boolean => tokens.slice(at, at + PARENTHETICAL_REACH).some((token) => token.surface === ",");
37
48
 
38
49
  export const danglingOpenerIn = (
@@ -46,7 +57,7 @@ export const danglingOpenerIn = (
46
57
  const comma = tokens.findIndex((token, at) => at > 0 && token.surface === ",");
47
58
  const subject = tokens[comma + 1];
48
59
  if (comma === -1 || comma > MAX_OPENER_TOKENS || subject === undefined || !subjects.has(lower(subject)) || !isBeAfter(tokens, comma + 2)) return undefined;
49
- if (isParenthetical(tokens, comma + 3)) return undefined;
60
+ if (isParenthetical(tokens, comma + 3) || hasFiniteVerb(tokens, comma)) return undefined;
50
61
  const last = tokens[comma - 1] ?? first;
51
62
  return { opener: source.slice(first.span.start, last.span.end), subject, offset: first.span.start };
52
63
  };
@@ -109,6 +109,9 @@ const lineStart = (source: string, offset: number): number => source.lastIndexOf
109
109
 
110
110
  const TABLE_ROW = /^\s*\|/u;
111
111
 
112
+ /** A blank line: the dates on either side are in different paragraphs. */
113
+ const PARAGRAPH_BREAK = /\n[ \t]*\n/u;
114
+
112
115
  const isTableRowAt = (source: string, offset: number): boolean => TABLE_ROW.test(source.slice(lineStart(source, offset), offset));
113
116
 
114
117
  const lineEnd = (source: string, offset: number): number => {
@@ -188,12 +191,20 @@ export const yearGaps = (
188
191
  if (previous !== undefined && opensSpan(previous, point, source, anyYear.joiners) && markedAnyYear(previous)) return true;
189
192
  return next !== undefined && opensSpan(point, next, source, anyYear.joiners) && hasYearWord(next, source, yearWords);
190
193
  };
194
+ // A yearly schedule told in one paragraph (a marketing year beginning July 1, proclaimed by May 15, … by June 10) keeps
195
+ // to any year: a yearless date after one that is any year's, with no dated date between, is any year's too.
196
+ const carriesAnyYear = (point: DatePoint): boolean => {
197
+ const previous = previousOf.get(point);
198
+ if (previous === undefined || !MONTH_DAY.test(previous.value) || PARAGRAPH_BREAK.test(source.slice(previous.end, point.offset))) return false;
199
+ return yearOfAny(previous) || carriesAnyYear(previous);
200
+ };
191
201
  // A recurring day or an example's date has no year to write, and is not the document's way of writing dates either.
192
202
  // A date that carries a dated account forward (On April 21, 1952, … on April 30 … May 3) takes that account's year. A
193
203
  // table cell is a record whose fields keep one format: a dated column with one year dropped is still a slip.
194
204
  const continuesRun = (point: DatePoint): boolean => !isTableRowAt(source, point.offset) && continuesDatedRun(point, (earlier) => previousOf.get(earlier));
195
205
  const yearless = points.filter(
196
- (point) => MONTH_DAY.test(point.value) && !yearGiven(point, anchors, source, yearWords) && !yearOfAny(point) && !continuesRun(point),
206
+ (point) =>
207
+ MONTH_DAY.test(point.value) && !yearGiven(point, anchors, source, yearWords) && !yearOfAny(point) && !carriesAnyYear(point) && !continuesRun(point),
197
208
  );
198
209
  const span = spanOf(dated);
199
210
  const unclear = dated.length >= 2 && yearless.length < dated.length && span !== undefined && span.to > span.from;
@@ -9,7 +9,7 @@ import { quoteAt } from "./structure-tree.ts";
9
9
  import { quotesWording, wordingCuesOf } from "./quoted-wording.ts";
10
10
  import { isPartOfAddress } from "./address-word.ts";
11
11
  import { exactOffsets, extendedAfter, extendedBefore } from "./term-extension.ts";
12
- import { headsKindPhrase, insideLongerTerm, isNamedAsTerm, isNarrowedUse } from "./ordinary-phrase.ts";
12
+ import { headsKindPhrase, insideLongerTerm, isNamedAsTerm, isNarrowedUse, isPartitiveUse } from "./ordinary-phrase.ts";
13
13
  import { CLOSES_SENTENCE, isNameField, isSignatureLine, opensClosingBlock, SLACK } from "./name-field.ts";
14
14
  import type { Detector, Finding, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
15
15
 
@@ -173,14 +173,19 @@ const quotedFindings = (doc: ProseDocument, term: DefinedTerm, uses: readonly nu
173
173
 
174
174
  /**
175
175
  * A lower-case use that is the ordinary word in a phrase of its own: inside another defined term (certificate of merger),
176
- * narrowed by the word before it (the common parent), or heading a kind of thing (certificates of deposit).
176
+ * narrowed by the word before it (the common parent), picked out of a kind (some of these terms), or heading a kind of
177
+ * thing (certificates of deposit).
177
178
  */
178
179
  const isOrdinaryPhraseAt = (doc: ProseDocument, offset: number, term: string, defined: readonly string[]): boolean => {
179
180
  if (insideLongerTerm(doc.source, offset, term, defined)) return true;
180
181
  const { tokens, at } = tokensAt(doc, offset);
181
182
  if (at === -1) return false;
182
183
  const last = tokens.findLastIndex((token) => token.span.start < offset + term.length);
183
- return isNarrowedUse(tokens, at, patternsOf(doc, "defined-term-pointer")) || headsKindPhrase(tokens, last);
184
+ return (
185
+ isNarrowedUse(tokens, at, patternsOf(doc, "defined-term-pointer")) ||
186
+ isPartitiveUse(tokens, at, patternsOf(doc, "defined-term-partitive")) ||
187
+ headsKindPhrase(tokens, last)
188
+ );
184
189
  };
185
190
 
186
191
  /** The term written longer with a word of its definition (文書管理責任者, the Application), after the sentence that defines it. */
@@ -203,12 +208,23 @@ const extendedFindings = (doc: ProseDocument, texts: readonly BodyText[], term:
203
208
  });
204
209
  };
205
210
 
211
+ /**
212
+ * A definition that interprets another instrument's term (憲法一九条にいう「良心の自由」とは): the term is that instrument's
213
+ * wording, which the document goes on quoting as written, not a term of its own.
214
+ */
215
+ const definesBorrowedWording = (doc: ProseDocument, spans: readonly Span[]): boolean => {
216
+ const wording = wordingCuesOf(doc.lexicons["quoted-wording-cue"] ?? []);
217
+ // A quoted definition's span runs from its opening quote to its closing one.
218
+ return spans.some((span) => OPENING_QUOTES.has(doc.source.charAt(span.start)) && quotesWording(doc.source, span.start, span.end - 1, wording));
219
+ };
220
+
206
221
  export const definedTermForm: Detector = (doc, options): Finding[] => {
207
222
  if (doc.structure === undefined) return [];
208
223
  const texts = bodyOf(doc);
209
224
  const terms = definedTerms(doc.structure);
210
225
  const defined = terms.map((term) => term.term);
211
226
  return firstDefinitions(terms).flatMap(({ term, spans }) => {
227
+ if (definesBorrowedWording(doc, spans)) return [];
212
228
  const uses = usesOf(term.term, texts, spans, "loose");
213
229
  const definingEnd = definingSentenceEnd(doc, term.span);
214
230
  const quoted = quotedFindings(doc, term, uses, definingEnd);