chaffjs 0.45.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/dist/announced-list.d.ts +2 -1
  2. package/dist/announced-list.d.ts.map +1 -1
  3. package/dist/announced-list.js +3 -1
  4. package/dist/announced-list.js.map +1 -1
  5. package/dist/body-section.d.ts +7 -0
  6. package/dist/body-section.d.ts.map +1 -1
  7. package/dist/body-section.js +15 -0
  8. package/dist/body-section.js.map +1 -1
  9. package/dist/derived/durations.d.ts +1 -0
  10. package/dist/derived/durations.d.ts.map +1 -1
  11. package/dist/derived/durations.js +2 -2
  12. package/dist/derived/durations.js.map +1 -1
  13. package/dist/derived/marked-dates.d.ts +2 -0
  14. package/dist/derived/marked-dates.d.ts.map +1 -1
  15. package/dist/derived/marked-dates.js +2 -0
  16. package/dist/derived/marked-dates.js.map +1 -1
  17. package/dist/detectors/acronym-capitals.d.ts +6 -0
  18. package/dist/detectors/acronym-capitals.d.ts.map +1 -0
  19. package/dist/detectors/acronym-capitals.js +30 -0
  20. package/dist/detectors/acronym-capitals.js.map +1 -0
  21. package/dist/detectors/bare-comparative.d.ts +1 -0
  22. package/dist/detectors/bare-comparative.d.ts.map +1 -1
  23. package/dist/detectors/bare-comparative.js +9 -2
  24. package/dist/detectors/bare-comparative.js.map +1 -1
  25. package/dist/detectors/bare-word-list.d.ts +7 -0
  26. package/dist/detectors/bare-word-list.d.ts.map +1 -0
  27. package/dist/detectors/bare-word-list.js +43 -0
  28. package/dist/detectors/bare-word-list.js.map +1 -0
  29. package/dist/detectors/bold-field-label.d.ts +8 -0
  30. package/dist/detectors/bold-field-label.d.ts.map +1 -0
  31. package/dist/detectors/bold-field-label.js +31 -0
  32. package/dist/detectors/bold-field-label.js.map +1 -0
  33. package/dist/detectors/bold-label.d.ts +21 -2
  34. package/dist/detectors/bold-label.d.ts.map +1 -1
  35. package/dist/detectors/bold-label.js +66 -13
  36. package/dist/detectors/bold-label.js.map +1 -1
  37. package/dist/detectors/broken-link.d.ts.map +1 -1
  38. package/dist/detectors/broken-link.js +22 -4
  39. package/dist/detectors/broken-link.js.map +1 -1
  40. package/dist/detectors/byline-list.d.ts +4 -0
  41. package/dist/detectors/byline-list.d.ts.map +1 -0
  42. package/dist/detectors/byline-list.js +19 -0
  43. package/dist/detectors/byline-list.js.map +1 -0
  44. package/dist/detectors/caps-screen-label.d.ts +3 -0
  45. package/dist/detectors/caps-screen-label.d.ts.map +1 -0
  46. package/dist/detectors/caps-screen-label.js +13 -0
  47. package/dist/detectors/caps-screen-label.js.map +1 -0
  48. package/dist/detectors/casual-voice.d.ts +8 -0
  49. package/dist/detectors/casual-voice.d.ts.map +1 -0
  50. package/dist/detectors/casual-voice.js +22 -0
  51. package/dist/detectors/casual-voice.js.map +1 -0
  52. package/dist/detectors/char-shape.js +1 -1
  53. package/dist/detectors/char-shape.js.map +1 -1
  54. package/dist/detectors/closing-cliche.d.ts +2 -1
  55. package/dist/detectors/closing-cliche.d.ts.map +1 -1
  56. package/dist/detectors/closing-cliche.js +10 -2
  57. package/dist/detectors/closing-cliche.js.map +1 -1
  58. package/dist/detectors/count-per-section.d.ts.map +1 -1
  59. package/dist/detectors/count-per-section.js +6 -2
  60. package/dist/detectors/count-per-section.js.map +1 -1
  61. package/dist/detectors/dangling-opener.d.ts.map +1 -1
  62. package/dist/detectors/dangling-opener.js +10 -1
  63. package/dist/detectors/dangling-opener.js.map +1 -1
  64. package/dist/detectors/date-year.d.ts.map +1 -1
  65. package/dist/detectors/date-year.js +11 -1
  66. package/dist/detectors/date-year.js.map +1 -1
  67. package/dist/detectors/defined-term-form.d.ts.map +1 -1
  68. package/dist/detectors/defined-term-form.js +17 -3
  69. package/dist/detectors/defined-term-form.js.map +1 -1
  70. package/dist/detectors/document-shape.d.ts +4 -1
  71. package/dist/detectors/document-shape.d.ts.map +1 -1
  72. package/dist/detectors/document-shape.js +12 -2
  73. package/dist/detectors/document-shape.js.map +1 -1
  74. package/dist/detectors/doubled-punctuation.d.ts.map +1 -1
  75. package/dist/detectors/doubled-punctuation.js +24 -1
  76. package/dist/detectors/doubled-punctuation.js.map +1 -1
  77. package/dist/detectors/email-letter.d.ts.map +1 -1
  78. package/dist/detectors/email-letter.js +5 -2
  79. package/dist/detectors/email-letter.js.map +1 -1
  80. package/dist/detectors/email-subject-reference.d.ts +6 -0
  81. package/dist/detectors/email-subject-reference.d.ts.map +1 -0
  82. package/dist/detectors/email-subject-reference.js +31 -0
  83. package/dist/detectors/email-subject-reference.js.map +1 -0
  84. package/dist/detectors/en-shape.d.ts.map +1 -1
  85. package/dist/detectors/en-shape.js +5 -4
  86. package/dist/detectors/en-shape.js.map +1 -1
  87. package/dist/detectors/fact-consistency.js +2 -2
  88. package/dist/detectors/fact-consistency.js.map +1 -1
  89. package/dist/detectors/figure-order.d.ts +1 -1
  90. package/dist/detectors/figure-order.d.ts.map +1 -1
  91. package/dist/detectors/figure-order.js +7 -2
  92. package/dist/detectors/figure-order.js.map +1 -1
  93. package/dist/detectors/fullwidth-alnum.d.ts +4 -0
  94. package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
  95. package/dist/detectors/fullwidth-alnum.js +31 -9
  96. package/dist/detectors/fullwidth-alnum.js.map +1 -1
  97. package/dist/detectors/gram-heading.d.ts.map +1 -1
  98. package/dist/detectors/gram-heading.js +13 -1
  99. package/dist/detectors/gram-heading.js.map +1 -1
  100. package/dist/detectors/heading-case.d.ts.map +1 -1
  101. package/dist/detectors/heading-case.js +6 -1
  102. package/dist/detectors/heading-case.js.map +1 -1
  103. package/dist/detectors/heading-numbering.d.ts.map +1 -1
  104. package/dist/detectors/heading-numbering.js +1 -7
  105. package/dist/detectors/heading-numbering.js.map +1 -1
  106. package/dist/detectors/hyphen-name-suffix.d.ts +3 -0
  107. package/dist/detectors/hyphen-name-suffix.d.ts.map +1 -0
  108. package/dist/detectors/hyphen-name-suffix.js +24 -0
  109. package/dist/detectors/hyphen-name-suffix.js.map +1 -0
  110. package/dist/detectors/katakana-density.d.ts.map +1 -1
  111. package/dist/detectors/katakana-density.js +7 -4
  112. package/dist/detectors/katakana-density.js.map +1 -1
  113. package/dist/detectors/lexicon.d.ts +1 -0
  114. package/dist/detectors/lexicon.d.ts.map +1 -1
  115. package/dist/detectors/lexicon.js +36 -4
  116. package/dist/detectors/lexicon.js.map +1 -1
  117. package/dist/detectors/link-shape.d.ts.map +1 -1
  118. package/dist/detectors/link-shape.js +10 -2
  119. package/dist/detectors/link-shape.js.map +1 -1
  120. package/dist/detectors/list-item-phrase.d.ts +20 -0
  121. package/dist/detectors/list-item-phrase.d.ts.map +1 -0
  122. package/dist/detectors/list-item-phrase.js +73 -0
  123. package/dist/detectors/list-item-phrase.js.map +1 -0
  124. package/dist/detectors/list-layout.d.ts +5 -0
  125. package/dist/detectors/list-layout.d.ts.map +1 -1
  126. package/dist/detectors/list-layout.js +12 -0
  127. package/dist/detectors/list-layout.js.map +1 -1
  128. package/dist/detectors/list-lead-in.d.ts.map +1 -1
  129. package/dist/detectors/list-lead-in.js +1 -17
  130. package/dist/detectors/list-lead-in.js.map +1 -1
  131. package/dist/detectors/list-parallel.d.ts.map +1 -1
  132. package/dist/detectors/list-parallel.js +29 -24
  133. package/dist/detectors/list-parallel.js.map +1 -1
  134. package/dist/detectors/mark-shape.d.ts +1 -1
  135. package/dist/detectors/mark-shape.d.ts.map +1 -1
  136. package/dist/detectors/mark-shape.js +10 -3
  137. package/dist/detectors/mark-shape.js.map +1 -1
  138. package/dist/detectors/measured-facts.d.ts +5 -1
  139. package/dist/detectors/measured-facts.d.ts.map +1 -1
  140. package/dist/detectors/measured-facts.js +7 -3
  141. package/dist/detectors/measured-facts.js.map +1 -1
  142. package/dist/detectors/middle-dot.d.ts +5 -0
  143. package/dist/detectors/middle-dot.d.ts.map +1 -1
  144. package/dist/detectors/middle-dot.js +27 -0
  145. package/dist/detectors/middle-dot.js.map +1 -1
  146. package/dist/detectors/missing-final-period.d.ts.map +1 -1
  147. package/dist/detectors/missing-final-period.js +13 -1
  148. package/dist/detectors/missing-final-period.js.map +1 -1
  149. package/dist/detectors/name-variant.d.ts.map +1 -1
  150. package/dist/detectors/name-variant.js +2 -1
  151. package/dist/detectors/name-variant.js.map +1 -1
  152. package/dist/detectors/number-style.d.ts +2 -0
  153. package/dist/detectors/number-style.d.ts.map +1 -1
  154. package/dist/detectors/number-style.js +19 -4
  155. package/dist/detectors/number-style.js.map +1 -1
  156. package/dist/detectors/numeral-opener.d.ts +1 -1
  157. package/dist/detectors/numeral-opener.d.ts.map +1 -1
  158. package/dist/detectors/numeral-opener.js +4 -2
  159. package/dist/detectors/numeral-opener.js.map +1 -1
  160. package/dist/detectors/open-end-names.d.ts +2 -0
  161. package/dist/detectors/open-end-names.d.ts.map +1 -1
  162. package/dist/detectors/open-end-names.js +8 -1
  163. package/dist/detectors/open-end-names.js.map +1 -1
  164. package/dist/detectors/ordinary-phrase.d.ts +5 -0
  165. package/dist/detectors/ordinary-phrase.d.ts.map +1 -1
  166. package/dist/detectors/ordinary-phrase.js +10 -0
  167. package/dist/detectors/ordinary-phrase.js.map +1 -1
  168. package/dist/detectors/orthographic-variant.js +2 -2
  169. package/dist/detectors/orthographic-variant.js.map +1 -1
  170. package/dist/detectors/output-lead-in.d.ts +3 -0
  171. package/dist/detectors/output-lead-in.d.ts.map +1 -0
  172. package/dist/detectors/output-lead-in.js +26 -0
  173. package/dist/detectors/output-lead-in.js.map +1 -0
  174. package/dist/detectors/outside-announced-list.d.ts.map +1 -1
  175. package/dist/detectors/outside-announced-list.js +6 -1
  176. package/dist/detectors/outside-announced-list.js.map +1 -1
  177. package/dist/detectors/oxford-comma.d.ts.map +1 -1
  178. package/dist/detectors/oxford-comma.js +3 -1
  179. package/dist/detectors/oxford-comma.js.map +1 -1
  180. package/dist/detectors/paragraph-restatement.d.ts +4 -1
  181. package/dist/detectors/paragraph-restatement.d.ts.map +1 -1
  182. package/dist/detectors/paragraph-restatement.js +17 -2
  183. package/dist/detectors/paragraph-restatement.js.map +1 -1
  184. package/dist/detectors/person-consistency.d.ts +2 -1
  185. package/dist/detectors/person-consistency.d.ts.map +1 -1
  186. package/dist/detectors/person-consistency.js +11 -2
  187. package/dist/detectors/person-consistency.js.map +1 -1
  188. package/dist/detectors/quoted-title-line.d.ts +6 -0
  189. package/dist/detectors/quoted-title-line.d.ts.map +1 -0
  190. package/dist/detectors/quoted-title-line.js +14 -0
  191. package/dist/detectors/quoted-title-line.js.map +1 -0
  192. package/dist/detectors/register-interview.d.ts +4 -0
  193. package/dist/detectors/register-interview.d.ts.map +1 -0
  194. package/dist/detectors/register-interview.js +19 -0
  195. package/dist/detectors/register-interview.js.map +1 -0
  196. package/dist/detectors/registry/colloquial-opener-pile.d.ts +3 -0
  197. package/dist/detectors/registry/colloquial-opener-pile.d.ts.map +1 -0
  198. package/dist/detectors/registry/colloquial-opener-pile.js +3 -0
  199. package/dist/detectors/registry/colloquial-opener-pile.js.map +1 -0
  200. package/dist/detectors/repeated-head.d.ts.map +1 -1
  201. package/dist/detectors/repeated-head.js +23 -4
  202. package/dist/detectors/repeated-head.js.map +1 -1
  203. package/dist/detectors/request-owner.d.ts +3 -1
  204. package/dist/detectors/request-owner.d.ts.map +1 -1
  205. package/dist/detectors/request-owner.js +5 -2
  206. package/dist/detectors/request-owner.js.map +1 -1
  207. package/dist/detectors/run-together.d.ts +3 -0
  208. package/dist/detectors/run-together.d.ts.map +1 -0
  209. package/dist/detectors/run-together.js +13 -0
  210. package/dist/detectors/run-together.js.map +1 -0
  211. package/dist/detectors/sentence-counts.d.ts +6 -2
  212. package/dist/detectors/sentence-counts.d.ts.map +1 -1
  213. package/dist/detectors/sentence-counts.js +19 -3
  214. package/dist/detectors/sentence-counts.js.map +1 -1
  215. package/dist/detectors/sentence-ending.d.ts +2 -0
  216. package/dist/detectors/sentence-ending.d.ts.map +1 -1
  217. package/dist/detectors/sentence-ending.js +8 -2
  218. package/dist/detectors/sentence-ending.js.map +1 -1
  219. package/dist/detectors/sentence-parts.d.ts +10 -1
  220. package/dist/detectors/sentence-parts.d.ts.map +1 -1
  221. package/dist/detectors/sentence-parts.js +17 -2
  222. package/dist/detectors/sentence-parts.js.map +1 -1
  223. package/dist/detectors/space-before-punctuation.d.ts +2 -2
  224. package/dist/detectors/space-before-punctuation.d.ts.map +1 -1
  225. package/dist/detectors/space-before-punctuation.js +13 -2
  226. package/dist/detectors/space-before-punctuation.js.map +1 -1
  227. package/dist/detectors/stray-space.js +1 -1
  228. package/dist/detectors/stray-space.js.map +1 -1
  229. package/dist/detectors/structure-tree.d.ts.map +1 -1
  230. package/dist/detectors/structure-tree.js +2 -1
  231. package/dist/detectors/structure-tree.js.map +1 -1
  232. package/dist/detectors/structure.d.ts +1 -0
  233. package/dist/detectors/structure.d.ts.map +1 -1
  234. package/dist/detectors/structure.js +5 -1
  235. package/dist/detectors/structure.js.map +1 -1
  236. package/dist/detectors/superlative-context.d.ts +7 -0
  237. package/dist/detectors/superlative-context.d.ts.map +1 -1
  238. package/dist/detectors/superlative-context.js +6 -0
  239. package/dist/detectors/superlative-context.js.map +1 -1
  240. package/dist/detectors/technical-docs.d.ts.map +1 -1
  241. package/dist/detectors/technical-docs.js +5 -1
  242. package/dist/detectors/technical-docs.js.map +1 -1
  243. package/dist/detectors/token-shape.d.ts.map +1 -1
  244. package/dist/detectors/token-shape.js +16 -3
  245. package/dist/detectors/token-shape.js.map +1 -1
  246. package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
  247. package/dist/detectors/unbalanced-bracket.js +5 -1
  248. package/dist/detectors/unbalanced-bracket.js.map +1 -1
  249. package/dist/detectors/undefined-term.d.ts.map +1 -1
  250. package/dist/detectors/undefined-term.js +5 -1
  251. package/dist/detectors/undefined-term.js.map +1 -1
  252. package/dist/detectors/unknown-word-context.d.ts +8 -0
  253. package/dist/detectors/unknown-word-context.d.ts.map +1 -1
  254. package/dist/detectors/unknown-word-context.js +38 -6
  255. package/dist/detectors/unknown-word-context.js.map +1 -1
  256. package/dist/detectors/unknown-word.d.ts.map +1 -1
  257. package/dist/detectors/unknown-word.js +11 -4
  258. package/dist/detectors/unknown-word.js.map +1 -1
  259. package/dist/detectors/vague-density.d.ts.map +1 -1
  260. package/dist/detectors/vague-density.js +13 -1
  261. package/dist/detectors/vague-density.js.map +1 -1
  262. package/dist/front-matter.d.ts +3 -0
  263. package/dist/front-matter.d.ts.map +1 -0
  264. package/dist/front-matter.js +13 -0
  265. package/dist/front-matter.js.map +1 -0
  266. package/dist/genre-check.js +1 -1
  267. package/dist/genre-check.js.map +1 -1
  268. package/dist/genre.d.ts +0 -2
  269. package/dist/genre.d.ts.map +1 -1
  270. package/dist/genre.js +1 -12
  271. package/dist/genre.js.map +1 -1
  272. package/dist/labelled-note-paragraphs.d.ts +4 -0
  273. package/dist/labelled-note-paragraphs.d.ts.map +1 -0
  274. package/dist/labelled-note-paragraphs.js +21 -0
  275. package/dist/labelled-note-paragraphs.js.map +1 -0
  276. package/dist/list-lead-sentence.d.ts +6 -0
  277. package/dist/list-lead-sentence.d.ts.map +1 -0
  278. package/dist/list-lead-sentence.js +20 -0
  279. package/dist/list-lead-sentence.js.map +1 -0
  280. package/dist/paragraph-runs.d.ts +2 -1
  281. package/dist/paragraph-runs.d.ts.map +1 -1
  282. package/dist/paragraph-runs.js +19 -2
  283. package/dist/paragraph-runs.js.map +1 -1
  284. package/dist/recording-title.d.ts +5 -0
  285. package/dist/recording-title.d.ts.map +1 -0
  286. package/dist/recording-title.js +11 -0
  287. package/dist/recording-title.js.map +1 -0
  288. package/dist/sentence-load.d.ts +2 -1
  289. package/dist/sentence-load.d.ts.map +1 -1
  290. package/dist/sentence-load.js +56 -2
  291. package/dist/sentence-load.js.map +1 -1
  292. package/dist/stray-space.d.ts +5 -2
  293. package/dist/stray-space.d.ts.map +1 -1
  294. package/dist/stray-space.js +24 -2
  295. package/dist/stray-space.js.map +1 -1
  296. package/dist/structure/due-column.d.ts +5 -0
  297. package/dist/structure/due-column.d.ts.map +1 -0
  298. package/dist/structure/due-column.js +30 -0
  299. package/dist/structure/due-column.js.map +1 -0
  300. package/dist/structure/generic-role.d.ts +1 -0
  301. package/dist/structure/generic-role.d.ts.map +1 -1
  302. package/dist/structure/generic-role.js +6 -0
  303. package/dist/structure/generic-role.js.map +1 -1
  304. package/dist/structure/party-role.d.ts.map +1 -1
  305. package/dist/structure/party-role.js +4 -2
  306. package/dist/structure/party-role.js.map +1 -1
  307. package/dist/title-case-name.d.ts +5 -0
  308. package/dist/title-case-name.d.ts.map +1 -1
  309. package/dist/title-case-name.js +14 -0
  310. package/dist/title-case-name.js.map +1 -1
  311. package/package.json +3 -3
  312. package/rules/adverb-overuse.yaml +2 -2
  313. package/rules/ai-tell.yaml +2 -2
  314. package/rules/all-caps-shouting.yaml +2 -2
  315. package/rules/bare-url-mix.yaml +2 -2
  316. package/rules/bold-density.yaml +2 -2
  317. package/rules/bold-label-list.yaml +6 -6
  318. package/rules/clause-chain.yaml +2 -2
  319. package/rules/closing-cliche.yaml +2 -2
  320. package/rules/code-fence-language-mix.yaml +2 -2
  321. package/rules/colloquial-opener.yaml +3 -3
  322. package/rules/comparative-without-baseline.yaml +2 -2
  323. package/rules/dangling-participle.yaml +2 -2
  324. package/rules/date-order.yaml +2 -2
  325. package/rules/date-outside-period.yaml +1 -1
  326. package/rules/defined-term-form.yaml +2 -2
  327. package/rules/doubled-punctuation.yaml +2 -2
  328. package/rules/duration-mismatch.yaml +2 -2
  329. package/rules/email-subject-length.yaml +2 -2
  330. package/rules/empty-intensifier.yaml +2 -2
  331. package/rules/figure-reference-order.yaml +2 -2
  332. package/rules/fullwidth-alnum-consistency.yaml +2 -2
  333. package/rules/hyphen-as-dash.yaml +2 -2
  334. package/rules/katakana-density.yaml +2 -2
  335. package/rules/list-item-form-mix.yaml +2 -2
  336. package/rules/max-kanji-continuous.yaml +4 -3
  337. package/rules/max-ten.yaml +3 -3
  338. package/rules/missing-final-period.yaml +2 -2
  339. package/rules/name-variant.yaml +2 -2
  340. package/rules/ngram-repetition.yaml +2 -2
  341. package/rules/no-lead.yaml +2 -2
  342. package/rules/no-mixed-desumasu.yaml +3 -2
  343. package/rules/no-nakaguro-parallel.yaml +2 -2
  344. package/rules/number-style-consistency.yaml +2 -2
  345. package/rules/numeral-sentence-start.yaml +2 -2
  346. package/rules/one-sentence-paragraph-run.yaml +2 -2
  347. package/rules/orthographic-variant.yaml +2 -2
  348. package/rules/outside-announced-list.yaml +2 -2
  349. package/rules/oxford-comma-consistency.yaml +2 -2
  350. package/rules/paragraph-restatement.yaml +2 -2
  351. package/rules/party-role-name.yaml +2 -2
  352. package/rules/person-consistency.yaml +2 -2
  353. package/rules/preamble-length.yaml +2 -2
  354. package/rules/repeated-conjunction.yaml +2 -2
  355. package/rules/repeated-sentence-head.yaml +2 -2
  356. package/rules/request-without-deadline.yaml +2 -2
  357. package/rules/requirement-smell.yaml +2 -2
  358. package/rules/space-before-punctuation.yaml +2 -2
  359. package/rules/stray-space.yaml +7 -4
  360. package/rules/summary-fact-mismatch.yaml +2 -2
  361. package/rules/taigen-dome-in-prose.yaml +2 -2
  362. package/rules/teki-overuse.yaml +2 -2
  363. package/rules/title-case-consistency.yaml +2 -2
  364. package/rules/title-length.yaml +2 -2
  365. package/rules/total-mismatch.yaml +1 -1
  366. package/rules/unbalanced-bracket.yaml +3 -3
  367. package/rules/undefined-term.yaml +2 -2
  368. package/rules/unknown-word.yaml +2 -2
  369. package/rules/unqualified-superlative.yaml +2 -2
  370. package/rules/vague-word-density.yaml +2 -2
  371. package/rules/very-adjective.yaml +1 -1
  372. package/rules/warning-without-action.yaml +2 -2
  373. package/rules/yori-as-from.yaml +1 -0
  374. package/src/announced-list.ts +12 -3
  375. package/src/body-section.ts +19 -0
  376. package/src/derived/durations.ts +3 -2
  377. package/src/derived/marked-dates.ts +4 -0
  378. package/src/detectors/acronym-capitals.ts +30 -0
  379. package/src/detectors/bare-comparative.ts +12 -2
  380. package/src/detectors/bare-word-list.ts +61 -0
  381. package/src/detectors/bold-field-label.ts +33 -0
  382. package/src/detectors/bold-label.ts +91 -14
  383. package/src/detectors/broken-link.ts +23 -2
  384. package/src/detectors/byline-list.ts +24 -0
  385. package/src/detectors/caps-screen-label.ts +15 -0
  386. package/src/detectors/casual-voice.ts +30 -0
  387. package/src/detectors/char-shape.ts +2 -2
  388. package/src/detectors/closing-cliche.ts +19 -3
  389. package/src/detectors/count-per-section.ts +6 -2
  390. package/src/detectors/dangling-opener.ts +12 -1
  391. package/src/detectors/date-year.ts +12 -1
  392. package/src/detectors/defined-term-form.ts +19 -3
  393. package/src/detectors/document-shape.ts +16 -2
  394. package/src/detectors/doubled-punctuation.ts +26 -1
  395. package/src/detectors/email-letter.ts +5 -3
  396. package/src/detectors/email-subject-reference.ts +36 -0
  397. package/src/detectors/en-shape.ts +5 -4
  398. package/src/detectors/fact-consistency.ts +2 -2
  399. package/src/detectors/figure-order.ts +8 -2
  400. package/src/detectors/fullwidth-alnum.ts +39 -10
  401. package/src/detectors/gram-heading.ts +15 -1
  402. package/src/detectors/heading-case.ts +7 -1
  403. package/src/detectors/heading-numbering.ts +1 -9
  404. package/src/detectors/hyphen-name-suffix.ts +30 -0
  405. package/src/detectors/katakana-density.ts +8 -4
  406. package/src/detectors/lexicon.ts +37 -5
  407. package/src/detectors/link-shape.ts +16 -2
  408. package/src/detectors/list-item-phrase.ts +86 -0
  409. package/src/detectors/list-layout.ts +17 -0
  410. package/src/detectors/list-lead-in.ts +1 -19
  411. package/src/detectors/list-parallel.ts +31 -28
  412. package/src/detectors/mark-shape.ts +13 -3
  413. package/src/detectors/measured-facts.ts +11 -4
  414. package/src/detectors/middle-dot.ts +32 -0
  415. package/src/detectors/missing-final-period.ts +14 -1
  416. package/src/detectors/name-variant.ts +2 -1
  417. package/src/detectors/number-style.ts +26 -4
  418. package/src/detectors/numeral-opener.ts +4 -2
  419. package/src/detectors/open-end-names.ts +11 -1
  420. package/src/detectors/ordinary-phrase.ts +10 -0
  421. package/src/detectors/orthographic-variant.ts +2 -2
  422. package/src/detectors/output-lead-in.ts +28 -0
  423. package/src/detectors/outside-announced-list.ts +6 -1
  424. package/src/detectors/oxford-comma.ts +3 -1
  425. package/src/detectors/paragraph-restatement.ts +17 -2
  426. package/src/detectors/person-consistency.ts +14 -2
  427. package/src/detectors/quoted-title-line.ts +13 -0
  428. package/src/detectors/register-interview.ts +22 -0
  429. package/src/detectors/registry/colloquial-opener-pile.ts +4 -0
  430. package/src/detectors/repeated-head.ts +32 -6
  431. package/src/detectors/request-owner.ts +5 -2
  432. package/src/detectors/run-together.ts +15 -0
  433. package/src/detectors/sentence-counts.ts +18 -3
  434. package/src/detectors/sentence-ending.ts +13 -2
  435. package/src/detectors/sentence-parts.ts +20 -2
  436. package/src/detectors/space-before-punctuation.ts +24 -4
  437. package/src/detectors/stray-space.ts +1 -1
  438. package/src/detectors/structure-tree.ts +12 -9
  439. package/src/detectors/structure.ts +4 -1
  440. package/src/detectors/superlative-context.ts +10 -0
  441. package/src/detectors/technical-docs.ts +5 -3
  442. package/src/detectors/token-shape.ts +19 -4
  443. package/src/detectors/unbalanced-bracket.ts +9 -1
  444. package/src/detectors/undefined-term.ts +5 -1
  445. package/src/detectors/unknown-word-context.ts +44 -6
  446. package/src/detectors/unknown-word.ts +16 -3
  447. package/src/detectors/vague-density.ts +15 -2
  448. package/src/front-matter.ts +14 -0
  449. package/src/genre-check.ts +1 -1
  450. package/src/genre.ts +1 -15
  451. package/src/labelled-note-paragraphs.ts +30 -0
  452. package/src/list-lead-sentence.ts +24 -0
  453. package/src/paragraph-runs.ts +25 -2
  454. package/src/recording-title.ts +16 -0
  455. package/src/sentence-load.ts +68 -2
  456. package/src/stray-space.ts +37 -6
  457. package/src/structure/due-column.ts +33 -0
  458. package/src/structure/generic-role.ts +8 -0
  459. package/src/structure/party-role.ts +3 -2
  460. package/src/title-case-name.ts +19 -0
