chaffjs 0.33.0 → 0.35.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 (802) hide show
  1. package/dist/api.d.ts +7 -1
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js.map +1 -1
  4. package/dist/capitals-passage.d.ts +3 -0
  5. package/dist/capitals-passage.d.ts.map +1 -0
  6. package/dist/capitals-passage.js +26 -0
  7. package/dist/capitals-passage.js.map +1 -0
  8. package/dist/cli-text.d.ts.map +1 -1
  9. package/dist/cli-text.js +4 -2
  10. package/dist/cli-text.js.map +1 -1
  11. package/dist/coined-hyphen-name.d.ts +13 -0
  12. package/dist/coined-hyphen-name.d.ts.map +1 -0
  13. package/dist/coined-hyphen-name.js +21 -0
  14. package/dist/coined-hyphen-name.js.map +1 -0
  15. package/dist/commands/grade.d.ts.map +1 -1
  16. package/dist/commands/grade.js +66 -21
  17. package/dist/commands/grade.js.map +1 -1
  18. package/dist/company-kana-spelling.d.ts +6 -1
  19. package/dist/company-kana-spelling.d.ts.map +1 -1
  20. package/dist/company-kana-spelling.js +19 -2
  21. package/dist/company-kana-spelling.js.map +1 -1
  22. package/dist/company-name-ending.d.ts +7 -0
  23. package/dist/company-name-ending.d.ts.map +1 -0
  24. package/dist/company-name-ending.js +44 -0
  25. package/dist/company-name-ending.js.map +1 -0
  26. package/dist/company-names.d.ts +17 -4
  27. package/dist/company-names.d.ts.map +1 -1
  28. package/dist/company-names.js +49 -17
  29. package/dist/company-names.js.map +1 -1
  30. package/dist/custom/no-rewrite.d.ts +3 -0
  31. package/dist/custom/no-rewrite.d.ts.map +1 -0
  32. package/dist/custom/no-rewrite.js +3 -0
  33. package/dist/custom/no-rewrite.js.map +1 -0
  34. package/dist/custom/parse.d.ts.map +1 -1
  35. package/dist/custom/parse.js +14 -2
  36. package/dist/custom/parse.js.map +1 -1
  37. package/dist/detectors/acronym-context.d.ts +1 -1
  38. package/dist/detectors/acronym-context.d.ts.map +1 -1
  39. package/dist/detectors/acronym-context.js +4 -4
  40. package/dist/detectors/acronym-context.js.map +1 -1
  41. package/dist/detectors/acronym-definition.d.ts +13 -0
  42. package/dist/detectors/acronym-definition.d.ts.map +1 -0
  43. package/dist/detectors/acronym-definition.js +90 -0
  44. package/dist/detectors/acronym-definition.js.map +1 -0
  45. package/dist/detectors/acronym-lone.d.ts +13 -0
  46. package/dist/detectors/acronym-lone.d.ts.map +1 -0
  47. package/dist/detectors/acronym-lone.js +22 -0
  48. package/dist/detectors/acronym-lone.js.map +1 -0
  49. package/dist/detectors/acronym-name.d.ts +55 -0
  50. package/dist/detectors/acronym-name.d.ts.map +1 -0
  51. package/dist/detectors/acronym-name.js +75 -0
  52. package/dist/detectors/acronym-name.js.map +1 -0
  53. package/dist/detectors/age-words.d.ts +5 -0
  54. package/dist/detectors/age-words.d.ts.map +1 -0
  55. package/dist/detectors/age-words.js +8 -0
  56. package/dist/detectors/age-words.js.map +1 -0
  57. package/dist/detectors/annual-pay-mismatch.d.ts.map +1 -1
  58. package/dist/detectors/annual-pay-mismatch.js +2 -12
  59. package/dist/detectors/annual-pay-mismatch.js.map +1 -1
  60. package/dist/detectors/blank-structure.d.ts.map +1 -1
  61. package/dist/detectors/blank-structure.js +4 -3
  62. package/dist/detectors/blank-structure.js.map +1 -1
  63. package/dist/detectors/capitalised-term.d.ts +14 -2
  64. package/dist/detectors/capitalised-term.d.ts.map +1 -1
  65. package/dist/detectors/capitalised-term.js +115 -4
  66. package/dist/detectors/capitalised-term.js.map +1 -1
  67. package/dist/detectors/caps-caption.d.ts +11 -0
  68. package/dist/detectors/caps-caption.d.ts.map +1 -0
  69. package/dist/detectors/caps-caption.js +51 -0
  70. package/dist/detectors/caps-caption.js.map +1 -0
  71. package/dist/detectors/char-shape.d.ts.map +1 -1
  72. package/dist/detectors/char-shape.js +47 -18
  73. package/dist/detectors/char-shape.js.map +1 -1
  74. package/dist/detectors/clause-shape.d.ts +1 -1
  75. package/dist/detectors/clause-shape.d.ts.map +1 -1
  76. package/dist/detectors/clause-shape.js +9 -4
  77. package/dist/detectors/clause-shape.js.map +1 -1
  78. package/dist/detectors/closing-balance-mismatch.d.ts.map +1 -1
  79. package/dist/detectors/closing-balance-mismatch.js +1 -0
  80. package/dist/detectors/closing-balance-mismatch.js.map +1 -1
  81. package/dist/detectors/code-fences.d.ts +5 -0
  82. package/dist/detectors/code-fences.d.ts.map +1 -1
  83. package/dist/detectors/code-fences.js +9 -0
  84. package/dist/detectors/code-fences.js.map +1 -1
  85. package/dist/detectors/concrete-evidence.d.ts +13 -1
  86. package/dist/detectors/concrete-evidence.d.ts.map +1 -1
  87. package/dist/detectors/concrete-evidence.js +59 -0
  88. package/dist/detectors/concrete-evidence.js.map +1 -1
  89. package/dist/detectors/condition-toki.d.ts +16 -0
  90. package/dist/detectors/condition-toki.d.ts.map +1 -0
  91. package/dist/detectors/condition-toki.js +42 -0
  92. package/dist/detectors/condition-toki.js.map +1 -0
  93. package/dist/detectors/conjugated-entry.d.ts +17 -0
  94. package/dist/detectors/conjugated-entry.d.ts.map +1 -0
  95. package/dist/detectors/conjugated-entry.js +50 -0
  96. package/dist/detectors/conjugated-entry.js.map +1 -0
  97. package/dist/detectors/content-morphemes.d.ts +2 -0
  98. package/dist/detectors/content-morphemes.d.ts.map +1 -1
  99. package/dist/detectors/content-morphemes.js +1 -1
  100. package/dist/detectors/content-morphemes.js.map +1 -1
  101. package/dist/detectors/contraction-minority.d.ts +11 -0
  102. package/dist/detectors/contraction-minority.d.ts.map +1 -0
  103. package/dist/detectors/contraction-minority.js +10 -0
  104. package/dist/detectors/contraction-minority.js.map +1 -0
  105. package/dist/detectors/counter-edge.d.ts +5 -0
  106. package/dist/detectors/counter-edge.d.ts.map +1 -1
  107. package/dist/detectors/counter-edge.js +23 -0
  108. package/dist/detectors/counter-edge.js.map +1 -1
  109. package/dist/detectors/cross-facts.d.ts.map +1 -1
  110. package/dist/detectors/cross-facts.js +2 -1
  111. package/dist/detectors/cross-facts.js.map +1 -1
  112. package/dist/detectors/custom.d.ts.map +1 -1
  113. package/dist/detectors/custom.js +8 -2
  114. package/dist/detectors/custom.js.map +1 -1
  115. package/dist/detectors/date-any-year.d.ts +6 -3
  116. package/dist/detectors/date-any-year.d.ts.map +1 -1
  117. package/dist/detectors/date-any-year.js +47 -10
  118. package/dist/detectors/date-any-year.js.map +1 -1
  119. package/dist/detectors/date-heading-year.d.ts +18 -0
  120. package/dist/detectors/date-heading-year.d.ts.map +1 -0
  121. package/dist/detectors/date-heading-year.js +38 -0
  122. package/dist/detectors/date-heading-year.js.map +1 -0
  123. package/dist/detectors/date-year.d.ts +12 -2
  124. package/dist/detectors/date-year.d.ts.map +1 -1
  125. package/dist/detectors/date-year.js +31 -6
  126. package/dist/detectors/date-year.js.map +1 -1
  127. package/dist/detectors/defined-term-form.d.ts.map +1 -1
  128. package/dist/detectors/defined-term-form.js +26 -5
  129. package/dist/detectors/defined-term-form.js.map +1 -1
  130. package/dist/detectors/document-shape.d.ts.map +1 -1
  131. package/dist/detectors/document-shape.js +6 -0
  132. package/dist/detectors/document-shape.js.map +1 -1
  133. package/dist/detectors/due-date.d.ts.map +1 -1
  134. package/dist/detectors/due-date.js +18 -2
  135. package/dist/detectors/due-date.js.map +1 -1
  136. package/dist/detectors/en-shape.d.ts.map +1 -1
  137. package/dist/detectors/en-shape.js +5 -1
  138. package/dist/detectors/en-shape.js.map +1 -1
  139. package/dist/detectors/fact-consistency.d.ts.map +1 -1
  140. package/dist/detectors/fact-consistency.js +15 -15
  141. package/dist/detectors/fact-consistency.js.map +1 -1
  142. package/dist/detectors/form-line.d.ts +9 -0
  143. package/dist/detectors/form-line.d.ts.map +1 -0
  144. package/dist/detectors/form-line.js +36 -0
  145. package/dist/detectors/form-line.js.map +1 -0
  146. package/dist/detectors/formula-amount.d.ts.map +1 -1
  147. package/dist/detectors/formula-amount.js +2 -12
  148. package/dist/detectors/formula-amount.js.map +1 -1
  149. package/dist/detectors/gram-passages.d.ts +11 -0
  150. package/dist/detectors/gram-passages.d.ts.map +1 -0
  151. package/dist/detectors/gram-passages.js +26 -0
  152. package/dist/detectors/gram-passages.js.map +1 -0
  153. package/dist/detectors/heading-claim.d.ts +14 -0
  154. package/dist/detectors/heading-claim.d.ts.map +1 -0
  155. package/dist/detectors/heading-claim.js +49 -0
  156. package/dist/detectors/heading-claim.js.map +1 -0
  157. package/dist/detectors/heading-echo.d.ts.map +1 -1
  158. package/dist/detectors/heading-echo.js +29 -1
  159. package/dist/detectors/heading-echo.js.map +1 -1
  160. package/dist/detectors/heading-end-mark.d.ts +8 -3
  161. package/dist/detectors/heading-end-mark.d.ts.map +1 -1
  162. package/dist/detectors/heading-end-mark.js +18 -8
  163. package/dist/detectors/heading-end-mark.js.map +1 -1
  164. package/dist/detectors/heading-names.d.ts +7 -0
  165. package/dist/detectors/heading-names.d.ts.map +1 -0
  166. package/dist/detectors/heading-names.js +24 -0
  167. package/dist/detectors/heading-names.js.map +1 -0
  168. package/dist/detectors/heading-numbering.d.ts.map +1 -1
  169. package/dist/detectors/heading-numbering.js +7 -2
  170. package/dist/detectors/heading-numbering.js.map +1 -1
  171. package/dist/detectors/inch-mark.d.ts +10 -0
  172. package/dist/detectors/inch-mark.d.ts.map +1 -0
  173. package/dist/detectors/inch-mark.js +48 -0
  174. package/dist/detectors/inch-mark.js.map +1 -0
  175. package/dist/detectors/installment-total-mismatch.d.ts.map +1 -1
  176. package/dist/detectors/installment-total-mismatch.js +2 -12
  177. package/dist/detectors/installment-total-mismatch.js.map +1 -1
  178. package/dist/detectors/lexicon.d.ts +0 -1
  179. package/dist/detectors/lexicon.d.ts.map +1 -1
  180. package/dist/detectors/lexicon.js +29 -23
  181. package/dist/detectors/lexicon.js.map +1 -1
  182. package/dist/detectors/list-parallel.d.ts +5 -2
  183. package/dist/detectors/list-parallel.d.ts.map +1 -1
  184. package/dist/detectors/list-parallel.js +45 -7
  185. package/dist/detectors/list-parallel.js.map +1 -1
  186. package/dist/detectors/mark-shape.d.ts +6 -3
  187. package/dist/detectors/mark-shape.d.ts.map +1 -1
  188. package/dist/detectors/mark-shape.js +12 -6
  189. package/dist/detectors/mark-shape.js.map +1 -1
  190. package/dist/detectors/name-variant-apart.d.ts +27 -0
  191. package/dist/detectors/name-variant-apart.d.ts.map +1 -0
  192. package/dist/detectors/name-variant-apart.js +51 -0
  193. package/dist/detectors/name-variant-apart.js.map +1 -0
  194. package/dist/detectors/name-variant.d.ts.map +1 -1
  195. package/dist/detectors/name-variant.js +51 -17
  196. package/dist/detectors/name-variant.js.map +1 -1
  197. package/dist/detectors/number-unit.d.ts +10 -0
  198. package/dist/detectors/number-unit.d.ts.map +1 -1
  199. package/dist/detectors/number-unit.js +28 -8
  200. package/dist/detectors/number-unit.js.map +1 -1
  201. package/dist/detectors/numeral-word.d.ts +15 -0
  202. package/dist/detectors/numeral-word.d.ts.map +1 -0
  203. package/dist/detectors/numeral-word.js +26 -0
  204. package/dist/detectors/numeral-word.js.map +1 -0
  205. package/dist/detectors/organisation-run.d.ts +14 -0
  206. package/dist/detectors/organisation-run.d.ts.map +1 -0
  207. package/dist/detectors/organisation-run.js +73 -0
  208. package/dist/detectors/organisation-run.js.map +1 -0
  209. package/dist/detectors/orthographic-variant.d.ts.map +1 -1
  210. package/dist/detectors/orthographic-variant.js +13 -5
  211. package/dist/detectors/orthographic-variant.js.map +1 -1
  212. package/dist/detectors/orthography.d.ts.map +1 -1
  213. package/dist/detectors/orthography.js +16 -7
  214. package/dist/detectors/orthography.js.map +1 -1
  215. package/dist/detectors/outline-label.d.ts +14 -0
  216. package/dist/detectors/outline-label.d.ts.map +1 -0
  217. package/dist/detectors/outline-label.js +32 -0
  218. package/dist/detectors/outline-label.js.map +1 -0
  219. package/dist/detectors/page-marker.d.ts +6 -0
  220. package/dist/detectors/page-marker.d.ts.map +1 -0
  221. package/dist/detectors/page-marker.js +19 -0
  222. package/dist/detectors/page-marker.js.map +1 -0
  223. package/dist/detectors/parallel-definition.d.ts +16 -0
  224. package/dist/detectors/parallel-definition.d.ts.map +1 -0
  225. package/dist/detectors/parallel-definition.js +51 -0
  226. package/dist/detectors/parallel-definition.js.map +1 -0
  227. package/dist/detectors/per-unit-words.d.ts +7 -0
  228. package/dist/detectors/per-unit-words.d.ts.map +1 -0
  229. package/dist/detectors/per-unit-words.js +17 -0
  230. package/dist/detectors/per-unit-words.js.map +1 -0
  231. package/dist/detectors/period-multiple-mismatch.d.ts.map +1 -1
  232. package/dist/detectors/period-multiple-mismatch.js +2 -12
  233. package/dist/detectors/period-multiple-mismatch.js.map +1 -1
  234. package/dist/detectors/reference-number-variant.d.ts.map +1 -1
  235. package/dist/detectors/reference-number-variant.js +21 -3
  236. package/dist/detectors/reference-number-variant.js.map +1 -1
  237. package/dist/detectors/reference-text.d.ts.map +1 -1
  238. package/dist/detectors/reference-text.js +1 -0
  239. package/dist/detectors/reference-text.js.map +1 -1
  240. package/dist/detectors/registry/condition-toki.d.ts +3 -0
  241. package/dist/detectors/registry/condition-toki.d.ts.map +1 -0
  242. package/dist/detectors/registry/condition-toki.js +3 -0
  243. package/dist/detectors/registry/condition-toki.js.map +1 -0
  244. package/dist/detectors/registry/unfilled-placeholder.d.ts.map +1 -1
  245. package/dist/detectors/registry/unfilled-placeholder.js +2 -2
  246. package/dist/detectors/registry/unfilled-placeholder.js.map +1 -1
  247. package/dist/detectors/registry/vague-density.js +1 -1
  248. package/dist/detectors/registry/vague-density.js.map +1 -1
  249. package/dist/detectors/rent-multiple-mismatch.d.ts.map +1 -1
  250. package/dist/detectors/rent-multiple-mismatch.js +2 -12
  251. package/dist/detectors/rent-multiple-mismatch.js.map +1 -1
  252. package/dist/detectors/request-owner.d.ts +6 -2
  253. package/dist/detectors/request-owner.d.ts.map +1 -1
  254. package/dist/detectors/request-owner.js +57 -7
  255. package/dist/detectors/request-owner.js.map +1 -1
  256. package/dist/detectors/requirement-smell.d.ts.map +1 -1
  257. package/dist/detectors/requirement-smell.js +10 -2
  258. package/dist/detectors/requirement-smell.js.map +1 -1
  259. package/dist/detectors/row-sentence-amounts.d.ts.map +1 -1
  260. package/dist/detectors/row-sentence-amounts.js +5 -10
  261. package/dist/detectors/row-sentence-amounts.js.map +1 -1
  262. package/dist/detectors/sentence-length.d.ts.map +1 -1
  263. package/dist/detectors/sentence-length.js +24 -16
  264. package/dist/detectors/sentence-length.js.map +1 -1
  265. package/dist/detectors/sentence-rhythm.d.ts.map +1 -1
  266. package/dist/detectors/sentence-rhythm.js +6 -3
  267. package/dist/detectors/sentence-rhythm.js.map +1 -1
  268. package/dist/detectors/series-label.d.ts +2 -1
  269. package/dist/detectors/series-label.d.ts.map +1 -1
  270. package/dist/detectors/series-label.js +10 -4
  271. package/dist/detectors/series-label.js.map +1 -1
  272. package/dist/detectors/signals.d.ts +4 -0
  273. package/dist/detectors/signals.d.ts.map +1 -1
  274. package/dist/detectors/signals.js +95 -36
  275. package/dist/detectors/signals.js.map +1 -1
  276. package/dist/detectors/stated-amounts.d.ts +4 -0
  277. package/dist/detectors/stated-amounts.d.ts.map +1 -0
  278. package/dist/detectors/stated-amounts.js +12 -0
  279. package/dist/detectors/stated-amounts.js.map +1 -0
  280. package/dist/detectors/step-time-sum.d.ts.map +1 -1
  281. package/dist/detectors/step-time-sum.js +2 -1
  282. package/dist/detectors/step-time-sum.js.map +1 -1
  283. package/dist/detectors/structure-tree.d.ts.map +1 -1
  284. package/dist/detectors/structure-tree.js +11 -7
  285. package/dist/detectors/structure-tree.js.map +1 -1
  286. package/dist/detectors/team.d.ts.map +1 -1
  287. package/dist/detectors/team.js +10 -6
  288. package/dist/detectors/team.js.map +1 -1
  289. package/dist/detectors/template-sections.d.ts +14 -0
  290. package/dist/detectors/template-sections.d.ts.map +1 -0
  291. package/dist/detectors/template-sections.js +25 -0
  292. package/dist/detectors/template-sections.js.map +1 -0
  293. package/dist/detectors/time-order.d.ts.map +1 -1
  294. package/dist/detectors/time-order.js +17 -13
  295. package/dist/detectors/time-order.js.map +1 -1
  296. package/dist/detectors/titled-run.d.ts +22 -0
  297. package/dist/detectors/titled-run.d.ts.map +1 -0
  298. package/dist/detectors/titled-run.js +34 -0
  299. package/dist/detectors/titled-run.js.map +1 -0
  300. package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
  301. package/dist/detectors/unbalanced-bracket.js +4 -0
  302. package/dist/detectors/unbalanced-bracket.js.map +1 -1
  303. package/dist/detectors/undefined-term.d.ts.map +1 -1
  304. package/dist/detectors/undefined-term.js +8 -0
  305. package/dist/detectors/undefined-term.js.map +1 -1
  306. package/dist/detectors/unfilled-placeholder.d.ts +4 -0
  307. package/dist/detectors/unfilled-placeholder.d.ts.map +1 -0
  308. package/dist/detectors/unfilled-placeholder.js +9 -0
  309. package/dist/detectors/unfilled-placeholder.js.map +1 -0
  310. package/dist/detectors/unknown-word.d.ts +4 -1
  311. package/dist/detectors/unknown-word.d.ts.map +1 -1
  312. package/dist/detectors/unknown-word.js +18 -2
  313. package/dist/detectors/unknown-word.js.map +1 -1
  314. package/dist/detectors/use-interval.d.ts +1 -0
  315. package/dist/detectors/use-interval.d.ts.map +1 -1
  316. package/dist/detectors/use-interval.js +15 -10
  317. package/dist/detectors/use-interval.js.map +1 -1
  318. package/dist/detectors/use-maximum.d.ts.map +1 -1
  319. package/dist/detectors/use-maximum.js +3 -1
  320. package/dist/detectors/use-maximum.js.map +1 -1
  321. package/dist/detectors/vague-density.d.ts +5 -0
  322. package/dist/detectors/vague-density.d.ts.map +1 -0
  323. package/dist/detectors/vague-density.js +52 -0
  324. package/dist/detectors/vague-density.js.map +1 -0
  325. package/dist/extension/document-view.d.ts +2 -2
  326. package/dist/extension/document-view.d.ts.map +1 -1
  327. package/dist/extension/document-view.js +17 -8
  328. package/dist/extension/document-view.js.map +1 -1
  329. package/dist/extension/entry-genres.d.ts +5 -0
  330. package/dist/extension/entry-genres.d.ts.map +1 -0
  331. package/dist/extension/entry-genres.js +13 -0
  332. package/dist/extension/entry-genres.js.map +1 -0
  333. package/dist/extension/module-detector.d.ts.map +1 -1
  334. package/dist/extension/module-detector.js +4 -4
  335. package/dist/extension/module-detector.js.map +1 -1
  336. package/dist/extension/plugin-parse.d.ts +1 -1
  337. package/dist/extension/plugin-parse.d.ts.map +1 -1
  338. package/dist/extension/plugin-parse.js +24 -7
  339. package/dist/extension/plugin-parse.js.map +1 -1
  340. package/dist/extension/problem-text.d.ts.map +1 -1
  341. package/dist/extension/problem-text.js +2 -0
  342. package/dist/extension/problem-text.js.map +1 -1
  343. package/dist/facts/age-values.d.ts.map +1 -1
  344. package/dist/facts/age-values.js +20 -2
  345. package/dist/facts/age-values.js.map +1 -1
  346. package/dist/facts/column-units.d.ts +31 -0
  347. package/dist/facts/column-units.d.ts.map +1 -0
  348. package/dist/facts/column-units.js +37 -0
  349. package/dist/facts/column-units.js.map +1 -0
  350. package/dist/facts/fact-scope.d.ts +10 -1
  351. package/dist/facts/fact-scope.d.ts.map +1 -1
  352. package/dist/facts/fact-scope.js +34 -3
  353. package/dist/facts/fact-scope.js.map +1 -1
  354. package/dist/facts/fact-values.d.ts +4 -0
  355. package/dist/facts/fact-values.d.ts.map +1 -1
  356. package/dist/facts/fact-values.js +3 -1
  357. package/dist/facts/fact-values.js.map +1 -1
  358. package/dist/facts/labelled-facts.d.ts +10 -0
  359. package/dist/facts/labelled-facts.d.ts.map +1 -1
  360. package/dist/facts/labelled-facts.js +6 -1
  361. package/dist/facts/labelled-facts.js.map +1 -1
  362. package/dist/facts/per-unit.d.ts +36 -0
  363. package/dist/facts/per-unit.d.ts.map +1 -0
  364. package/dist/facts/per-unit.js +56 -0
  365. package/dist/facts/per-unit.js.map +1 -0
  366. package/dist/facts/row-sentence-amounts.d.ts +3 -12
  367. package/dist/facts/row-sentence-amounts.d.ts.map +1 -1
  368. package/dist/facts/row-sentence-amounts.js +1 -15
  369. package/dist/facts/row-sentence-amounts.js.map +1 -1
  370. package/dist/facts/table-facts.d.ts +13 -3
  371. package/dist/facts/table-facts.d.ts.map +1 -1
  372. package/dist/facts/table-facts.js +35 -13
  373. package/dist/facts/table-facts.js.map +1 -1
  374. package/dist/facts/term-values.d.ts +13 -1
  375. package/dist/facts/term-values.d.ts.map +1 -1
  376. package/dist/facts/term-values.js +71 -12
  377. package/dist/facts/term-values.js.map +1 -1
  378. package/dist/grade/baseline.d.ts +4 -2
  379. package/dist/grade/baseline.d.ts.map +1 -1
  380. package/dist/grade/baseline.js +13 -11
  381. package/dist/grade/baseline.js.map +1 -1
  382. package/dist/grade/expect-read.d.ts +16 -0
  383. package/dist/grade/expect-read.d.ts.map +1 -0
  384. package/dist/grade/expect-read.js +52 -0
  385. package/dist/grade/expect-read.js.map +1 -0
  386. package/dist/grade/expect.d.ts +50 -0
  387. package/dist/grade/expect.d.ts.map +1 -0
  388. package/dist/grade/expect.js +53 -0
  389. package/dist/grade/expect.js.map +1 -0
  390. package/dist/grade/grade-item.d.ts +1 -1
  391. package/dist/grade/grade-item.d.ts.map +1 -1
  392. package/dist/grade/grade-item.js +13 -3
  393. package/dist/grade/grade-item.js.map +1 -1
  394. package/dist/grade/item.d.ts +9 -1
  395. package/dist/grade/item.d.ts.map +1 -1
  396. package/dist/grade/item.js +32 -7
  397. package/dist/grade/item.js.map +1 -1
  398. package/dist/grade/result.d.ts +5 -0
  399. package/dist/grade/result.d.ts.map +1 -1
  400. package/dist/grade/results-read.d.ts.map +1 -1
  401. package/dist/grade/results-read.js +4 -2
  402. package/dist/grade/results-read.js.map +1 -1
  403. package/dist/grade/rubric-file.d.ts +23 -0
  404. package/dist/grade/rubric-file.d.ts.map +1 -0
  405. package/dist/grade/rubric-file.js +35 -0
  406. package/dist/grade/rubric-file.js.map +1 -0
  407. package/dist/grade/rubric.d.ts +2 -0
  408. package/dist/grade/rubric.d.ts.map +1 -1
  409. package/dist/grade/rubric.js +75 -47
  410. package/dist/grade/rubric.js.map +1 -1
  411. package/dist/grade/setup.d.ts +2 -1
  412. package/dist/grade/setup.d.ts.map +1 -1
  413. package/dist/grade/setup.js +2 -2
  414. package/dist/grade/setup.js.map +1 -1
  415. package/dist/grade/stamp.d.ts +2 -0
  416. package/dist/grade/stamp.d.ts.map +1 -1
  417. package/dist/grade/stamp.js +8 -2
  418. package/dist/grade/stamp.js.map +1 -1
  419. package/dist/grade/task-rubric.d.ts +16 -0
  420. package/dist/grade/task-rubric.d.ts.map +1 -0
  421. package/dist/grade/task-rubric.js +34 -0
  422. package/dist/grade/task-rubric.js.map +1 -0
  423. package/dist/grade/text.d.ts +5 -1
  424. package/dist/grade/text.d.ts.map +1 -1
  425. package/dist/grade/text.js +16 -4
  426. package/dist/grade/text.js.map +1 -1
  427. package/dist/grade-api.d.ts +9 -2
  428. package/dist/grade-api.d.ts.map +1 -1
  429. package/dist/grade-api.js +31 -15
  430. package/dist/grade-api.js.map +1 -1
  431. package/dist/heading-numbering.d.ts +5 -2
  432. package/dist/heading-numbering.d.ts.map +1 -1
  433. package/dist/heading-numbering.js +27 -6
  434. package/dist/heading-numbering.js.map +1 -1
  435. package/dist/name-char-reading.d.ts +5 -0
  436. package/dist/name-char-reading.d.ts.map +1 -1
  437. package/dist/name-char-reading.js +15 -0
  438. package/dist/name-char-reading.js.map +1 -1
  439. package/dist/name-end-letter.d.ts +24 -0
  440. package/dist/name-end-letter.d.ts.map +1 -0
  441. package/dist/name-end-letter.js +45 -0
  442. package/dist/name-end-letter.js.map +1 -0
  443. package/dist/name-given-before.d.ts +15 -0
  444. package/dist/name-given-before.d.ts.map +1 -0
  445. package/dist/name-given-before.js +30 -0
  446. package/dist/name-given-before.js.map +1 -0
  447. package/dist/name-neighbours.d.ts.map +1 -1
  448. package/dist/name-neighbours.js +2 -1
  449. package/dist/name-neighbours.js.map +1 -1
  450. package/dist/name-separator.d.ts +6 -0
  451. package/dist/name-separator.d.ts.map +1 -1
  452. package/dist/name-separator.js +80 -0
  453. package/dist/name-separator.js.map +1 -1
  454. package/dist/name-variants.d.ts +8 -3
  455. package/dist/name-variants.d.ts.map +1 -1
  456. package/dist/name-variants.js +40 -12
  457. package/dist/name-variants.js.map +1 -1
  458. package/dist/name-word-order.d.ts +9 -5
  459. package/dist/name-word-order.d.ts.map +1 -1
  460. package/dist/name-word-order.js +47 -15
  461. package/dist/name-word-order.js.map +1 -1
  462. package/dist/nominal-stem.d.ts +13 -0
  463. package/dist/nominal-stem.d.ts.map +1 -0
  464. package/dist/nominal-stem.js +32 -0
  465. package/dist/nominal-stem.js.map +1 -0
  466. package/dist/number-name.d.ts.map +1 -1
  467. package/dist/number-name.js +11 -2
  468. package/dist/number-name.js.map +1 -1
  469. package/dist/profile/cue-lines.d.ts +6 -0
  470. package/dist/profile/cue-lines.d.ts.map +1 -0
  471. package/dist/profile/cue-lines.js +13 -0
  472. package/dist/profile/cue-lines.js.map +1 -0
  473. package/dist/profile/parse.d.ts +1 -1
  474. package/dist/profile/parse.d.ts.map +1 -1
  475. package/dist/profile/parse.js +3 -2
  476. package/dist/profile/parse.js.map +1 -1
  477. package/dist/reference-numbers.d.ts +2 -0
  478. package/dist/reference-numbers.d.ts.map +1 -1
  479. package/dist/reference-numbers.js +1 -1
  480. package/dist/reference-numbers.js.map +1 -1
  481. package/dist/sentence-load.d.ts +2 -1
  482. package/dist/sentence-load.d.ts.map +1 -1
  483. package/dist/sentence-load.js +6 -2
  484. package/dist/sentence-load.js.map +1 -1
  485. package/dist/spaced-person-name.d.ts.map +1 -1
  486. package/dist/spaced-person-name.js +26 -1
  487. package/dist/spaced-person-name.js.map +1 -1
  488. package/dist/spacing-code.d.ts.map +1 -1
  489. package/dist/spacing-code.js +10 -1
  490. package/dist/spacing-code.js.map +1 -1
  491. package/dist/spacing-minority.d.ts +7 -0
  492. package/dist/spacing-minority.d.ts.map +1 -1
  493. package/dist/spacing-minority.js +14 -0
  494. package/dist/spacing-minority.js.map +1 -1
  495. package/dist/structure/cited-document-section.d.ts +7 -0
  496. package/dist/structure/cited-document-section.d.ts.map +1 -0
  497. package/dist/structure/cited-document-section.js +33 -0
  498. package/dist/structure/cited-document-section.js.map +1 -0
  499. package/dist/structure/closing-balance.d.ts +9 -0
  500. package/dist/structure/closing-balance.d.ts.map +1 -1
  501. package/dist/structure/closing-balance.js +34 -7
  502. package/dist/structure/closing-balance.js.map +1 -1
  503. package/dist/structure/definition-use.d.ts.map +1 -1
  504. package/dist/structure/definition-use.js +20 -1
  505. package/dist/structure/definition-use.js.map +1 -1
  506. package/dist/structure/document-context.d.ts +2 -0
  507. package/dist/structure/document-context.d.ts.map +1 -0
  508. package/dist/structure/document-context.js +42 -0
  509. package/dist/structure/document-context.js.map +1 -0
  510. package/dist/structure/fenced-lines.d.ts +7 -0
  511. package/dist/structure/fenced-lines.d.ts.map +1 -0
  512. package/dist/structure/fenced-lines.js +27 -0
  513. package/dist/structure/fenced-lines.js.map +1 -0
  514. package/dist/structure/html-text-blocks.d.ts +8 -0
  515. package/dist/structure/html-text-blocks.d.ts.map +1 -0
  516. package/dist/structure/html-text-blocks.js +47 -0
  517. package/dist/structure/html-text-blocks.js.map +1 -0
  518. package/dist/structure/issues.d.ts +1 -1
  519. package/dist/structure/issues.d.ts.map +1 -1
  520. package/dist/structure/issues.js +19 -4
  521. package/dist/structure/issues.js.map +1 -1
  522. package/dist/structure/labelled-date-order.d.ts +34 -9
  523. package/dist/structure/labelled-date-order.d.ts.map +1 -1
  524. package/dist/structure/labelled-date-order.js +60 -15
  525. package/dist/structure/labelled-date-order.js.map +1 -1
  526. package/dist/structure/labelled-order.d.ts +10 -1
  527. package/dist/structure/labelled-order.d.ts.map +1 -1
  528. package/dist/structure/labelled-order.js +18 -6
  529. package/dist/structure/labelled-order.js.map +1 -1
  530. package/dist/structure/line-amount-label.d.ts.map +1 -1
  531. package/dist/structure/line-amount-label.js +2 -1
  532. package/dist/structure/line-amount-label.js.map +1 -1
  533. package/dist/structure/line-amount.d.ts +0 -5
  534. package/dist/structure/line-amount.d.ts.map +1 -1
  535. package/dist/structure/line-amount.js +1 -10
  536. package/dist/structure/line-amount.js.map +1 -1
  537. package/dist/structure/list-numbering.d.ts +20 -4
  538. package/dist/structure/list-numbering.d.ts.map +1 -1
  539. package/dist/structure/list-numbering.js +65 -9
  540. package/dist/structure/list-numbering.js.map +1 -1
  541. package/dist/structure/listed-paragraph.d.ts +16 -0
  542. package/dist/structure/listed-paragraph.d.ts.map +1 -0
  543. package/dist/structure/listed-paragraph.js +37 -0
  544. package/dist/structure/listed-paragraph.js.map +1 -0
  545. package/dist/structure/numbering.d.ts +3 -2
  546. package/dist/structure/numbering.d.ts.map +1 -1
  547. package/dist/structure/numbering.js +31 -6
  548. package/dist/structure/numbering.js.map +1 -1
  549. package/dist/structure/prose-total.d.ts +8 -0
  550. package/dist/structure/prose-total.d.ts.map +1 -1
  551. package/dist/structure/prose-total.js +70 -2
  552. package/dist/structure/prose-total.js.map +1 -1
  553. package/dist/structure/reference-text.d.ts +9 -1
  554. package/dist/structure/reference-text.d.ts.map +1 -1
  555. package/dist/structure/reference-text.js +21 -3
  556. package/dist/structure/reference-text.js.map +1 -1
  557. package/dist/structure/runs.d.ts.map +1 -1
  558. package/dist/structure/runs.js +9 -1
  559. package/dist/structure/runs.js.map +1 -1
  560. package/dist/structure/section-names.d.ts +12 -0
  561. package/dist/structure/section-names.d.ts.map +1 -0
  562. package/dist/structure/section-names.js +26 -0
  563. package/dist/structure/section-names.js.map +1 -0
  564. package/dist/structure/signed-date-line.d.ts +15 -0
  565. package/dist/structure/signed-date-line.d.ts.map +1 -0
  566. package/dist/structure/signed-date-line.js +68 -0
  567. package/dist/structure/signed-date-line.js.map +1 -0
  568. package/dist/structure/tax.d.ts.map +1 -1
  569. package/dist/structure/tax.js +5 -3
  570. package/dist/structure/tax.js.map +1 -1
  571. package/dist/structure/total-line.d.ts.map +1 -1
  572. package/dist/structure/total-line.js +10 -6
  573. package/dist/structure/total-line.js.map +1 -1
  574. package/dist/structure/total.d.ts +2 -0
  575. package/dist/structure/total.d.ts.map +1 -1
  576. package/dist/structure/total.js +34 -3
  577. package/dist/structure/total.js.map +1 -1
  578. package/dist/structure/versioned-label.d.ts +16 -0
  579. package/dist/structure/versioned-label.d.ts.map +1 -0
  580. package/dist/structure/versioned-label.js +48 -0
  581. package/dist/structure/versioned-label.js.map +1 -0
  582. package/dist/structure/written-headings.d.ts +31 -0
  583. package/dist/structure/written-headings.d.ts.map +1 -0
  584. package/dist/structure/written-headings.js +119 -0
  585. package/dist/structure/written-headings.js.map +1 -0
  586. package/dist/structure/written-resolve.d.ts +12 -0
  587. package/dist/structure/written-resolve.d.ts.map +1 -0
  588. package/dist/structure/written-resolve.js +49 -0
  589. package/dist/structure/written-resolve.js.map +1 -0
  590. package/dist/subject-codes.d.ts +21 -0
  591. package/dist/subject-codes.d.ts.map +1 -0
  592. package/dist/subject-codes.js +79 -0
  593. package/dist/subject-codes.js.map +1 -0
  594. package/dist/unlabelled-references.d.ts +6 -2
  595. package/dist/unlabelled-references.d.ts.map +1 -1
  596. package/dist/unlabelled-references.js +11 -10
  597. package/dist/unlabelled-references.js.map +1 -1
  598. package/genres.yaml +17 -0
  599. package/package.json +3 -3
  600. package/profiles/listing.yaml +1 -1
  601. package/rules/all-caps-shouting.yaml +2 -2
  602. package/rules/closing-balance-mismatch.yaml +3 -3
  603. package/rules/concrete-evidence-density.yaml +2 -2
  604. package/rules/contraction-consistency.yaml +13 -13
  605. package/rules/dangling-reference.yaml +2 -2
  606. package/rules/date-without-year.yaml +2 -2
  607. package/rules/defined-name-repeated.yaml +2 -2
  608. package/rules/due-before-issue.yaml +9 -5
  609. package/rules/fact-conflict.yaml +2 -2
  610. package/rules/heading-echo.yaml +2 -2
  611. package/rules/heading-end-punctuation-mix.yaml +2 -2
  612. package/rules/heading-numbering-mix.yaml +2 -2
  613. package/rules/internal-jargon.yaml +2 -2
  614. package/rules/latin-spacing.yaml +4 -4
  615. package/rules/list-item-form-mix.yaml +1 -1
  616. package/rules/max-kanji-continuous.yaml +5 -3
  617. package/rules/max-sentence-length.yaml +3 -2
  618. package/rules/name-variant.yaml +5 -2
  619. package/rules/ngram-repetition.yaml +2 -2
  620. package/rules/no-lead.yaml +2 -2
  621. package/rules/number-without-unit.yaml +2 -2
  622. package/rules/numbering-gap.yaml +2 -2
  623. package/rules/orthographic-variant.yaml +2 -2
  624. package/rules/reference-number-variant.yaml +3 -3
  625. package/rules/reference-title-mismatch.yaml +2 -2
  626. package/rules/repeated-sentence-ending.yaml +3 -2
  627. package/rules/request-without-deadline.yaml +2 -2
  628. package/rules/requirement-smell.yaml +2 -2
  629. package/rules/sentence-rhythm.yaml +2 -2
  630. package/rules/title-case-consistency.yaml +2 -2
  631. package/rules/toki-as-condition.yaml +71 -0
  632. package/rules/total-mismatch.yaml +4 -4
  633. package/rules/unbalanced-bracket.yaml +2 -2
  634. package/rules/undefined-acronym.yaml +11 -2
  635. package/rules/undefined-term.yaml +2 -2
  636. package/rules/unfilled-placeholder.yaml +2 -2
  637. package/rules/unknown-word.yaml +2 -2
  638. package/rules/use-before-definition.yaml +2 -2
  639. package/rules/vague-word-density.yaml +2 -2
  640. package/src/api.ts +11 -2
  641. package/src/capitals-passage.ts +31 -0
  642. package/src/cli-text.ts +4 -2
  643. package/src/coined-hyphen-name.ts +27 -0
  644. package/src/commands/grade.ts +75 -23
  645. package/src/company-kana-spelling.ts +22 -2
  646. package/src/company-name-ending.ts +50 -0
  647. package/src/company-names.ts +76 -20
  648. package/src/custom/no-rewrite.ts +2 -0
  649. package/src/custom/parse.ts +18 -2
  650. package/src/detectors/acronym-context.ts +5 -6
  651. package/src/detectors/acronym-definition.ts +123 -0
  652. package/src/detectors/acronym-lone.ts +26 -0
  653. package/src/detectors/acronym-name.ts +117 -0
  654. package/src/detectors/age-words.ts +12 -0
  655. package/src/detectors/annual-pay-mismatch.ts +3 -18
  656. package/src/detectors/blank-structure.ts +4 -3
  657. package/src/detectors/capitalised-term.ts +154 -4
  658. package/src/detectors/caps-caption.ts +61 -0
  659. package/src/detectors/char-shape.ts +74 -22
  660. package/src/detectors/clause-shape.ts +14 -4
  661. package/src/detectors/closing-balance-mismatch.ts +1 -0
  662. package/src/detectors/code-fences.ts +10 -0
  663. package/src/detectors/concrete-evidence.ts +77 -1
  664. package/src/detectors/condition-toki.ts +60 -0
  665. package/src/detectors/conjugated-entry.ts +53 -0
  666. package/src/detectors/content-morphemes.ts +2 -1
  667. package/src/detectors/contraction-minority.ts +11 -0
  668. package/src/detectors/counter-edge.ts +23 -0
  669. package/src/detectors/cross-facts.ts +2 -1
  670. package/src/detectors/custom.ts +9 -2
  671. package/src/detectors/date-any-year.ts +56 -10
  672. package/src/detectors/date-heading-year.ts +55 -0
  673. package/src/detectors/date-year.ts +54 -9
  674. package/src/detectors/defined-term-form.ts +26 -5
  675. package/src/detectors/document-shape.ts +8 -0
  676. package/src/detectors/due-date.ts +26 -7
  677. package/src/detectors/en-shape.ts +5 -1
  678. package/src/detectors/fact-consistency.ts +16 -19
  679. package/src/detectors/form-line.ts +47 -0
  680. package/src/detectors/formula-amount.ts +2 -18
  681. package/src/detectors/gram-passages.ts +36 -0
  682. package/src/detectors/heading-claim.ts +76 -0
  683. package/src/detectors/heading-echo.ts +32 -1
  684. package/src/detectors/heading-end-mark.ts +23 -10
  685. package/src/detectors/heading-names.ts +31 -0
  686. package/src/detectors/heading-numbering.ts +7 -2
  687. package/src/detectors/inch-mark.ts +49 -0
  688. package/src/detectors/installment-total-mismatch.ts +3 -18
  689. package/src/detectors/lexicon.ts +32 -21
  690. package/src/detectors/list-parallel.ts +46 -7
  691. package/src/detectors/mark-shape.ts +12 -6
  692. package/src/detectors/name-variant-apart.ts +63 -0
  693. package/src/detectors/name-variant.ts +73 -18
  694. package/src/detectors/number-unit.ts +35 -9
  695. package/src/detectors/numeral-word.ts +33 -0
  696. package/src/detectors/organisation-run.ts +86 -0
  697. package/src/detectors/orthographic-variant.ts +22 -6
  698. package/src/detectors/orthography.ts +17 -8
  699. package/src/detectors/outline-label.ts +48 -0
  700. package/src/detectors/page-marker.ts +26 -0
  701. package/src/detectors/parallel-definition.ts +64 -0
  702. package/src/detectors/per-unit-words.ts +24 -0
  703. package/src/detectors/period-multiple-mismatch.ts +2 -18
  704. package/src/detectors/reference-number-variant.ts +27 -5
  705. package/src/detectors/reference-text.ts +1 -0
  706. package/src/detectors/registry/condition-toki.ts +4 -0
  707. package/src/detectors/registry/unfilled-placeholder.ts +2 -2
  708. package/src/detectors/registry/vague-density.ts +1 -1
  709. package/src/detectors/rent-multiple-mismatch.ts +2 -18
  710. package/src/detectors/request-owner.ts +71 -8
  711. package/src/detectors/requirement-smell.ts +15 -2
  712. package/src/detectors/row-sentence-amounts.ts +5 -20
  713. package/src/detectors/sentence-length.ts +14 -6
  714. package/src/detectors/sentence-rhythm.ts +8 -4
  715. package/src/detectors/series-label.ts +13 -4
  716. package/src/detectors/signals.ts +94 -26
  717. package/src/detectors/stated-amounts.ts +20 -0
  718. package/src/detectors/step-time-sum.ts +2 -1
  719. package/src/detectors/structure-tree.ts +13 -8
  720. package/src/detectors/team.ts +13 -7
  721. package/src/detectors/template-sections.ts +37 -0
  722. package/src/detectors/time-order.ts +6 -3
  723. package/src/detectors/titled-run.ts +43 -0
  724. package/src/detectors/unbalanced-bracket.ts +3 -0
  725. package/src/detectors/undefined-term.ts +8 -0
  726. package/src/detectors/unfilled-placeholder.ts +10 -0
  727. package/src/detectors/unknown-word.ts +20 -2
  728. package/src/detectors/use-interval.ts +8 -4
  729. package/src/detectors/use-maximum.ts +3 -1
  730. package/src/detectors/vague-density.ts +68 -0
  731. package/src/extension/document-view.ts +18 -9
  732. package/src/extension/entry-genres.ts +15 -0
  733. package/src/extension/module-detector.ts +9 -4
  734. package/src/extension/plugin-parse.ts +29 -7
  735. package/src/extension/problem-text.ts +4 -0
  736. package/src/facts/age-values.ts +24 -2
  737. package/src/facts/column-units.ts +67 -0
  738. package/src/facts/fact-scope.ts +53 -4
  739. package/src/facts/fact-values.ts +11 -1
  740. package/src/facts/labelled-facts.ts +16 -2
  741. package/src/facts/per-unit.ts +105 -0
  742. package/src/facts/row-sentence-amounts.ts +4 -26
  743. package/src/facts/table-facts.ts +50 -10
  744. package/src/facts/term-values.ts +94 -13
  745. package/src/grade/baseline.ts +20 -12
  746. package/src/grade/expect-read.ts +65 -0
  747. package/src/grade/expect.ts +74 -0
  748. package/src/grade/grade-item.ts +14 -3
  749. package/src/grade/item.ts +48 -8
  750. package/src/grade/result.ts +5 -0
  751. package/src/grade/results-read.ts +7 -2
  752. package/src/grade/rubric-file.ts +46 -0
  753. package/src/grade/rubric.ts +77 -47
  754. package/src/grade/setup.ts +3 -3
  755. package/src/grade/stamp.ts +10 -2
  756. package/src/grade/task-rubric.ts +39 -0
  757. package/src/grade/text.ts +27 -5
  758. package/src/grade-api.ts +38 -16
  759. package/src/heading-numbering.ts +35 -8
  760. package/src/name-char-reading.ts +16 -0
  761. package/src/name-end-letter.ts +61 -0
  762. package/src/name-given-before.ts +40 -0
  763. package/src/name-neighbours.ts +2 -1
  764. package/src/name-separator.ts +93 -0
  765. package/src/name-variants.ts +69 -18
  766. package/src/name-word-order.ts +62 -17
  767. package/src/nominal-stem.ts +36 -0
  768. package/src/number-name.ts +12 -3
  769. package/src/profile/cue-lines.ts +14 -0
  770. package/src/profile/parse.ts +3 -2
  771. package/src/reference-numbers.ts +1 -1
  772. package/src/sentence-load.ts +7 -2
  773. package/src/spaced-person-name.ts +27 -2
  774. package/src/spacing-code.ts +13 -2
  775. package/src/spacing-minority.ts +17 -0
  776. package/src/structure/cited-document-section.ts +42 -0
  777. package/src/structure/closing-balance.ts +46 -8
  778. package/src/structure/definition-use.ts +24 -1
  779. package/src/structure/document-context.ts +46 -0
  780. package/src/structure/fenced-lines.ts +28 -0
  781. package/src/structure/html-text-blocks.ts +45 -0
  782. package/src/structure/issues.ts +19 -4
  783. package/src/structure/labelled-date-order.ts +108 -21
  784. package/src/structure/labelled-order.ts +33 -13
  785. package/src/structure/line-amount-label.ts +2 -1
  786. package/src/structure/line-amount.ts +1 -11
  787. package/src/structure/list-numbering.ts +100 -11
  788. package/src/structure/listed-paragraph.ts +45 -0
  789. package/src/structure/numbering.ts +48 -19
  790. package/src/structure/prose-total.ts +81 -2
  791. package/src/structure/reference-text.ts +25 -3
  792. package/src/structure/runs.ts +10 -1
  793. package/src/structure/section-names.ts +32 -0
  794. package/src/structure/signed-date-line.ts +78 -0
  795. package/src/structure/tax.ts +6 -3
  796. package/src/structure/total-line.ts +12 -6
  797. package/src/structure/total.ts +42 -3
  798. package/src/structure/versioned-label.ts +52 -0
  799. package/src/structure/written-headings.ts +137 -0
  800. package/src/structure/written-resolve.ts +57 -0
  801. package/src/subject-codes.ts +105 -0
  802. package/src/unlabelled-references.ts +24 -16
@@ -2,6 +2,8 @@ import type { Token } from "./plugin.ts";
2
2
  import { escapeRegExp } from "./orthography.ts";
3
3
  import { nameCueAt, type NameCue, type NameCues } from "./name-cue.ts";
4
4
  import { isNearSurname } from "./surname-near.ts";
5
+ import { isEndWordSlip, isWordFormOf, NO_WORD_USE, type WordUse } from "./name-end-letter.ts";
6
+ import { areOtherPeople, givenNamesBySurface, type GivenNames } from "./name-given-before.ts";
5
7
  import { foldedKeysOf, NO_SPELLING, type SpellingInput } from "./name-spelling-chars.ts";
6
8
  import { NO_CHAR_READINGS, readingOfWords } from "./name-char-reading.ts";
7
9
  import { isPersonRun } from "./name-person.ts";
@@ -15,7 +17,9 @@ import { heavierFirst, outweighs, type NameWeight } from "./name-weight.ts";
15
17
  * words は名前の語(記号を除く)。読みが同じ二つの名前が、どの語で違うかを見るため。person は人の名前と読めるもの(解析器が
16
18
  * 人名と読むか、敬称が付く)。cue は前後の語から見た名前らしさ(name-cue.ts)。ordinary は、ふつうの語でもある一語の名前で、