@@ -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));
@@ -138,7 +138,7 @@ type NameWords = {
138
138
  readonly addressees: AddresseeWords;
139
139
  /** 前に書いたものを指す語(上記、当該)。連なりの頭にあれば、後ろの語に付いた指示の語。 */
140
140
  readonly references: readonly string[];
141
- /** 並べた物の後ろに付く語(等)。連なりの尻にあれば、名前の後ろに付いた語。 */
141
+ /** 並べた物の後ろに付く語(等)と、範囲の端や除くものを示す語(以外、以上)。連なりの尻にあれば、名前の後ろに付いた語。 */
142
142
  readonly listSuffixes: readonly string[];
143
143
  /** 連なりを閉じる、読み手が一つの語と知っている長い語(内閣総理大臣、許可事業者)。その前で連なりを割る。 */
144
144
  readonly knownWords: ReadonlySet<string>;
@@ -363,7 +363,7 @@ const nameWordsOf = (doc: ProseDocument): NameWords => {
363
363
  addressee: patterns("addressee-suffix"),
364
364
  addressees: { prefixes: patterns("addressee-prefix"), titles: patterns("addressee-title"), endings: organisation.units, forms: organisation.closingForms },
365
365
  references: patterns("reference-prefix"),
366
- listSuffixes: patterns("list-suffix"),
366
+ listSuffixes: [...patterns("list-suffix"), ...patterns("range-suffix")],
367
367
  knownWords: new Set(patterns("kanji-known-word")),
368
368
  designations: patterns("designation-phrase"),
369
369
  noticeEndings: patterns("notice-title-ending"),
@@ -9,9 +9,11 @@ import { comparableText, entryIn, entryOpens } from "./lexicon-match.ts";
9
9
  // last 最後の段落にあるときだけ当たる言い回し(てみてほしい)。本文の途中なら普通の勧め
10
10
  // lead:/open:/end:<name> 前の語と文の終わりの語の組(気軽に〜ください)。closing-exhortation と同じ書き方
11
11
  // signoff 最後の段落の、この語で始まり「!」で終わる短い一行(Happy brewing!)
12
+ // stacked 結びにほかの定型があるときだけ当たる言い回し(feel free to)。一つなら普通の礼儀
12
13
 
13
14
  const LAST = "last";
14
15
  const SIGNOFF = "signoff";
16
+ const STACKED = "stacked";
15
17
 
16
18
  /** 一行の結びの挨拶と読む語の数の上限。「Happy brewing!」は二語、「Happy holidays, everyone!」は三語。 */
17
19
  const SIGNOFF_WORDS = 3;
@@ -36,7 +38,12 @@ const lastParagraphSentences = (sentences: readonly Sentence[], paragraphs: read
36
38
  return paragraph === undefined ? [final] : sentences.filter((sentence) => sentence.span.start >= paragraph.span.start);
37
39
  };
38
40
 
39
- type Words = { readonly closing: ReturnType<typeof exhortationWords>; readonly last: readonly LexiconEntry[]; readonly signoff: readonly LexiconEntry[] };
41
+ type Words = {
42
+ readonly closing: ReturnType<typeof exhortationWords>;
43
+ readonly last: readonly LexiconEntry[];
44
+ readonly signoff: readonly LexiconEntry[];
45
+ readonly stacked: readonly LexiconEntry[];
46
+ };
40
47
 
41
48
  /** 最後の段落でだけ当たる語。言い回しなら語彙の語、挨拶の一行なら文そのもの。 */
42
49
  const lastIn = (sentence: Sentence, words: Words): string | undefined =>
@@ -45,11 +52,19 @@ const lastIn = (sentence: Sentence, words: Words): string | undefined =>
45
52
 
46
53
  type Hit = { readonly sentence: Sentence; readonly matched: string };
47
54
 
48
- /** 結びの、定型の言い回しのある文。一文に一つ。 */
55
+ /** 結びの、定型の言い回しのある文。一文に一つ。stacked の語は、ほかの定型が結びにあるときだけ数える。 */
49
56
  export const closingClicheHits = (sentences: readonly Sentence[], paragraphs: readonly Paragraph[], words: Words): Hit[] => {
50
57
  const last = new Set(lastParagraphSentences(sentences, paragraphs));
58
+ const stock = new Map<Sentence, string>(
59
+ sentences.flatMap((sentence): [Sentence, string][] => {
60
+ const matched = exhortationIn(sentence, words.closing) ?? (last.has(sentence) ? lastIn(sentence, words) : undefined);
61
+ return matched === undefined ? [] : [[sentence, matched]];
62
+ }),
63
+ );
64
+ const stackedIn = (sentence: Sentence): string | undefined =>
65
+ stock.size === 0 ? undefined : words.stacked.find((entry) => entryIn(sentence, entry))?.pattern;
51
66
  return sentences.flatMap((sentence) => {
52
- const matched = exhortationIn(sentence, words.closing) ?? (last.has(sentence) ? lastIn(sentence, words) : undefined);
67
+ const matched = stock.get(sentence) ?? stackedIn(sentence);
53
68
  return matched === undefined ? [] : [{ sentence, matched }];
54
69
  });
55
70
  };
@@ -58,6 +73,7 @@ export const closingClicheWords = (lexicon: readonly LexiconEntry[]): Words => (
58
73
  closing: exhortationWords(lexicon),
59
74
  last: lexicon.filter((entry) => entry.group === LAST),
60
75
  signoff: lexicon.filter((entry) => entry.group === SIGNOFF),
76
+ stacked: lexicon.filter((entry) => entry.group === STACKED),
61
77
  });
62
78
 
63
79
  /** 結び(最後の節の終わりの段落)の定型の言い回し。limit は指摘に要る文の数。 */
@@ -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);
@@ -1,6 +1,7 @@
1
1
  // The shape of a document's top: whether the lead says anything the title does not, and whether a title or heading