17
19
  * 文書がその形をどこでも名前に使わないもの(name-ordinary-word.ts)。labelled は、人を書く欄(氏名:、Contractor:)に書いた名前
18
- * (person-field.ts)。
20
+ * (person-field.ts)。givenNameReading は、空白を挟んだ姓と名の名を、名の中での字の読みで読み直した読み(name-char-reading.ts の
21
+ * givenNameReadingOf)。解析器が名を別の読みに切ったとき(建太 を タテフトシ)のもう一通りの読み。givenName は、名前のすぐ前に
22
+ * 書いた名(Jeffrey D. Walker の Jeffrey、name-given-before.ts)。
19
23
  */
20
24
  export type NameMention = {
21
25
  readonly surface: string;
@@ -26,6 +30,8 @@ export type NameMention = {
26
30
  readonly cue?: NameCue;
27
31
  readonly ordinary?: boolean;
28
32
  readonly labelled?: boolean;
33
+ readonly givenNameReading?: string | undefined;
34
+ readonly givenName?: string | undefined;
29
35
  };
30
36
 
31
37
  export type NameVariant = {
@@ -163,8 +169,12 @@ export const nameKey = (surface: string): string =>
163
169
  */
164
170
  export type NameEvidence = { readonly person: boolean; readonly named: boolean; readonly nameLike: boolean };
165
171
 
166
- /** readings は書き方の現れの読みのすべて。解析器は同じ字を所によって別に読む(佐伯 を サエキ と サイキ)。 */
167
- type Tally = NameEvidence & NameWeight & { readonly surface: string; readonly first: NameMention; readonly readings: readonly string[] };
172
+ /**
173
+ * readings は書き方の現れの読みのすべて。解析器は同じ字を所によって別に読む(佐伯 を サエキ と サイキ)。givenNameReadings は
174
+ * 現れの givenNameReading のすべて。
175
+ */
176
+ type Tally = NameEvidence &
177
+ NameWeight & { readonly surface: string; readonly first: NameMention; readonly readings: readonly string[]; readonly givenNameReadings: readonly string[] };
168
178
 
169
179
  const readingsWith = (readings: readonly string[], reading: string | undefined): readonly string[] =>
170
180
  reading === undefined || readings.includes(reading) ? readings : [...readings, reading];
@@ -184,11 +194,20 @@ const talliesOf = (mentions: readonly NameMention[]): Tally[] => {
184
194
  tallies.set(
185
195
  mention.surface,
186
196
  tally === undefined
187
- ? { surface: mention.surface, first: mention, count: 1, readings: readingsWith([], mention.reading), labelled: mention.labelled === true, ...evidence }
197
+ ? {
198
+ surface: mention.surface,
199
+ first: mention,
200
+ count: 1,
201
+ readings: readingsWith([], mention.reading),
202
+ givenNameReadings: readingsWith([], mention.givenNameReading),
203
+ labelled: mention.labelled === true,
204
+ ...evidence,
205
+ }
188
206
  : {
189
207
  ...tally,
190
208
  count: tally.count + 1,
191
209
  readings: readingsWith(tally.readings, mention.reading),
210
+ givenNameReadings: readingsWith(tally.givenNameReadings, mention.givenNameReading),
192
211
  person: tally.person || evidence.person,
193
212
  named: tally.named || evidence.named,
194
213
  nameLike: tally.nameLike || evidence.nameLike,
@@ -268,14 +287,17 @@ const isSwapOrReplace = (left: string, right: string): boolean => {
268
287
  const isInnerDrop = (longer: string, shorter: string): boolean =>
269
288
  [...longer].some((_char, index) => index > 0 && index < longer.length - 1 && longer.slice(0, index) + longer.slice(index + 1) === shorter);
270
289
 
271
- /** 二つの語が一字違いか。英字だけの、長さ 5 以上の語で。 */
272
- export const isNearWord = (left: string, right: string): boolean => {
273
- if (left === right || !LATIN_WORD.test(left) || !LATIN_WORD.test(right) || Math.min(left.length, right.length) < MIN_NEAR_LENGTH) return false;
290
+ /** 二つの英字だけの語が一字違いか(置き換え・隣どうしの入れ替え・中の抜け)。長さは問わない。 */
291
+ const isOneLetterApart = (left: string, right: string): boolean => {
292
+ if (left === right || !LATIN_WORD.test(left) || !LATIN_WORD.test(right)) return false;
274
293
  if (left.length === right.length) return isSwapOrReplace(left, right);
275
294
  if (left.length === right.length + 1) return isInnerDrop(left, right);
276
295
  return right.length === left.length + 1 && isInnerDrop(right, left);
277
296
  };
278
297
 
298
+ /** 二つの語が一字違いか。英字だけの、長さ 5 以上の語で。 */
299
+ export const isNearWord = (left: string, right: string): boolean => Math.min(left.length, right.length) >= MIN_NEAR_LENGTH && isOneLetterApart(left, right);
300
+
279
301
  /** 語の一つを伏せた形。ほかの語が同じ二つの名前は、同じ形を一つ持つ。 */
280
302
  const maskedKeys = (tally: Tally): string[] => {
281
303
  const words = wordsOf(tally.surface);
@@ -291,13 +313,37 @@ const differingWords = (left: Tally, right: Tally): readonly [string, string] |
291
313
  };
292
314
 
293
315
  /** 一語だけが一字違いで、相手のほうが重い(outweighs)。どちらもふつうの語(Green と Greek)なら、別の二つの語。 */
294
- const isSlipOf = (tally: Tally, other: Tally): boolean => {
295
- if (!outweighs(other, tally) || (tally.first.ordinary === true && other.first.ordinary === true)) return false;
296
- const words = differingWords(tally, other);
297
- return words !== undefined && isNearWord(...words);
298
- };
316
+ const isSlipOf =
317
+ (use: WordUse): Alike =>
318
+ (tally, other) => {
319
+ if (!outweighs(other, tally) || (tally.first.ordinary === true && other.first.ordinary === true)) return false;
320
+ const words = differingWords(tally, other);
321
+ return words !== undefined && isNearWord(...words) && !isWordFormOf(...words, use);
322
+ };
299
323
 
300
- const nearVariants = (tallies: readonly Tally[]): NameVariant[] => variantsIn(groupBy(tallies, maskedKeys), "near", isSlipOf, true);
324
+ /**
325
+ * 二語以上の名前の一語だけが、終わりの一字の抜けか足し(Rachel Whitmore と Rachel Whitmor)か、最後の語(姓)が四字でも一字違い
326
+ * (Daniel Reyes と Daniel Reys)で、相手のほうが重い(outweighs)。違う語のどちらかがふつうの語なら語の形の違い。
327
+ */
328
+ const isEndSlipOf =
329
+ (use: WordUse): Alike =>
330
+ (tally, other) => {
331
+ const [words, others] = [wordsOf(tally.surface), wordsOf(other.surface)];
332
+ const at = words.findIndex((word, index) => word !== others[index]);
333
+ const [word, usual] = [words[at], others[at]];
334
+ if (!outweighs(other, tally) || words.length < 2 || words.length !== others.length || word === undefined || usual === undefined) return false;
335
+ return !use.ordinary.has(word) && !use.ordinary.has(usual) && isEndWordSlip(words, at, usual, use, isOneLetterApart);
336
+ };
337
+
338
+ const nearVariants = (tallies: readonly Tally[], use: WordUse, givenNames: GivenNames): NameVariant[] => {
339
+ const [isSlip, isEndSlip] = [isSlipOf(use), isEndSlipOf(use)];
340
+ return variantsIn(
341
+ groupBy(tallies, maskedKeys),
342
+ "near",
343
+ (tally, other) => !areOtherPeople(givenNames.get(tally.surface), givenNames.get(other.surface)) && (isSlip(tally, other) || isEndSlip(tally, other)),
344
+ true,
345
+ );
346
+ };
301
347
 
302
348
  /**
303
349
  * 名が同じで姓だけが二字ほど違う人の名前(Rachel Whitford と Rachel Whitfield)。一字違い(near)より遠いので、名と姓の二語以上
@@ -343,7 +389,7 @@ const oneCharApart = (left: string, right: string): boolean => {
343
389
 
344
390
  /**
345
391
  * 読みが同じ人の名前が、一字だけ違う(松本 と 松元)。読みの同じ別の姓(伊藤 と 伊東)もあるので、相手のほうが重い(outweighs)
346
- * ときに限る。
392
+ * ときに限る。名を名の中での字の読みで読み直した読み(健太 と 建太 の ケンタ)でも比べる。
347
393
  */
348
394
  const isPersonSlipOf = (tally: Tally, other: Tally): boolean => outweighs(other, tally) && oneCharApart(tally.surface, other.surface);
349
395
 
@@ -351,7 +397,7 @@ const personReadingVariants = (tallies: readonly Tally[]): NameVariant[] =>
351
397
  variantsIn(
352
398
  groupBy(
353
399
  tallies.filter((tally) => tally.person),
354
- (tally) => tally.readings,
400
+ (tally) => [...tally.readings, ...tally.givenNameReadings],
355
401
  ),
356
402
  "reading",
357
403
  isPersonSlipOf,
@@ -360,9 +406,14 @@ const personReadingVariants = (tallies: readonly Tally[]): NameVariant[] =>
360
406
 
361
407
  /**
362
408
  * 同じ名前の、少ないほうの書き方。書き方ごとに最初の現れを一つ。同じ現れを二つの見方が言えば、先の見方だけ。chars は字体の
363
- * 違う同じ字の組(語彙表 name-variant-char)。
409
+ * 違う同じ字の組(語彙表 name-variant-char)。use は文書での英字の語の使い方。
364
410
  */
365
- export const nameVariants = (mentions: readonly NameMention[], chars: VariantChars = new Map(), spelling: SpellingInput = NO_SPELLING): NameVariant[] => {
411
+ export const nameVariants = (
412
+ mentions: readonly NameMention[],
413
+ chars: VariantChars = new Map(),
414
+ spelling: SpellingInput = NO_SPELLING,
415
+ use: WordUse = NO_WORD_USE,
416
+ ): NameVariant[] => {
366
417
  const tallies = talliesOf(mentions);
367
418
  const found = [
368
419
  ...variantsIn(
@@ -378,7 +429,7 @@ export const nameVariants = (mentions: readonly NameMention[], chars: VariantCha
378
429
  "reading",
379
430
  oneWordApart,
380
431
  ),
381
- ...nearVariants(tallies),
432
+ ...nearVariants(tallies, use, givenNamesBySurface(mentions)),
382
433
  ...surnameVariants(tallies),
383
434
  ...characterVariants(tallies, chars),
384
435
  ...personReadingVariants(tallies),
@@ -41,12 +41,25 @@ const CAPITALISED = "\\p{Lu}[\\p{L}'’-]*";
41
41
 
42
42
  const FIRST_WORD = new RegExp(`^${CAPITALISED}[ \\t]+`, "u");
43
43
 
44
+ /** 小さな語の並び。冠詞(the)は前置詞(of、for)のすぐ後ろにだけ立つ(Bank of the West)。 */
45
+ const joinerPattern = (joiners: readonly string[], articles: readonly string[]): string => {
46
+ if (joiners.length === 0) return "";
47
+ const article = articles.length === 0 ? "" : `(?:(?:${articles.map(escapeRegExp).join("|")})[ \\t]+)?`;
48
+ return `(?:(?:${joiners.map(escapeRegExp).join("|")})[ \\t]+${article})*`;
49
+ };
50
+
44
51
  /**
45
- * 大文字で始まる語が二つ以上並んだ所(Foundations of Statistics)。語のあいだに小さな語(of)を挟んでよい。文の頭の語は、
46
- * 文の頭だから大文字のことがあるので、外す(Take Data Lab の Take)。
52
+ * 大文字で始まる語が二つ以上並んだ所(Foundations of Statistics)。語のあいだに小さな語(of、of the)を挟んでよい。冠詞だけを
53
+ * 挟んだ二つの語(this Agreement the Stockholders)は、句の切れ目をまたぐので一つの名前にしない。文の頭の語は、文の頭だから
54
+ * 大文字のことがあるので、外す(Take Data Lab の Take)。
47
55
  */
48
- export const titleCaseSpans = (text: string, joiners: readonly string[], isSentenceStart: (offset: number) => boolean = () => false): NameSpan[] => {
49
- const joiner = joiners.length === 0 ? "" : `(?:(?:${joiners.map(escapeRegExp).join("|")})[ \\t]+)*`;
56
+ export const titleCaseSpans = (
57
+ text: string,
58
+ joiners: readonly string[],
59
+ isSentenceStart: (offset: number) => boolean = () => false,
60
+ articles: readonly string[] = [],
61
+ ): NameSpan[] => {
62
+ const joiner = joinerPattern(joiners, articles);
50
63
  const pattern = new RegExp(`(?<![\\p{L}'’-])${CAPITALISED}(?:[ \\t]+${joiner}${CAPITALISED})+`, "gu");
51
64
  return [...text.matchAll(pattern)].map((found) => {
52
65
  const start = found.index ?? 0;
@@ -112,16 +125,33 @@ export const orderNamesOf = (text: string, spans: readonly NameSpan[], words: re
112
125
  .toSorted((left, right) => left.offset - right.offset);
113
126
  };
114
127
 
115
- type Tally = { readonly first: OrderName; readonly count: number; readonly anchored: boolean };
116
-
117
- const talliesOf = (names: readonly OrderName[]): Tally[] => [
118
- ...names
119
- .reduce<Map<string, Tally>>((tallies, name) => {
120
- const known = tallies.get(name.surface);
121
- return tallies.set(name.surface, { first: known?.first ?? name, count: (known?.count ?? 0) + 1, anchored: (known?.anchored ?? false) || name.anchored });
122
- }, new Map())
123
- .values(),
124
- ];
128
+ type Tally = { readonly first: OrderName; readonly count: number; readonly anchored: boolean; readonly offsets: readonly number[] };
129
+
130
+ /** 書き方ごとの、現れの位置のすべて。 */
131
+ const offsetsBySurface = (names: readonly OrderName[]): Map<string, number[]> =>
132
+ names.reduce((offsets, name) => {
133
+ const known = offsets.get(name.surface);
134
+ if (known === undefined) offsets.set(name.surface, [name.offset]);
135
+ else known.push(name.offset);
136
+ return offsets;
137
+ }, new Map<string, number[]>());
138
+
139
+ const talliesOf = (names: readonly OrderName[]): Tally[] => {
140
+ const offsets = offsetsBySurface(names);
141
+ return [
142
+ ...names
143
+ .reduce<Map<string, Tally>>((tallies, name) => {
144
+ const known = tallies.get(name.surface);
145
+ return tallies.set(name.surface, {
146
+ first: known?.first ?? name,
147
+ count: (known?.count ?? 0) + 1,
148
+ anchored: (known?.anchored ?? false) || name.anchored,
149
+ offsets: offsets.get(name.surface) ?? [],
150
+ });
151
+ }, new Map())
152
+ .values(),
153
+ ];
154
+ };
125
155
 
126
156
  /** 多いほうが前。同じ数なら先に書いたほうが前。 */
127
157
  const byUse = (left: Tally, right: Tally): number => right.count - left.count || left.first.offset - right.first.offset;
@@ -135,15 +165,30 @@ export const isReordered = (left: OrderName, right: OrderName): boolean =>
135
165
  !left.surface.includes(right.surface) &&
136
166
  !right.surface.includes(left.surface);
137
167
 
168
+ /** 文の番号。同じ文の二つの書き方を見分けるため。 */
169
+ export type SentenceOf = (offset: number) => number;
170
+
171
+ /** 二つの書き方を、どこかで同じ文に並べて書いたか(“Request Additional Time” or “Additional Time Requests”)。 */
172
+ const sharesSentence = (left: Tally, right: Tally, sentenceOf: SentenceOf): boolean => {
173
+ const sentences = new Set(left.offsets.map(sentenceOf));
174
+ return right.offsets.some((offset) => sentences.has(sentenceOf(offset)));
175
+ };
176
+
138
177
  /**
139
178
  * 多く使った書き方と同じ語を違う順に並べた名前。少ないほうを一つずつ指す。二つのどちらかが名前として書いた所(anchored)に
140
- * あるときだけ。surfaces は表の升まるごとの書き方で、その書き方の名前も anchored と見る。
179
+ * あるときだけ。surfaces は表の升まるごとの書き方で、その書き方の名前も anchored と見る。同じ文に並べて書いた二つは、書き手が
180
+ * 言い分けた別の名前(画面の二つの項目、定義する語とその中身)なので比べない。
141
181
  */
142
- export const wordOrderVariants = (names: readonly OrderName[], surfaces: ReadonlySet<string> = new Set()): OrderVariant[] => {
182
+ export const wordOrderVariants = (
183
+ names: readonly OrderName[],
184
+ surfaces: ReadonlySet<string> = new Set(),
185
+ sentenceOf: SentenceOf = (offset) => offset,
186
+ ): OrderVariant[] => {
143
187
  const tallies = talliesOf(names).toSorted(byUse);
144
188
  const anchored = (tally: Tally): boolean => tally.anchored || surfaces.has(tally.first.surface);
189
+ const apart = (left: Tally, right: Tally): boolean => !sharesSentence(left, right, sentenceOf);
145
190
  return tallies.flatMap((tally, index) => {
146
- const usual = tallies.slice(0, index).find((other) => (anchored(other) || anchored(tally)) && isReordered(other.first, tally.first));
191
+ const usual = tallies.slice(0, index).find((other) => (anchored(other) || anchored(tally)) && isReordered(other.first, tally.first) && apart(other, tally));
147
192
  return usual === undefined ? [] : [{ name: tally.first, usual: usual.first.surface }];
148
193
  });
149
194
  };
@@ -0,0 +1,36 @@
1
+ import type { Token } from "./plugin.ts";
2
+
3
+ /** The last kana of a verb's dictionary form, and the kana its stem form (連用形) ends in instead: 払い込む → 払い込み. */
4
+ const STEM_ENDING: Readonly<Record<string, string>> = { う: "い", く: "き", ぐ: "ぎ", す: "し", つ: "ち", ぬ: "に", ぶ: "び", む: "み", る: "り" };
5
+
6
+ /**
7
+ * Whether a verb is written in its stem form (払い込み from 払い込む, 申出 from 申出る). Other forms that differ from the
8
+ * dictionary form (ください from 下さる, 払い込ん before で) are not: they are never a noun.
9
+ */
10
+ export const isStemForm = (surface: string, lemma: string): boolean => {
11
+ const last = lemma.slice(-1);
12
+ const stem = lemma.slice(0, -1);
13
+ if (stem === "") return false;
14
+ return surface === stem + (STEM_ENDING[last] ?? "\u0000") || (last === "る" && surface === stem);
15
+ };
16
+
17
+ /** What carries a verb on (払い込み、払い込んで, 払い込みます, 払い込みやすい): after these the stem form is still the verb. */
18
+ const VERB_GOES_ON = new Set(["AUX", "SCONJ", "VERB", "ADJ"]);
19
+ const CLAUSE_COMMA = new Set(["、", ",", ","]);
20
+
21
+ /**
22
+ * A free noun after the stem form may begin the next clause (疾病にかかり療養のために), so the stem form stays a verb; a suffix
23
+ * (払込み等), or a noun the caller lists as one (受取り前), may not.
24
+ */
25
+ const verbGoesOn = (next: Token, suffixes: ReadonlySet<string>): boolean =>
26
+ VERB_GOES_ON.has(next.pos) || CLAUSE_COMMA.has(next.surface) || (next.pos === "NOUN" && next.features?.["Bound"] !== "Yes" && !suffixes.has(next.surface));
27
+
28
+ /**
29
+ * A verb's stem form that the verb does not go on from (払込みの期日, 申出により, 株式の買取り)): a noun the analyser read as the
30
+ * verb, returned as the noun it is, spelled as written. Official Japanese spells the noun and the verb apart (払込み, 払い込む),
31
+ * so the two are not one word in two spellings; the noun is compared with nouns. Any other token is returned as it is.
32
+ */
33
+ export const asNounWhereNominal = (token: Token, next: Token | undefined, suffixes: ReadonlySet<string> = new Set()): Token => {
34
+ if (token.pos !== "VERB" || token.lemma === undefined || !isStemForm(token.surface, token.lemma)) return token;
35
+ return next !== undefined && verbGoesOn(next, suffixes) ? token : { ...token, pos: "NOUN", lemma: token.surface };
36
+ };
@@ -6,7 +6,7 @@ import type { Span, Token } from "./plugin.ts";
6
6
  * 「〒100-8916 東京都」の郵便番号、「紀尾井町1-3 東京ガーデンテラス」の番地は、後ろの空白が番号と題・項目の区切りで、「3回」「3 回」のような空け方の好みではない。
7
7
  * 空け方を数える材料にしない。
8
8
  *
9
- * 形で名前と読むのは六つだけ。0 で始まる組を含むハイフンつなぎの番号、※・〒や鉤括弧のすぐ後ろの番号、市・区・町まで下りた地名のすぐ後ろのハイフンつなぎの番号、
9
+ * 形で名前と読むのは七つだけ。桁の区切りの無い 6 桁以上の番号(口座番号 3056172)、0 で始まる組を含むハイフンつなぎの番号、※・〒や鉤括弧のすぐ後ろの番号、市・区・町まで下りた地名のすぐ後ろのハイフンつなぎの番号、
10
10
  * 文頭の階層つきの節番号(2.1、3.1.2)、続き番号になった行や番号の並ぶ箇条書きの頭の番号(白書の注、関連コード)、「問3」のように番号の前に書く語のすぐ後ろの番号。
11
11
  * 文頭でも「223 言語」「1ターン」は数量なので、階層の無い数は文頭というだけでは名前と読まない。
12
12
  * そのうえで、すぐ後ろ(空白 1 つまで)の語が数につく語(助数詞・数・助詞・助動詞)なら数量として数え続ける(「3-5 日」「26.7 万行」)。
@@ -53,8 +53,16 @@ const wordAfter = (tokens: readonly Token[], text: string, run: Span, base: numb
53
53
  return tokens.find((token) => token.span.start === base + next);
54
54
  };
55
55
 
56
- const isBoundToNumber = (token: Token): boolean =>
57
- token.features?.["NounType"] === "Class" || token.features?.["NumType"] === "Card" || BOUND_TO_NUMBER.has(token.pos);
56
+ /** 助数詞(NounType=Class)か数(NumType=Card)。 */
57
+ const isCounterOrNumber = (token: Token | undefined): boolean => token?.features?.["NounType"] === "Class" || token?.features?.["NumType"] === "Card";
58
+
59
+ const isBoundToNumber = (token: Token): boolean => isCounterOrNumber(token) || BOUND_TO_NUMBER.has(token.pos);
60
+
61
+ /**
62
+ * 桁の区切りの無い、6 桁以上の数字だけの番号(口座番号 3056172 を、普通 1234567)。この大きさの数量は桁を区切るか単位を付けて書くので、
63
+ * 助数詞か数が続くとき(1234567円、250000 人)だけ数量と読む。助詞が続いても番号のまま。
64
+ */
65
+ const PLAIN_CODE = /^\d{6,}$/u;
58
66
 
59
67
  /** 「1 又は 2」の接続詞は数どうしをつなぐが、続き番号の注の本文は「31 ただし、…」のように接続詞でも始まる。 */
60
68
  const CONJUNCTIONS = new Set(["CCONJ", "SCONJ"]);
@@ -221,6 +229,7 @@ export type NameContext = {
221
229
  export const isNumberName = (text: string, run: Span, tokens: readonly Token[] | undefined, base: number, context: NameContext = {}): boolean => {
222
230
  const inSequence = context.sequence?.has(base + run.start) ?? false;
223
231
  if (tokens === undefined) return false;
232
+ if (PLAIN_CODE.test(text.slice(run.start, run.end))) return !isCounterOrNumber(wordAfter(tokens, text, run, base));
224
233
  const shaped =
225
234
  inSequence ||
226
235
  isNameShaped(text, run) ||
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 行頭の箇条の印。Markdown の印(- * + と 1. 1))は後ろに空白が要る。「・」は日本語で手で打つ箇条の印で、空白を置かずに続けて書く。
3
+ * 「**賃料**」の太字や「-5」は印ではない。
4
+ */
5
+ const LIST_MARKER = /^([ \t]*)(?:(?:[-*+]|\d{1,9}[.)])[ \t]+|・[ \t\u3000]*)/gmu;
6
+
7
+ /** 行頭で項目の名だけを包む太字(「**賃料**:」)。名の後ろにすぐ区切りが来るときだけで、文の中の太字は外さない。 */
8
+ const BOLD_LABEL = /^([ \t]*)\*\*([^*::||\n]+)\*\*(?=[ \t]*[||::])/gmu;
9
+
10
+ /**
11
+ * 内容から種類を選ぶ行を読むために、行頭の箇条の印と、項目の名を包む太字を外す。字下げは残す。
12
+ * 「- 賃料:85,000円」「・賃料:85,000円」「**賃料**:85,000円」も「賃料:85,000円」と同じ項目の行として数えるため。
13
+ */
14
+ export const withoutListMarkers = (source: string): string => source.replace(LIST_MARKER, "$1").replace(BOLD_LABEL, "$1$2");
@@ -1,4 +1,5 @@
1
1
  import type { DocumentProfile, RelativeVocabulary } from "../plugin.ts";
2
+ import { withoutListMarkers } from "./cue-lines.ts";
2
3
 
3
4
  /** profiles/*.yaml を一つ読んだもの。言語ごとの中身と、内容から選ぶための形を持つ。 */
4
5
  export type ProfileDefinition = {
@@ -137,10 +138,10 @@ export const parseProfile = (raw: unknown): ProfileDefinition | undefined => {
137
138
  return { id, name: texts(raw["name"]), detect, languages: languagesOf(id, raw) };
138
139
  };
139
140
 
140
- /** 行頭から数える。source 全体に m フラグで当てれば、行ごとに分けずに数えられる。 */
141
+ /** 行頭から数える。source 全体に m フラグで当てれば、行ごとに分けずに数えられる。箇条の印は行頭に数えない。 */
141
142
  export const detected = (definition: ProfileDefinition, source: string, language: string): boolean => {
142
143
  const detect = definition.detect[language];
143
144
  if (detect === undefined) return false;
144
- const count = [...source.matchAll(new RegExp(detect.line, "gmu"))].length;
145
+ const count = [...withoutListMarkers(source).matchAll(new RegExp(detect.line, "gmu"))].length;
145
146
  return count >= detect.minLines;
146
147
  };
@@ -18,7 +18,7 @@ export const MAX_CHARACTERS = 24;
18
18
  const DIGIT = /\d/gu;
19
19
  const SEPARATOR = /[-‐−-]/gu;
20
20
  /** Only spaces and a colon, comma or opening bracket between the label and its number (「予約番号:」, "booking number, "); not a sentence's end. */
21
- const LABEL_TO_NUMBER = /^[\s::,,、##((「『[[]{0,4}$/u;
21
+ export const LABEL_TO_NUMBER = /^[\s::,,、##((「『[[]{0,4}$/u;
22
22
 
23
23
  export const charactersOf = (written: string): string => written.normalize("NFKC").replaceAll(SEPARATOR, "").replaceAll(" ", "").toUpperCase();
24
24
 
@@ -20,18 +20,23 @@ const BRACKETS: Readonly<Record<string, string>> = {
20
20
  "“": "”",
21
21
  };
22
22
 
23
+ /** A closer and the same closer in the other width: a numbering marker written (1) closes the bracket it opened. */
24
+ const OTHER_WIDTH: Readonly<Record<string, string>> = { ")": ")", ")": ")", "]": "]", "]": "]" };
25
+
23
26
  /** A formula written in TeX ($d^k = -\nabla f(x^k)$): its brackets are the formula's, not the sentence's. */
24
27
  const FORMULA = /\$\$[^$]*\$\$|\$[^$\n]*\$/gu;
25
28
 
26
29
  /**
27
30
  * The deepest the brackets of a text nest: 「計画(案)」 is one, 「(注(a)を参照)」 two, plain text none. A closer with no
28
- * opener (the 1) of a list) is ignored, an opener never closed counts as open until the end, and formulas in $…$ are skipped.
31
+ * opener (the 1) of a list) is ignored, an opener never closed counts as open until the end, a closer of the other width closes
32
+ * its opener ((1) is one), and formulas in $…$ are skipped.
29
33
  */
30
34
  export const bracketDepth = (text: string): number => {
31
35
  // The closers still awaited, innermost last. Pushed and popped in place: copying it per character is quadratic on deep nesting.
32
36
  const awaited: string[] = [];
33
37
  return [...text.replace(FORMULA, " ")].reduce((deepest, char) => {
34
- if (awaited.at(-1) === char) awaited.pop();
38
+ const innermost = awaited.at(-1);
39
+ if (innermost !== undefined && (innermost === char || innermost === OTHER_WIDTH[char])) awaited.pop();
35
40
  else if (BRACKETS[char] !== undefined) awaited.push(BRACKETS[char]);
36
41
  return Math.max(deepest, awaited.length);
37
42
  }, 0);
@@ -4,7 +4,7 @@ import { isInPersonField as isFieldValue } from "./person-field.ts";
4
4
  // 空白を挟んで書いた姓と名(高瀬 誠、佐伯 未咲)を、解析器の品詞に頼らず、前後の語で人の名前と読む。解析器は姓を地名やふつうの
5
5
  // 名詞と読み、名を二語に切ることがあるので、姓と名を一つの名前にできない。後ろに敬称か肩書き(様、部長)が付くか、人を書く欄
6
6
  // (氏名:、承認者:)の行の終わりにあれば、人の名前と読む。欄に書いた名と同じ名を空白の後ろに書いたもの(受託者:西村 亮 の
7
- // 文書の 西邑 亮が)も、人の名前と読む。
7
+ // 文書の 西邑 亮が)も、人の名前と読む。名はかなで書いてもよい(松本 あかり 様)。
8
8
 
9
9
  /** suffixes は敬称(様、さん)、titles は名前のすぐ後ろの肩書き(部長)、labels は人を書く欄の語(氏名、承認者)。語彙表から。 */
10
10
  export type SpacedNameCues = { readonly suffixes: readonly string[]; readonly titles: readonly string[]; readonly labels: readonly string[] };
@@ -31,6 +31,13 @@ const LINE_MARKS = /^[\s>*#+-]*/u;
31
31
  const FIELD_END = /^[\u0020\u3000]*(?:[((][^(())\n]*[))][\u0020\u3000]*)?(?:\r?\n|$)/u;
32
32
 
33
33
  const isHan = (letter: string | undefined): boolean => letter !== undefined && HAN.test(letter);
34
+ const KANA = /^[\p{Script=Hiragana}\p{Script=Katakana}]$/u;
35
+ const LEADING_KANA = /^[\p{Script=Hiragana}\p{Script=Katakana}ー]+/u;
36
+ /** かなで書いた名の字数(あかり、エミリー)。一字のかな(ご担当 の ご)は名でない。 */
37
+ const MIN_KANA_GIVEN = 2;
38
+ const MAX_KANA_GIVEN = 5;
39
+
40
+ const isKana = (letter: string | undefined): boolean => letter !== undefined && KANA.test(letter);
34
41
 
35
42
  /** 人を書く欄の行(承認者:営業部長 高瀬 誠)で、姓が欄の語の後ろにあるか。 */
36
43
  const isInPersonField = (source: string, surnameStart: number, labels: readonly string[]): boolean => {
@@ -53,8 +60,23 @@ const givenBeforeSuffix = (run: string, after: string, words: readonly string[])
53
60
  });
54
61
  };
55
62
 
63
+ /**
64
+ * かなで書いた名(松本 あかり 様)。かなの連なりまるごとを名と読み、後ろに空白一つまでを挟んで敬称か肩書きが付くか、人を書く欄の
65
+ * 行の終わりにあるときだけ。かなの続きの中で敬称を切り出さない(みなさま を みな と さま にしない)。
66
+ */
67
+ const kanaGivenAt = (source: string, start: number, cues: SpacedNameCues, inField: boolean, fieldGivens: ReadonlySet<string>): string | undefined => {
68
+ const run = LEADING_KANA.exec(source.slice(start, start + LOOKBACK))?.[0];
69
+ const length = [...(run ?? "")].length;
70
+ if (run === undefined || length < MIN_KANA_GIVEN || length > MAX_KANA_GIVEN) return undefined;
71
+ const after = source.slice(start + run.length, start + run.length + LOOKBACK);
72
+ const rest = after.replace(ONE_SPACE, "");
73
+ if ([...cues.suffixes, ...cues.titles].some((word) => rest.startsWith(word))) return run;
74
+ return fieldGivens.has(run) || (inField && FIELD_END.test(after)) ? run : undefined;
75
+ };
76
+
56
77
  /** fieldGivens は、文書が人を書く欄に書いた名(亮)。その名と同じ漢字の連なりは、敬称が無くても名と読む。 */
57
78
  const givenAt = (source: string, start: number, cues: SpacedNameCues, inField: boolean, fieldGivens: ReadonlySet<string>): string | undefined => {
79
+ if (isKana(source.charAt(start))) return kanaGivenAt(source, start, cues, inField, fieldGivens);
58
80
  const run = LEADING_HAN.exec(source.slice(start, start + LOOKBACK))?.[0];
59
81
  if (run === undefined) return undefined;
60
82
  const after = source.slice(start + run.length, start + run.length + LOOKBACK);
@@ -73,10 +95,13 @@ const surnameBefore = (source: string, space: number, cues: SpacedNameCues): str
73
95
  return [...cues.titles, ...cues.suffixes].some((word) => run.endsWith(word)) ? undefined : run;
74
96
  };
75
97
 
98
+ /** 名の頭の字。漢字か、かな(松本 あかり)。 */
99
+ const isNameLetter = (letter: string | undefined): boolean => isHan(letter) || isKana(letter);
100
+
76
101
  const namesIn = (source: string, cues: SpacedNameCues, fieldGivens: ReadonlySet<string>): SpacedName[] =>
77
102
  [...source.matchAll(NAME_SPACE)].flatMap((match) => {
78
103
  const space = match.index;
79
- if (!isHan(LAST_LETTER.exec(source.slice(Math.max(0, space - 2), space))?.[0]) || !isHan(FIRST_LETTER.exec(source.slice(space + 1, space + 3))?.[0]))
104
+ if (!isHan(LAST_LETTER.exec(source.slice(Math.max(0, space - 2), space))?.[0]) || !isNameLetter(FIRST_LETTER.exec(source.slice(space + 1, space + 3))?.[0]))
80
105
  return [];
81
106
  const surname = surnameBefore(source, space, cues);
82
107
  if (surname === undefined) return [];
@@ -28,6 +28,15 @@ const HYPHENATED = new RegExp(
28
28
  "gu",
29
29
  );
30
30
  const CAPITALS_SERIAL = new RegExp(`(?<![A-Za-z0-9.${HYPHEN_CHARS}])[A-Z]+\\d{4,}(?![A-Za-z0-9${HYPHEN_CHARS}]|\\.[A-Za-z0-9])`, "gu");
31
+ /**
32
+ * A Japanese number plate after its place name: a class number of two or three digits, one hiragana and a serial
33
+ * (330 ね 48-15, 500み・・12). A one-digit class number, or a serial that a kanji or katakana word follows, is a reference
34
+ * such as 「表3の12-15行」「表30の12-34行」, not a plate. The spaces inside a plate are its layout, and the one before it ends the place name.
35
+ */
36
+ const PLATE = new RegExp(
37
+ `(?<![\\d${HYPHEN_CHARS}])\\d{2,3}[ \\u3000]?\\p{Script=Hiragana}[ \\u3000]?(?:\\d{1,2}[${HYPHEN_CHARS}]\\d{2}|[・・]{1,3}\\d{1,3})(?![\\d${HYPHEN_CHARS}\\p{Script=Han}\\p{Script=Katakana}])`,
38
+ "gu",
39
+ );
31
40
  const HAS_LETTER = /[A-Za-z]/u;
32
41
  const SERIAL_DIGITS = /\d{3}/u;
33
42
 
@@ -40,8 +49,10 @@ export const addressSpans = (text: string): Span[] => spansOf(text, ASCII_RUN).f
40
49
 
41
50
  const isIdentifier = (word: string): boolean => HAS_LETTER.test(word) && SERIAL_DIGITS.test(word);
42
51
 
43
- export const identifierSpans = (text: string): Span[] =>
44
- [...spansOf(text, HYPHENATED), ...spansOf(text, CAPITALS_SERIAL)].filter((span) => isIdentifier(text.slice(span.start, span.end)));
52
+ export const identifierSpans = (text: string): Span[] => [
53
+ ...[...spansOf(text, HYPHENATED), ...spansOf(text, CAPITALS_SERIAL)].filter((span) => isIdentifier(text.slice(span.start, span.end))),
54
+ ...spansOf(text, PLATE),
55
+ ];
45
56
 
46
57
  /** Whether the character at `at` is inside one of the spans. */
47
58
  export const isInsideSpan = (spans: readonly Span[], at: number): boolean => spans.some((span) => span.start <= at && at < span.end);
@@ -25,3 +25,20 @@ export const minorityReport = <T extends { readonly spaced: boolean }>(ofKind: r
25
25
  const spaced = ofKind.filter((entry) => entry.spaced).length;
26
26
  return { mode: "mixed", first, odd: odd.length, spaced, touching: ofKind.length - spaced };
27
27
  };
28
+
29
+ /** 同数のとき、書き方が二通りあると 1 件で言う最少の数。1 対 1 は一つずつの書き違いとも区別がつかないので言わない。 */
30
+ const MIN_TIE = 2;
31
+
32
+ /**
33
+ * 二通りが同じ数なら少ないほうは無く、1 箇所ずつ「違う」と指すとどちらかの側に立つ。MIN_TIE 対 MIN_TIE 以上なら書き方が二通りあることを 1 件で言い、
34
+ * それより少なければ言わない。同数でなければ report のまま。
35
+ */
36
+ export const withoutSideOnTie = <T extends { readonly spaced: boolean }>(
37
+ report: MinorityReport<T> | undefined,
38
+ ofKind: readonly T[],
39
+ ): MinorityReport<T> | undefined => {
40
+ if (report?.mode !== "each" || report.odd.length * 2 !== ofKind.length) return report;
41
+ const first = ofKind[0];
42
+ if (report.odd.length < MIN_TIE || first === undefined) return undefined;
43
+ return { mode: "mixed", first, odd: report.odd.length, spaced: report.odd.length, touching: report.odd.length };
44
+ };
@@ -0,0 +1,42 @@
1
+ import type { StructureNode } from "../plugin.ts";
2
+
3
+ // 他の文書を引き写した節。「##### 地方公務員法」の下に引いた第十六条の「第六十条」は、地方公務員法の条で、この文書の条ではない。
4
+
5
+ /** heading: いちばん近い見出しの節の言葉。inArticle: 条の中か。 */
6
+ type Visit = { readonly node: StructureNode; readonly heading: string | undefined; readonly inArticle: boolean };
7
+
8
+ /** 見出しの言葉。文書の最初の見出しは文書自身の題(「# 就業規則」)なので、他の文書の名前として読まない。 */
9
+ const headingOf = (node: StructureNode, title: StructureNode | undefined): string | undefined =>
10
+ node === title ? undefined : String(node.attrs["heading"] ?? "").trim();
11
+
12
+ const documentsCited = (nodes: readonly StructureNode[]): ReadonlySet<string> =>
13
+ new Set(nodes.flatMap((node) => (node.kind === "reference" && typeof node.attrs["document"] === "string" ? [node.attrs["document"]] : [])));
14
+
15
+ /** 木を上から順に、見出しの言葉と条の中かと一緒に並べる。再帰にしないのは、深い木でスタックを使い切らないため。 */
16
+ const visitsOf = (tree: StructureNode): Visit[] => {
17
+ const title = tree.children.find((child) => child.kind === "section");
18
+ const visits: Visit[] = [];
19
+ const pending: Visit[] = [{ node: tree, heading: undefined, inArticle: false }];
20
+ while (pending.length > 0) {
21
+ const visit = pending.pop();
22
+ if (visit === undefined) break;
23
+ visits.push(visit);
24
+ const { node } = visit;
25
+ const heading = node.kind === "section" ? headingOf(node, title) : visit.heading;
26
+ const inArticle = node.kind === "section" ? false : visit.inArticle || node.kind === "article";
27
+ node.children.toReversed().forEach((child) => pending.push({ node: child, heading, inArticle }));
28
+ }
29
+ return visits;
30
+ };
31
+
32
+ /**
33
+ * 見出しが他の文書の名前そのものである節に引き写した条の中の参照。その名前を文書がほかで他の文書として引いている
34
+ * (「地方公務員法第16条」)ときだけ、節はその文書を引き写したものと読む。条の外の地の文の参照は、この文書のもの。Pure.
35
+ */
36
+ export const referencesInCitedDocuments = (tree: StructureNode): ReadonlySet<StructureNode> => {
37
+ const visits = visitsOf(tree);
38
+ const cited = documentsCited(visits.map((visit) => visit.node));
39
+ if (cited.size === 0) return new Set();
40
+ const quoted = visits.filter((visit) => visit.node.kind === "reference" && visit.inArticle && visit.heading !== undefined && cited.has(visit.heading));
41
+ return new Set(quoted.map((visit) => visit.node));
42
+ };