2
2
  // runs too long to scan. Pure; both read only the sections, paragraphs and tokens chaff has already built.
3
3
  import { newContentMorphemes } from "./content-morphemes.ts";
4
+ import { isRecordingTitle } from "../recording-title.ts";
4
5
  import { formValueTokens, isFormBlock } from "./form-line.ts";
5
6
  import { trigrams } from "./heading-overlap.ts";
6
7
  import { findingAt, writtenHeadings } from "./markup-finding.ts";
@@ -17,10 +18,20 @@ const PERCENT = 100;
17
18
  /** The document's title: its first top-level heading, when it has words. */
18
19
  export const titleSectionOf = (doc: ProseDocument): Section | undefined => doc.sections.find((section) => section.depth === 1 && section.heading.trim() !== "");
19
20
 
20
- /** The paragraph right under the title, with nothing but blank lines between them. A list, a table or an image first is not a lead. */
21
+ /** A marker a site's tooling reads, alone on its line (mdBook's rule identifier r[glossary.ast], {#anchor}): one run of marks and letters, no words. */
22
+ const SPACE = /\s/u;
23
+ const MARKER_BRACKET = /[[\]{}<>]/u;
24
+
25
+ const isMarkerLine = (text: string): boolean => !SPACE.test(text) && MARKER_BRACKET.test(text);
26
+
27
+ /**
28
+ * The paragraph right under the title, with nothing but blank lines between them. A list, a table or an image first is not
29
+ * a lead, and neither is a marker line.
30
+ */
21
31
  export const leadParagraphOf = (doc: ProseDocument, title: Section): Paragraph | undefined => {
22
32
  const first = doc.paragraphs.find((paragraph) => paragraph.span.start >= title.span.start && paragraph.span.start < title.span.end);
23
33
  if (first === undefined || first.sentences.length === 0) return undefined;
34
+ if (isMarkerLine(doc.source.slice(first.span.start, first.span.end).trim())) return undefined;
24
35
  return doc.source.slice(title.span.start, first.span.start).trim() === "" ? first : undefined;
25
36
  };
26
37
 
@@ -162,7 +173,10 @@ export const titleLength: Detector = (doc, options): Finding[] => {
162
173
  return headings
163
174
  .map((heading) => ({ heading, section: sectionOf(doc, heading) }))
164
175
  .map(({ heading, section }) => ({ heading, words: section?.unlabeledHeading ?? heading.text, tokens: section?.headingTokens ?? [] }))
165
- .filter(({ words, tokens }) => !isParagraphHeading(words) && !isQuestionHeading(words) && !endsWithQuestionParticle(tokens, questionParticles))
176
+ .filter(
177
+ ({ words, tokens }) =>
178
+ !isParagraphHeading(words) && !isQuestionHeading(words) && !endsWithQuestionParticle(tokens, questionParticles) && !isRecordingTitle(words),
179
+ )
166
180
  .map(({ heading, words }) => ({ heading, count: headingLength(ownWordsOf(words, citedTitleActions), doc.lengthUnit) }))
167
181
  .filter(({ count }) => count > options.limit)
168
182
  .map(({ heading, count }) => ({
@@ -60,6 +60,30 @@ const marksInNames = ({ start, run }: DoubledMarks, names: readonly Span[]): num
60
60
  return [...run].filter((_, at) => near.some((name) => start + at >= name.start && start + at < name.end)).length;
61
61
  };
62
62
 
63
+ /** 半角の点と空白: 書誌の要素の区切り(「佐藤翔. 」「LRG. 」「p. 136」)。 */
64
+ const ELEMENT_SEPARATOR = /\. /gu;
65
+ /** 書誌の行には、この数より多くの区切りの点がほかにもある(著者の後ろ、誌名の後ろ、ページの前)。 */
66
+ const MIN_OTHER_SEPARATORS = 2;
67
+ /** 和文の終わりの印(。?!)のすぐ後ろの区切りの点(「考えてみた。. LRG.」)。 */
68
+ const STOP_THEN_SEPARATOR = /^[。?!]\.$/u;
69
+
70
+ const lineAround = (text: string, offset: number): { readonly start: number; readonly text: string } => {
71
+ const start = text.lastIndexOf("\n", offset - 1) + 1;
72
+ const end = text.indexOf("\n", offset);
73
+ return { start, text: text.slice(start, end === -1 ? text.length : end) };
74
+ };
75
+
76
+ /**
77
+ * 「。」で終わる書名の後ろの、書誌の要素の区切りの点(佐藤翔. なぜ生まれたのか?その原因を考えてみた。. LRG. 2019, p. 1-9.)。
78
+ * 点の後ろが空白で、同じ行にほかの区切りの点が二つ以上あるときだけ(書誌の行)。
79
+ */
80
+ const isCitationSeparator = (text: string, { start, run }: DoubledMarks): boolean => {
81
+ if (!STOP_THEN_SEPARATOR.test(run) || text.charAt(start + run.length) !== " ") return false;
82
+ const line = lineAround(text, start);
83
+ const dot = start + run.length - 1 - line.start;
84
+ return [...line.text.matchAll(ELEMENT_SEPARATOR)].filter((match) => match.index !== dot).length >= MIN_OTHER_SEPARATORS;
85
+ };
86
+
63
87
  const isSlip = (text: string, found: DoubledMarks, names: readonly Span[]): boolean => {
64
88
  const { start, run } = found;
65
89
  return (
@@ -67,7 +91,8 @@ const isSlip = (text: string, found: DoubledMarks, names: readonly Span[]): bool
67
91
  !isDrawnOut(run) &&
68
92
  !isDrawnOutThenClosed(run) &&
69
93
  !AFTER_ABBREVIATION.test(run) &&
70
- !isJoinedDots(text, start, run)
94
+ !isJoinedDots(text, start, run) &&
95
+ !isCitationSeparator(text, found)
71
96
  );
72
97
  };
73
98
 
@@ -2,12 +2,14 @@
2
2
  // Pure. The words (お世話になっております, Dear, Best regards, 件名, attached) come from the language's email-greeting,
3
3
  // email-closing, email-salutation-end, email-sentence-end, memo-header-label, notice-header, newsletter-issue, email-subject-field, attachment-mention, attachment-not-mention and attachment-line lexicons. The
4
4
  // header and the signature are masked in doc.prose; a quoted reply is someone else's words and is left out.
5
+ import { withoutReferenceSuffix } from "./email-subject-reference.ts";
5
6
  import { escapeRegExp } from "../orthography.ts";
6
7
  import { quoteAt } from "./structure-tree.ts";
7
8
  import { closingIn, isSalutation, lineHas } from "./email-frame-words.ts";
8
9
  import { isNoticeHead, noticeWordsOf } from "../notice-header.ts";
9
10
  import { isHeadingLine, isIssueHead, issueWordsOf } from "../newsletter-issue.ts";
10
11
  import type { Detector, Finding, ProseDocument, Span } from "../plugin.ts";
12
+ import { endsWithQuotedTitle } from "./quoted-title-line.ts";
11
13
 
12
14
  /** A greeting comes before the body: past the subject, the addressee (株式会社… / 総務部 山田様) and the writer's name. */
13
15
  const GREETING_LINES = 5;
@@ -293,8 +295,8 @@ const isHeaderField = (line: string, headerFields: readonly string[]): boolean =
293
295
  */
294
296
  export const valueBelow = (lines: readonly SourceLine[], index: number, vocabulary: SubjectVocabulary): string => {
295
297
  const text = nextText(lines, index);
296
- const isBody =
297
- text.startsWith(">") || isHeaderField(text, vocabulary.headerFields) || lineHas(text, vocabulary.greetings) || endsSentence(text, vocabulary.sentenceEnds);
298
+ const ends = endsSentence(text, vocabulary.sentenceEnds) && !endsWithQuotedTitle(text);
299
+ const isBody = text.startsWith(">") || isHeaderField(text, vocabulary.headerFields) || lineHas(text, vocabulary.greetings) || ends;
298
300
  return isBody ? "" : text;
299
301
  };
300
302
 
@@ -333,7 +335,7 @@ export const emailSubject: Detector = (doc, options): Finding[] =>
333
335
  },
334
336
  doc.replyQuotes ?? [],
335
337
  ).flatMap((line): Finding[] => {
336
- const length = [...line.subject].length;
338
+ const length = [...withoutReferenceSuffix(line.subject)].length;
337
339
  if (length > 0 && length <= options.limit) return [];
338
340
  return [
339
341
  {
@@ -0,0 +1,36 @@
1
+ // The part of a subject line that is a reference number, not words to read.
2
+
3
+ /** A closing bracket's pair, for a reference in brackets at the subject's end. */
4
+ const OPENING_OF: Readonly<Record<string, string>> = { ")": "(", ")": "(", "]": "[", "]": "[", "】": "【" };
5
+ const CODE_CHARACTER = /[\w#-]/u;
6
+ const DIGIT = /\d/u;
7
+ const LATIN_OR_HASH = /[A-Za-z#]/u;
8
+ /** A run of digits this long is a number to look up even with no letter (請求番号 2026103101). */
9
+ const MIN_DIGIT_RUN = 5;
10
+
11
+ /** The runs of code characters (A-20481, #58213) in a text. */
12
+ const codesIn = (text: string): string[] =>
13
+ [...text].reduce<string[]>(
14
+ (codes, char) => {
15
+ if (!CODE_CHARACTER.test(char)) return codes.at(-1) === "" ? codes : [...codes, ""];
16
+ return [...codes.slice(0, -1), `${codes.at(-1) ?? ""}${char}`];
17
+ },
18
+ [""],
19
+ );
20
+
21
+ /** An order, ticket or invoice number: a code with a digit and a Latin letter or "#", or a long run of digits. */
22
+ const isReferenceCode = (code: string): boolean =>
23
+ DIGIT.test(code) && (LATIN_OR_HASH.test(code) || (code.length >= MIN_DIGIT_RUN && [...code].every((char) => DIGIT.test(char))));
24
+
25
+ /**
26
+ * "…について(ご注文番号:A-20481)" counts as "…について": a reference number in brackets at the end is what the reader
27
+ * searches the inbox for, not words to read, so its length does not make a subject long.
28
+ */
29
+ export const withoutReferenceSuffix = (subject: string): string => {
30
+ const trimmed = subject.trimEnd();
31
+ const opening = OPENING_OF[trimmed.at(-1) ?? ""];
32
+ if (opening === undefined) return subject;
33
+ const start = trimmed.lastIndexOf(opening);
34
+ if (start <= 0) return subject;
35
+ return codesIn(trimmed.slice(start + 1, -1)).some(isReferenceCode) ? trimmed.slice(0, start).trimEnd() : subject;
36
+ };
@@ -22,11 +22,11 @@ const LETTER = /\p{L}/u;
22
22
 
23
23
  /**
24
24
  * 文の途中の頭だけ大文字の -ly の語は、解析器が語尾で副詞と当てた名前(July、Kelly)か、題の語(Frequently Asked Questions)。
25
- * どちらも動詞に畳める副詞ではない。
25
+ * どちらも動詞に畳める副詞ではない。書き手の確かさを言う副詞(probably、apparently)も、畳む先の動詞が無い。
26
26
  */
27
- const lyAdverbsOf = (tokens: readonly Token[]): Token[] => {
27
+ const lyAdverbsOf = (tokens: readonly Token[], stance: ReadonlySet<string>): Token[] => {
28
28
  const first = tokens.findIndex((token) => LETTER.test(token.surface));
29
- return tokens.filter((token, at) => isLyAdverb(token) && !(at > first && CAPITALISED.test(token.surface)));
29
+ return tokens.filter((token, at) => isLyAdverb(token) && !stance.has(token.surface.toLowerCase()) && !(at > first && CAPITALISED.test(token.surface)));
30
30
  };
31
31
 
32
32
  /**
@@ -35,7 +35,8 @@ const lyAdverbsOf = (tokens: readonly Token[]): Token[] => {
35
35
  */
36
36
  export const adverbDensity: Detector = (doc, options): Finding[] => {
37
37
  const words = wordsIn(doc);
38
- const hits = doc.sentences.flatMap((sentence) => lyAdverbsOf(sentence.tokens ?? []).map((token) => ({ sentence, token })));
38
+ const stance = new Set((doc.lexicons["stance-adverb"] ?? []).map((entry) => entry.pattern));
39
+ const hits = doc.sentences.flatMap((sentence) => lyAdverbsOf(sentence.tokens ?? [], stance).map((token) => ({ sentence, token })));
39
40
  const density = words === 0 ? 0 : Math.round((hits.length / words) * PER);
40
41
  const first = hits[0];
41
42
  if (words < MIN_WORDS || first === undefined || density <= options.limit) return [];
@@ -16,7 +16,7 @@ import { retentionConflicts, type LengthMark, type RetentionLength, type Retenti
16
16
  import type { DurationUnit } from "../derived/date-arithmetic.ts";
17
17
  import { DURATION_LEXICONS, quantitiesOf, type Quantity } from "./derived-numbers.ts";
18
18
  import { quoteAt } from "./structure-tree.ts";
19
- import { measuredOf, valuesWith } from "./measured-facts.ts";
19
+ import { measuredOf, valuesOutsideCode } from "./measured-facts.ts";
20
20
  import { durationValues, type DurationWord } from "../facts/duration-values.ts";
21
21
  import { overlapsAny, spanIndex } from "../compare/spans.ts";
22
22
  import { documentTermConflicts, isTermName, termHomes, type TermWord, type TermWords } from "../facts/document-terms.ts";
@@ -133,7 +133,7 @@ const readFacts = (doc: ProseDocument, tree: StructureNode): ScopedFact[] => {
133
133
  durationWordsOf(doc),
134
134
  );
135
135
  const taken = spanIndex([...ages, ...durations]);
136
- const values = perUnitsOf(doc, valuesWith(tree, doc, [...measuredOf(doc).filter((value) => !overlapsAny(taken, value)), ...ages, ...durations]));
136
+ const values = perUnitsOf(doc, valuesOutsideCode(tree, doc, [...measuredOf(doc).filter((value) => !overlapsAny(taken, value)), ...ages, ...durations]));
137
137
  const terms = termValues(doc.source, values, termValueWordsOf(doc));
138
138
  const termed = new Set(terms.map((fact) => fact.value.start));
139
139
  const labelled = labelledFacts(doc.source, values, { ...factWordsOf(doc), qualifiers: qualifierWordsOf(doc) }).filter(
@@ -42,7 +42,13 @@ export const outOfOrder = (references: readonly FigureMention[]): FigureOrderSli
42
42
  };
43
43
 
44
44
  /**
45
- * Each captioned figure first referred to only after a heading that follows its caption, and each captioned figure never
45
+ * How far before its first reference a figure may be captioned and still be where the typesetter put it: LaTeX floats a
46
+ * figure to the top of the page, or the page before, so it can land a heading ahead of the text that refers to it.
47
+ */
48
+ const FLOAT_REACH_CHARS = 4000;
49
+
50
+ /**
51
+ * Each captioned figure first referred to only after a heading that follows its caption, more than a page on, and each captioned figure never
46
52
  * referred to, when the document refers to another of its kind (so it is the kind of document that refers to its figures).
47
53
  */
48
54
  export const placementSlips = (
@@ -58,7 +64,7 @@ export const placementSlips = (
58
64
  const first = firstReference.get(caption.key);
59
65
  if (first === undefined) return referredKinds.has(caption.kind) ? [{ variant: "unreferenced", offset: caption.start, label: caption.written }] : [];
60
66
  const headingBetween = headingStarts.some((start) => caption.end < start && start < first.start);
61
- return headingBetween ? [{ variant: "late", offset: first.start, label: first.written }] : [];
67
+ return headingBetween && first.start - caption.end > FLOAT_REACH_CHARS ? [{ variant: "late", offset: first.start, label: first.written }] : [];
62
68
  });
63
69
  };
64
70
 
@@ -78,6 +78,11 @@ const continuesVersion = (text: string, start: number, run: string): boolean =>
78
78
  FULLWIDTH.test(run) === FULLWIDTH.test(text.charAt(start - 2)) &&
79
79
  VERSION_SO_FAR.test(text.slice(Math.max(0, start - 1 - VERSION_REACH), start - 1));
80
80
 
81
+ /** 電話番号(03-3581-1101、0570 - 064 - 556)。0 で始まり、ハイフンで三つの組につなぐ。三つの組を一つの幅で書いた一つの番号。 */
82
+ const PHONE_NUMBER = /(?<![0-90-9])[00][0-90-9]{1,4}(?:\s?[--‐−ー]\s?[0-90-9]{1,4}){2}(?![0-90-9])/gu;
83
+
84
+ const phoneSpans = (text: string): Span[] => [...text.matchAll(PHONE_NUMBER)].map((match) => ({ start: match.index, end: match.index + match[0].length }));
85
+
81
86
  const isListItemNumber = (source: string, offset: number): boolean => LIST_ITEM_HEAD.test(source.slice(source.lastIndexOf("\n", offset - 1) + 1, offset));
82
87
 
83
88
  export type AlnumRun = {
@@ -87,9 +92,13 @@ export type AlnumRun = {
87
92
  readonly offset: number;
88
93
  /** 表のセルを続けてしまった数字(8,457 と 95.7 の 8,45795.7)の中。幅は書き手のものだが、セルの切れ目が分からず桁の数は当てにならない。 */
89
94
  readonly glued: boolean;
95
+ /** 一つの書き物として書いたまとまりの位置。電話番号の組はその番号の頭、ほかは並び自身の位置。 */
96
+ readonly unit: number;
97
+ /** 英字一字と数字を違う幅で書いた並び(Q5)を分けた片方。 */
98
+ readonly split: boolean;
90
99
  };
91
100
 
92
- type Piece = { readonly 0: string; readonly index: number };
101
+ type Piece = { readonly 0: string; readonly index: number; readonly split?: boolean };
93
102
 
94
103
  /** 一つの幅で書いた部分。 */
95
104
  const SAME_WIDTH = /[A-Za-z0-9]+|[A-Za-z0-9]+/gu;
@@ -106,7 +115,7 @@ const isLetterAndNumber = (parts: readonly Piece[]): boolean =>
106
115
  */
107
116
  const widthPieces = (match: RegExpExecArray): Piece[] => {
108
117
  if (FULLWIDTH.test(match[0]) || HALFWIDTH.test(match[0])) return [match];
109
- const parts = [...match[0].matchAll(SAME_WIDTH)].map((part) => ({ 0: part[0], index: match.index + part.index }));
118
+ const parts = [...match[0].matchAll(SAME_WIDTH)].map((part) => ({ 0: part[0], index: match.index + part.index, split: true }));
110
119
  return isLetterAndNumber(parts) ? parts : [];
111
120
  };
112
121
 
@@ -117,6 +126,7 @@ const widthPieces = (match: RegExpExecArray): Piece[] => {
117
126
  export const alnumRunsIn = (sentence: Sentence, source: string): AlnumRun[] => {
118
127
  const quoted: readonly Span[] = quotedSpans(sentence.text, QUOTATION_MARKS);
119
128
  const glued = gluedNumberSpans(sentence.text);
129
+ const phones = phoneSpans(sentence.text);
120
130
  return [...sentence.text.matchAll(ALNUM_RUN)]
121
131
  .flatMap(widthPieces)
122
132
  .filter((match) => !isWithinAny(quoted, { start: match.index, end: match.index + match[0].length }))
@@ -132,6 +142,8 @@ export const alnumRunsIn = (sentence: Sentence, source: string): AlnumRun[] => {
132
142
  written: match[0],
133
143
  offset: sentence.span.start + match.index,
134
144
  glued: isWithinAny(glued, { start: match.index, end: match.index + match[0].length }),
145
+ unit: sentence.span.start + (phones.find((phone) => phone.start <= match.index && match.index < phone.end)?.start ?? match.index),
146
+ split: "split" in match && match.split === true,
135
147
  }));
136
148
  };
137
149
 
@@ -163,20 +175,34 @@ const datelineOf = (doc: ProseDocument): Span | undefined => {
163
175
  return first !== undefined && DATELINE.test(doc.source.slice(first.span.start, first.span.end).trim()) ? first.span : undefined;
164
176
  };
165
177
 
178
+ /**
179
+ * 見出しの文字(### Q5:…の Q5:…)を、文と同じに読む一続き。文書の頭の題(# ノロウイルスに関するQ&A)は載せたページの名前なので読まない。
180
+ * 見出しから数えるのは、英字一字と数字を違う幅で書いた並び(Q5)だけ。見出しはほかの数を本文と別の幅で書くことが多いが(## 1 概要)、
181
+ * 一つの並びの中で幅が変わるのは書き損じ。
182
+ */
183
+ const headingSentences = (doc: ProseDocument): Sentence[] =>
184
+ (doc.markup?.headings ?? []).flatMap((heading, index) => {
185
+ if (index === 0 && heading.depth === 1) return [];
186
+ const start = doc.source.indexOf(heading.text, heading.start);
187
+ return start < 0 || start >= heading.end || heading.text === "" ? [] : [{ span: { start, end: start + heading.text.length }, text: heading.text }];
188
+ });
189
+
166
190
  /** 多いほうの英字の語が何種類あれば、文書の書き方と見るか。BAR を二度書いただけなら、それはその語の書き方。 */
167
191
  const HABIT_WORDS = 2;
168
192
 
169
193
  const wordOf = (run: AlnumRun): string => run.written.normalize("NFKC").toUpperCase();
170
194
 
171
195
  /**
172
- * 英字の語の少ないほうを、文書の書き方からはずれたと言えるか。多いほうが二種類以上の語か、少ないほうと同じ語(URL と URL)のとき。
173
- * 全角の BAR だけの文書の DELICATE は、別の語を別の書き方で書いただけ。
196
+ * 少ないほうを、文書の書き方からはずれたと言えるか。英字の語は、多いほうが二種類以上の語か、少ないほうと同じ語(URL と URL)のとき。
197
+ * 全角の BAR だけの文書の DELICATE は、別の語を別の書き方で書いただけ。ほかの組は、多いほうが二つ以上のまとまりにわたるとき。
198
+ * 多いほうが電話番号一つの組(0570 - 064 - 556)だけなら、それはその番号の書き方で、文書の書き方ではない。
174
199
  */
175
200
  const departsFromHabit =
176
201
  (ofKind: readonly Located[], odd: readonly Located[]) =>
177
202
  ({ run }: Located): boolean => {
178
- if (run.kind !== "letters") return true;
179
- const usual = new Set(ofKind.filter((entry) => !odd.includes(entry)).map((entry) => wordOf(entry.run)));
203
+ const usualRuns = ofKind.filter((entry) => !odd.includes(entry)).map((entry) => entry.run);
204
+ if (run.kind !== "letters") return new Set(usualRuns.map((usual) => usual.unit)).size >= HABIT_WORDS;
205
+ const usual = new Set(usualRuns.map(wordOf));
180
206
  return usual.size >= HABIT_WORDS || usual.has(wordOf(run));
181
207
  };
182
208
 
@@ -198,10 +224,13 @@ const findingOf = ({ sentence, run }: Located, count: number, of: number, limit:
198
224
  */
199
225
  export const fullwidthAlnum: Detector = (doc, options): Finding[] => {
200
226
  const dateline = datelineOf(doc);
201
- const located: Located[] = doc.sentences
202
- .filter((sentence) => sentence.embeddedLanguage === undefined && !isCitation(sentence, doc.source))
203
- .filter((sentence) => dateline === undefined || !isWithinAny([dateline], sentence.span))
204
- .flatMap((sentence) => alnumRunsIn(sentence, doc.source).map((run) => ({ sentence, run })));
227
+ const located: Located[] = [
228
+ ...doc.sentences
229
+ .filter((sentence) => sentence.embeddedLanguage === undefined && !isCitation(sentence, doc.source))
230
+ .filter((sentence) => dateline === undefined || !isWithinAny([dateline], sentence.span))
231
+ .flatMap((sentence) => alnumRunsIn(sentence, doc.source).map((run) => ({ sentence, run }))),
232
+ ...headingSentences(doc).flatMap((sentence) => alnumRunsIn(sentence, doc.source).flatMap((run) => (run.split ? [{ sentence, run }] : []))),
233
+ ];
205
234
  return KINDS.flatMap((kind) => {
206
235
  const ofKind = located.filter(({ run }) => run.kind === kind);
207
236
  const odd = minorityWithin(ofKind, ({ run }) => run.fullwidth, options.limit);
@@ -24,4 +24,18 @@ const longestNamedRun = (units: readonly string[], title: string, unit: LengthUn
24
24
  * 題と見出しにある句は文書の主題で、名前と同じく、それに付いた語句も数えない。title は見出しを並べた文字列。
25
25
  */
26
26
  export const namedByHeading = (key: string, title: string, unit: LengthUnit): boolean =>
27
- title.includes(key) || longestNamedRun(unitsOf(key, unit), title, unit) * 2 > [...key].length;
27
+ title.includes(key) || longestNamedRun(unitsOf(key, unit), title, unit) * 2 > [...key].length || (unit === "char" && namesCompound(key, title));
28
+
29
+ const KANA = /[ぁ-ゖ]/gu;
30
+ /** A compound of two words at least (旧氏併記): one word of a heading (記載) is not the heading's subject. */
31
+ const MIN_COMPOUND_CHARS = 4;
32
+
33
+ /**
34
+ * Whether a heading writes the key's content words as one compound (旧氏併記 for 旧氏を併記した氏): the body spells the heading's
35
+ * subject out with its particles. Measured on the key without kana, the run must be a compound and more than half of it.
36
+ */
37
+ const namesCompound = (key: string, title: string): boolean => {
38
+ const content = [...key.replace(KANA, "")];
39
+ const run = longestNamedRun(content, title, "char");
40
+ return run >= MIN_COMPOUND_CHARS && run * 2 > content.length;
41
+ };