chaffjs 0.38.0 → 0.40.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 (892) hide show
  1. package/README.ja.md +21 -4
  2. package/README.md +20 -2
  3. package/checks/ai-tells.yaml +153 -0
  4. package/dist/acronym-expansion.d.ts +4 -0
  5. package/dist/acronym-expansion.d.ts.map +1 -0
  6. package/dist/acronym-expansion.js +46 -0
  7. package/dist/acronym-expansion.js.map +1 -0
  8. package/dist/ai-score/human-shares.d.ts.map +1 -1
  9. package/dist/ai-score/human-shares.js +54 -12
  10. package/dist/ai-score/human-shares.js.map +1 -1
  11. package/dist/ai-score/of-document.d.ts.map +1 -1
  12. package/dist/ai-score/of-document.js +4 -2
  13. package/dist/ai-score/of-document.js.map +1 -1
  14. package/dist/alternative-words.d.ts +6 -0
  15. package/dist/alternative-words.d.ts.map +1 -1
  16. package/dist/alternative-words.js +10 -0
  17. package/dist/alternative-words.js.map +1 -1
  18. package/dist/body-section.d.ts +3 -1
  19. package/dist/body-section.d.ts.map +1 -1
  20. package/dist/body-section.js +9 -2
  21. package/dist/body-section.js.map +1 -1
  22. package/dist/capitals-with-small.d.ts +5 -0
  23. package/dist/capitals-with-small.d.ts.map +1 -1
  24. package/dist/capitals-with-small.js +15 -0
  25. package/dist/capitals-with-small.js.map +1 -1
  26. package/dist/checks.d.ts +11 -0
  27. package/dist/checks.d.ts.map +1 -1
  28. package/dist/checks.js +27 -1
  29. package/dist/checks.js.map +1 -1
  30. package/dist/cli-args.js +1 -1
  31. package/dist/cli-args.js.map +1 -1
  32. package/dist/cli-text.d.ts.map +1 -1
  33. package/dist/cli-text.js +4 -0
  34. package/dist/cli-text.js.map +1 -1
  35. package/dist/closing-code.d.ts +8 -0
  36. package/dist/closing-code.d.ts.map +1 -0
  37. package/dist/closing-code.js +18 -0
  38. package/dist/closing-code.js.map +1 -0
  39. package/dist/commands/fix-plan.d.ts.map +1 -1
  40. package/dist/commands/fix-plan.js +64 -4
  41. package/dist/commands/fix-plan.js.map +1 -1
  42. package/dist/commands/test.d.ts.map +1 -1
  43. package/dist/commands/test.js +16 -2
  44. package/dist/commands/test.js.map +1 -1
  45. package/dist/date-format.d.ts +19 -1
  46. package/dist/date-format.d.ts.map +1 -1
  47. package/dist/date-format.js +41 -5
  48. package/dist/date-format.js.map +1 -1
  49. package/dist/detectors/acronym-context.d.ts +5 -2
  50. package/dist/detectors/acronym-context.d.ts.map +1 -1
  51. package/dist/detectors/acronym-context.js +19 -4
  52. package/dist/detectors/acronym-context.js.map +1 -1
  53. package/dist/detectors/acronym-expansion.d.ts.map +1 -1
  54. package/dist/detectors/acronym-expansion.js +25 -0
  55. package/dist/detectors/acronym-expansion.js.map +1 -1
  56. package/dist/detectors/acronym-gloss.d.ts +19 -0
  57. package/dist/detectors/acronym-gloss.d.ts.map +1 -1
  58. package/dist/detectors/acronym-gloss.js +115 -0
  59. package/dist/detectors/acronym-gloss.js.map +1 -1
  60. package/dist/detectors/acronym-mention.d.ts +5 -0
  61. package/dist/detectors/acronym-mention.d.ts.map +1 -1
  62. package/dist/detectors/acronym-mention.js +16 -0
  63. package/dist/detectors/acronym-mention.js.map +1 -1
  64. package/dist/detectors/acronym-name.d.ts +14 -2
  65. package/dist/detectors/acronym-name.d.ts.map +1 -1
  66. package/dist/detectors/acronym-name.js +28 -3
  67. package/dist/detectors/acronym-name.js.map +1 -1
  68. package/dist/detectors/acronym-series.d.ts +7 -0
  69. package/dist/detectors/acronym-series.d.ts.map +1 -0
  70. package/dist/detectors/acronym-series.js +25 -0
  71. package/dist/detectors/acronym-series.js.map +1 -0
  72. package/dist/detectors/ai-phrasing.d.ts +3 -6
  73. package/dist/detectors/ai-phrasing.d.ts.map +1 -1
  74. package/dist/detectors/ai-phrasing.js +17 -16
  75. package/dist/detectors/ai-phrasing.js.map +1 -1
  76. package/dist/detectors/ai-structure.d.ts +1 -0
  77. package/dist/detectors/ai-structure.d.ts.map +1 -1
  78. package/dist/detectors/ai-structure.js +15 -4
  79. package/dist/detectors/ai-structure.js.map +1 -1
  80. package/dist/detectors/alnum-number.d.ts +1 -0
  81. package/dist/detectors/alnum-number.d.ts.map +1 -1
  82. package/dist/detectors/alnum-number.js +7 -3
  83. package/dist/detectors/alnum-number.js.map +1 -1
  84. package/dist/detectors/bare-comparative.d.ts +6 -0
  85. package/dist/detectors/bare-comparative.d.ts.map +1 -1
  86. package/dist/detectors/bare-comparative.js +31 -12
  87. package/dist/detectors/bare-comparative.js.map +1 -1
  88. package/dist/detectors/blank-runs.d.ts +12 -0
  89. package/dist/detectors/blank-runs.d.ts.map +1 -0
  90. package/dist/detectors/blank-runs.js +27 -0
  91. package/dist/detectors/blank-runs.js.map +1 -0
  92. package/dist/detectors/bold-emphasis-form.d.ts +8 -0
  93. package/dist/detectors/bold-emphasis-form.d.ts.map +1 -0
  94. package/dist/detectors/bold-emphasis-form.js +40 -0
  95. package/dist/detectors/bold-emphasis-form.js.map +1 -0
  96. package/dist/detectors/bold-emphasis.d.ts +0 -1
  97. package/dist/detectors/bold-emphasis.d.ts.map +1 -1
  98. package/dist/detectors/bold-emphasis.js +14 -12
  99. package/dist/detectors/bold-emphasis.js.map +1 -1
  100. package/dist/detectors/bold-label.d.ts +3 -1
  101. package/dist/detectors/bold-label.d.ts.map +1 -1
  102. package/dist/detectors/bold-label.js +16 -6
  103. package/dist/detectors/bold-label.js.map +1 -1
  104. package/dist/detectors/capitalised-term.d.ts.map +1 -1
  105. package/dist/detectors/capitalised-term.js +28 -9
  106. package/dist/detectors/capitalised-term.js.map +1 -1
  107. package/dist/detectors/caps-caption.d.ts +5 -0
  108. package/dist/detectors/caps-caption.d.ts.map +1 -1
  109. package/dist/detectors/caps-caption.js +20 -2
  110. package/dist/detectors/caps-caption.js.map +1 -1
  111. package/dist/detectors/char-shape.d.ts.map +1 -1
  112. package/dist/detectors/char-shape.js +86 -27
  113. package/dist/detectors/char-shape.js.map +1 -1
  114. package/dist/detectors/chat-log-line.d.ts +8 -0
  115. package/dist/detectors/chat-log-line.d.ts.map +1 -0
  116. package/dist/detectors/chat-log-line.js +13 -0
  117. package/dist/detectors/chat-log-line.js.map +1 -0
  118. package/dist/detectors/citation-string.d.ts +9 -0
  119. package/dist/detectors/citation-string.d.ts.map +1 -0
  120. package/dist/detectors/citation-string.js +86 -0
  121. package/dist/detectors/citation-string.js.map +1 -0
  122. package/dist/detectors/closing-cliche.d.ts +18 -0
  123. package/dist/detectors/closing-cliche.d.ts.map +1 -0
  124. package/dist/detectors/closing-cliche.js +58 -0
  125. package/dist/detectors/closing-cliche.js.map +1 -0
  126. package/dist/detectors/closing-exhortation.d.ts +18 -0
  127. package/dist/detectors/closing-exhortation.d.ts.map +1 -0
  128. package/dist/detectors/closing-exhortation.js +55 -0
  129. package/dist/detectors/closing-exhortation.js.map +1 -0
  130. package/dist/detectors/cold-open.d.ts +25 -0
  131. package/dist/detectors/cold-open.d.ts.map +1 -0
  132. package/dist/detectors/cold-open.js +121 -0
  133. package/dist/detectors/cold-open.js.map +1 -0
  134. package/dist/detectors/comparative-context.d.ts +21 -0
  135. package/dist/detectors/comparative-context.d.ts.map +1 -0
  136. package/dist/detectors/comparative-context.js +57 -0
  137. package/dist/detectors/comparative-context.js.map +1 -0
  138. package/dist/detectors/concrete-evidence-density.d.ts +3 -0
  139. package/dist/detectors/concrete-evidence-density.d.ts.map +1 -0
  140. package/dist/detectors/concrete-evidence-density.js +75 -0
  141. package/dist/detectors/concrete-evidence-density.js.map +1 -0
  142. package/dist/detectors/concrete-evidence.d.ts +14 -0
  143. package/dist/detectors/concrete-evidence.d.ts.map +1 -1
  144. package/dist/detectors/concrete-evidence.js +24 -0
  145. package/dist/detectors/concrete-evidence.js.map +1 -1
  146. package/dist/detectors/contraction-emphasis.d.ts +3 -0
  147. package/dist/detectors/contraction-emphasis.d.ts.map +1 -0
  148. package/dist/detectors/contraction-emphasis.js +24 -0
  149. package/dist/detectors/contraction-emphasis.js.map +1 -0
  150. package/dist/detectors/contraction-mention.d.ts +12 -1
  151. package/dist/detectors/contraction-mention.d.ts.map +1 -1
  152. package/dist/detectors/contraction-mention.js +39 -6
  153. package/dist/detectors/contraction-mention.js.map +1 -1
  154. package/dist/detectors/contraction-mix.d.ts +3 -0
  155. package/dist/detectors/contraction-mix.d.ts.map +1 -0
  156. package/dist/detectors/contraction-mix.js +69 -0
  157. package/dist/detectors/contraction-mix.js.map +1 -0
  158. package/dist/detectors/contrast-frame.d.ts +5 -0
  159. package/dist/detectors/contrast-frame.d.ts.map +1 -1
  160. package/dist/detectors/contrast-frame.js +53 -6
  161. package/dist/detectors/contrast-frame.js.map +1 -1
  162. package/dist/detectors/coordinate-adjective.d.ts +2 -1
  163. package/dist/detectors/coordinate-adjective.d.ts.map +1 -1
  164. package/dist/detectors/coordinate-adjective.js +4 -2
  165. package/dist/detectors/coordinate-adjective.js.map +1 -1
  166. package/dist/detectors/date-format.d.ts.map +1 -1
  167. package/dist/detectors/date-format.js +13 -1
  168. package/dist/detectors/date-format.js.map +1 -1
  169. package/dist/detectors/duplicate-definition.d.ts +3 -0
  170. package/dist/detectors/duplicate-definition.d.ts.map +1 -0
  171. package/dist/detectors/duplicate-definition.js +16 -0
  172. package/dist/detectors/duplicate-definition.js.map +1 -0
  173. package/dist/detectors/duplicate-heading.d.ts +4 -2
  174. package/dist/detectors/duplicate-heading.d.ts.map +1 -1
  175. package/dist/detectors/duplicate-heading.js +35 -11
  176. package/dist/detectors/duplicate-heading.js.map +1 -1
  177. package/dist/detectors/email-frame-words.d.ts +10 -0
  178. package/dist/detectors/email-frame-words.d.ts.map +1 -0
  179. package/dist/detectors/email-frame-words.js +34 -0
  180. package/dist/detectors/email-frame-words.js.map +1 -0
  181. package/dist/detectors/email-letter.d.ts +3 -7
  182. package/dist/detectors/email-letter.d.ts.map +1 -1
  183. package/dist/detectors/email-letter.js +13 -21
  184. package/dist/detectors/email-letter.js.map +1 -1
  185. package/dist/detectors/final-period-captions.d.ts +15 -0
  186. package/dist/detectors/final-period-captions.d.ts.map +1 -0
  187. package/dist/detectors/final-period-captions.js +61 -0
  188. package/dist/detectors/final-period-captions.js.map +1 -0
  189. package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
  190. package/dist/detectors/fullwidth-alnum.js +20 -4
  191. package/dist/detectors/fullwidth-alnum.js.map +1 -1
  192. package/dist/detectors/gram-furniture.d.ts +18 -1
  193. package/dist/detectors/gram-furniture.d.ts.map +1 -1
  194. package/dist/detectors/gram-furniture.js +71 -0
  195. package/dist/detectors/gram-furniture.js.map +1 -1
  196. package/dist/detectors/gram-openers.d.ts +16 -0
  197. package/dist/detectors/gram-openers.d.ts.map +1 -1
  198. package/dist/detectors/gram-openers.js +52 -0
  199. package/dist/detectors/gram-openers.js.map +1 -1
  200. package/dist/detectors/gram-predicate.d.ts.map +1 -1
  201. package/dist/detectors/gram-predicate.js +40 -7
  202. package/dist/detectors/gram-predicate.js.map +1 -1
  203. package/dist/detectors/gram-repetition.d.ts +3 -0
  204. package/dist/detectors/gram-repetition.d.ts.map +1 -0
  205. package/dist/detectors/gram-repetition.js +158 -0
  206. package/dist/detectors/gram-repetition.js.map +1 -0
  207. package/dist/detectors/heading-level-skip.d.ts +6 -0
  208. package/dist/detectors/heading-level-skip.d.ts.map +1 -1
  209. package/dist/detectors/heading-level-skip.js +24 -1
  210. package/dist/detectors/heading-level-skip.js.map +1 -1
  211. package/dist/detectors/heading-numbering.js +2 -2
  212. package/dist/detectors/heading-numbering.js.map +1 -1
  213. package/dist/detectors/heading-sentences.d.ts +10 -0
  214. package/dist/detectors/heading-sentences.d.ts.map +1 -0
  215. package/dist/detectors/heading-sentences.js +32 -0
  216. package/dist/detectors/heading-sentences.js.map +1 -0
  217. package/dist/detectors/hyphen-copied-text.d.ts +3 -0
  218. package/dist/detectors/hyphen-copied-text.d.ts.map +1 -0
  219. package/dist/detectors/hyphen-copied-text.js +49 -0
  220. package/dist/detectors/hyphen-copied-text.js.map +1 -0
  221. package/dist/detectors/kanji-name-edge.d.ts +15 -0
  222. package/dist/detectors/kanji-name-edge.d.ts.map +1 -1
  223. package/dist/detectors/kanji-name-edge.js +30 -0
  224. package/dist/detectors/kanji-name-edge.js.map +1 -1
  225. package/dist/detectors/kanji-run-pieces.d.ts +7 -0
  226. package/dist/detectors/kanji-run-pieces.d.ts.map +1 -1
  227. package/dist/detectors/kanji-run-pieces.js +14 -4
  228. package/dist/detectors/kanji-run-pieces.js.map +1 -1
  229. package/dist/detectors/kutoten-consistency.d.ts.map +1 -1
  230. package/dist/detectors/kutoten-consistency.js +22 -4
  231. package/dist/detectors/kutoten-consistency.js.map +1 -1
  232. package/dist/detectors/lead-in-dash.d.ts +5 -0
  233. package/dist/detectors/lead-in-dash.d.ts.map +1 -1
  234. package/dist/detectors/lead-in-dash.js +9 -0
  235. package/dist/detectors/lead-in-dash.js.map +1 -1
  236. package/dist/detectors/letter-joined-name.d.ts +2 -0
  237. package/dist/detectors/letter-joined-name.d.ts.map +1 -1
  238. package/dist/detectors/letter-joined-name.js +8 -0
  239. package/dist/detectors/letter-joined-name.js.map +1 -1
  240. package/dist/detectors/lexicon.d.ts +1 -2
  241. package/dist/detectors/lexicon.d.ts.map +1 -1
  242. package/dist/detectors/lexicon.js +16 -57
  243. package/dist/detectors/lexicon.js.map +1 -1
  244. package/dist/detectors/list-item.d.ts +14 -0
  245. package/dist/detectors/list-item.d.ts.map +1 -1
  246. package/dist/detectors/list-item.js +30 -1
  247. package/dist/detectors/list-item.js.map +1 -1
  248. package/dist/detectors/list-items.d.ts +1 -1
  249. package/dist/detectors/list-items.d.ts.map +1 -1
  250. package/dist/detectors/list-items.js +2 -0
  251. package/dist/detectors/list-items.js.map +1 -1
  252. package/dist/detectors/list-joint.d.ts +18 -0
  253. package/dist/detectors/list-joint.d.ts.map +1 -0
  254. package/dist/detectors/list-joint.js +42 -0
  255. package/dist/detectors/list-joint.js.map +1 -0
  256. package/dist/detectors/list-layout.d.ts +14 -0
  257. package/dist/detectors/list-layout.d.ts.map +1 -0
  258. package/dist/detectors/list-layout.js +29 -0
  259. package/dist/detectors/list-layout.js.map +1 -0
  260. package/dist/detectors/list-lead-in.d.ts +7 -2
  261. package/dist/detectors/list-lead-in.d.ts.map +1 -1
  262. package/dist/detectors/list-lead-in.js +67 -6
  263. package/dist/detectors/list-lead-in.js.map +1 -1
  264. package/dist/detectors/list-parallel.d.ts +6 -0
  265. package/dist/detectors/list-parallel.d.ts.map +1 -1
  266. package/dist/detectors/list-parallel.js +106 -13
  267. package/dist/detectors/list-parallel.js.map +1 -1
  268. package/dist/detectors/list-run.d.ts +13 -0
  269. package/dist/detectors/list-run.d.ts.map +1 -0
  270. package/dist/detectors/list-run.js +80 -0
  271. package/dist/detectors/list-run.js.map +1 -0
  272. package/dist/detectors/list-sentence.d.ts +11 -0
  273. package/dist/detectors/list-sentence.d.ts.map +1 -1
  274. package/dist/detectors/list-sentence.js +1 -0
  275. package/dist/detectors/list-sentence.js.map +1 -1
  276. package/dist/detectors/mark-shape.d.ts +2 -1
  277. package/dist/detectors/mark-shape.d.ts.map +1 -1
  278. package/dist/detectors/mark-shape.js +10 -6
  279. package/dist/detectors/mark-shape.js.map +1 -1
  280. package/dist/detectors/missing-final-period.d.ts.map +1 -1
  281. package/dist/detectors/missing-final-period.js +3 -1
  282. package/dist/detectors/missing-final-period.js.map +1 -1
  283. package/dist/detectors/name-run.d.ts +2 -0
  284. package/dist/detectors/name-run.d.ts.map +1 -1
  285. package/dist/detectors/name-run.js +1 -1
  286. package/dist/detectors/name-run.js.map +1 -1
  287. package/dist/detectors/name-variant-two-things.d.ts +18 -0
  288. package/dist/detectors/name-variant-two-things.d.ts.map +1 -0
  289. package/dist/detectors/name-variant-two-things.js +84 -0
  290. package/dist/detectors/name-variant-two-things.js.map +1 -0
  291. package/dist/detectors/name-variant.d.ts.map +1 -1
  292. package/dist/detectors/name-variant.js +14 -15
  293. package/dist/detectors/name-variant.js.map +1 -1
  294. package/dist/detectors/numbering-readings.d.ts +2 -2
  295. package/dist/detectors/numbering-readings.d.ts.map +1 -1
  296. package/dist/detectors/numbering-readings.js +7 -0
  297. package/dist/detectors/numbering-readings.js.map +1 -1
  298. package/dist/detectors/open-end-anaphor.d.ts +8 -0
  299. package/dist/detectors/open-end-anaphor.d.ts.map +1 -0
  300. package/dist/detectors/open-end-anaphor.js +22 -0
  301. package/dist/detectors/open-end-anaphor.js.map +1 -0
  302. package/dist/detectors/open-end-lead.d.ts +4 -0
  303. package/dist/detectors/open-end-lead.d.ts.map +1 -0
  304. package/dist/detectors/open-end-lead.js +34 -0
  305. package/dist/detectors/open-end-lead.js.map +1 -0
  306. package/dist/detectors/open-end-scope.d.ts.map +1 -1
  307. package/dist/detectors/open-end-scope.js +7 -1
  308. package/dist/detectors/open-end-scope.js.map +1 -1
  309. package/dist/detectors/ordinal-run-gaps.d.ts +1 -0
  310. package/dist/detectors/ordinal-run-gaps.d.ts.map +1 -1
  311. package/dist/detectors/ordinal-run-gaps.js +1 -1
  312. package/dist/detectors/ordinal-run-gaps.js.map +1 -1
  313. package/dist/detectors/organisation-run.d.ts +6 -0
  314. package/dist/detectors/organisation-run.d.ts.map +1 -1
  315. package/dist/detectors/organisation-run.js +26 -2
  316. package/dist/detectors/organisation-run.js.map +1 -1
  317. package/dist/detectors/orthographic-variant-open.d.ts +37 -0
  318. package/dist/detectors/orthographic-variant-open.d.ts.map +1 -0
  319. package/dist/detectors/orthographic-variant-open.js +81 -0
  320. package/dist/detectors/orthographic-variant-open.js.map +1 -0
  321. package/dist/detectors/orthographic-variant.d.ts.map +1 -1
  322. package/dist/detectors/orthographic-variant.js +55 -59
  323. package/dist/detectors/orthographic-variant.js.map +1 -1
  324. package/dist/detectors/orthography.d.ts.map +1 -1
  325. package/dist/detectors/orthography.js +14 -5
  326. package/dist/detectors/orthography.js.map +1 -1
  327. package/dist/detectors/over-general-claim.d.ts.map +1 -1
  328. package/dist/detectors/over-general-claim.js +82 -4
  329. package/dist/detectors/over-general-claim.js.map +1 -1
  330. package/dist/detectors/oxford-comma.d.ts.map +1 -1
  331. package/dist/detectors/oxford-comma.js +61 -27
  332. package/dist/detectors/oxford-comma.js.map +1 -1
  333. package/dist/detectors/particle-run-names.d.ts +8 -0
  334. package/dist/detectors/particle-run-names.d.ts.map +1 -0
  335. package/dist/detectors/particle-run-names.js +17 -0
  336. package/dist/detectors/particle-run-names.js.map +1 -0
  337. package/dist/detectors/placeholder-text.d.ts.map +1 -1
  338. package/dist/detectors/placeholder-text.js +14 -2
  339. package/dist/detectors/placeholder-text.js.map +1 -1
  340. package/dist/detectors/proper-noun-density.d.ts +13 -0
  341. package/dist/detectors/proper-noun-density.d.ts.map +1 -0
  342. package/dist/detectors/proper-noun-density.js +97 -0
  343. package/dist/detectors/proper-noun-density.js.map +1 -0
  344. package/dist/detectors/quote-without-source.d.ts +6 -2
  345. package/dist/detectors/quote-without-source.d.ts.map +1 -1
  346. package/dist/detectors/quote-without-source.js +33 -8
  347. package/dist/detectors/quote-without-source.js.map +1 -1
  348. package/dist/detectors/quoted-excerpt.d.ts +13 -0
  349. package/dist/detectors/quoted-excerpt.d.ts.map +1 -0
  350. package/dist/detectors/quoted-excerpt.js +53 -0
  351. package/dist/detectors/quoted-excerpt.js.map +1 -0
  352. package/dist/detectors/reference-entry.d.ts +7 -0
  353. package/dist/detectors/reference-entry.d.ts.map +1 -0
  354. package/dist/detectors/reference-entry.js +35 -0
  355. package/dist/detectors/reference-entry.js.map +1 -0
  356. package/dist/detectors/register-neutral-shape.d.ts +5 -2
  357. package/dist/detectors/register-neutral-shape.d.ts.map +1 -1
  358. package/dist/detectors/register-neutral-shape.js +21 -4
  359. package/dist/detectors/register-neutral-shape.js.map +1 -1
  360. package/dist/detectors/register-separate-part.d.ts +7 -0
  361. package/dist/detectors/register-separate-part.d.ts.map +1 -0
  362. package/dist/detectors/register-separate-part.js +32 -0
  363. package/dist/detectors/register-separate-part.js.map +1 -0
  364. package/dist/detectors/register-set-apart.d.ts +24 -0
  365. package/dist/detectors/register-set-apart.d.ts.map +1 -0
  366. package/dist/detectors/register-set-apart.js +102 -0
  367. package/dist/detectors/register-set-apart.js.map +1 -0
  368. package/dist/detectors/register-voice.d.ts +14 -0
  369. package/dist/detectors/register-voice.d.ts.map +1 -0
  370. package/dist/detectors/register-voice.js +47 -0
  371. package/dist/detectors/register-voice.js.map +1 -0
  372. package/dist/detectors/register.d.ts +5 -0
  373. package/dist/detectors/register.d.ts.map +1 -1
  374. package/dist/detectors/register.js +13 -0
  375. package/dist/detectors/register.js.map +1 -1
  376. package/dist/detectors/registry/closing-cliche.d.ts +3 -0
  377. package/dist/detectors/registry/closing-cliche.d.ts.map +1 -0
  378. package/dist/detectors/registry/closing-cliche.js +3 -0
  379. package/dist/detectors/registry/closing-cliche.js.map +1 -0
  380. package/dist/detectors/registry/closing-exhortation.d.ts +3 -0
  381. package/dist/detectors/registry/closing-exhortation.d.ts.map +1 -0
  382. package/dist/detectors/registry/closing-exhortation.js +3 -0
  383. package/dist/detectors/registry/closing-exhortation.js.map +1 -0
  384. package/dist/detectors/registry/cold-open.d.ts +3 -0
  385. package/dist/detectors/registry/cold-open.d.ts.map +1 -0
  386. package/dist/detectors/registry/cold-open.js +3 -0
  387. package/dist/detectors/registry/cold-open.js.map +1 -0
  388. package/dist/detectors/registry/colon-lead-in.js +1 -1
  389. package/dist/detectors/registry/colon-lead-in.js.map +1 -1
  390. package/dist/detectors/registry/concrete-evidence.js +1 -1
  391. package/dist/detectors/registry/concrete-evidence.js.map +1 -1
  392. package/dist/detectors/registry/contraction-mix.js +1 -1
  393. package/dist/detectors/registry/contraction-mix.js.map +1 -1
  394. package/dist/detectors/registry/duplicate-definition.js +1 -1
  395. package/dist/detectors/registry/duplicate-definition.js.map +1 -1
  396. package/dist/detectors/registry/ngram-repetition.js +1 -1
  397. package/dist/detectors/registry/ngram-repetition.js.map +1 -1
  398. package/dist/detectors/registry/proper-noun-density.js +1 -1
  399. package/dist/detectors/registry/proper-noun-density.js.map +1 -1
  400. package/dist/detectors/registry/topic-predicate-distance.js +1 -1
  401. package/dist/detectors/registry/topic-predicate-distance.js.map +1 -1
  402. package/dist/detectors/registry/unprompted-denial.d.ts +3 -0
  403. package/dist/detectors/registry/unprompted-denial.d.ts.map +1 -0
  404. package/dist/detectors/registry/unprompted-denial.js +3 -0
  405. package/dist/detectors/registry/unprompted-denial.js.map +1 -0
  406. package/dist/detectors/reproduced-text.d.ts +5 -0
  407. package/dist/detectors/reproduced-text.d.ts.map +1 -0
  408. package/dist/detectors/reproduced-text.js +19 -0
  409. package/dist/detectors/reproduced-text.js.map +1 -0
  410. package/dist/detectors/request-owner.d.ts +2 -1
  411. package/dist/detectors/request-owner.d.ts.map +1 -1
  412. package/dist/detectors/request-owner.js +31 -7
  413. package/dist/detectors/request-owner.js.map +1 -1
  414. package/dist/detectors/requirement-smell.d.ts.map +1 -1
  415. package/dist/detectors/requirement-smell.js +16 -5
  416. package/dist/detectors/requirement-smell.js.map +1 -1
  417. package/dist/detectors/sentence-counts.d.ts +2 -1
  418. package/dist/detectors/sentence-counts.d.ts.map +1 -1
  419. package/dist/detectors/sentence-counts.js +23 -7
  420. package/dist/detectors/sentence-counts.js.map +1 -1
  421. package/dist/detectors/sentence-ending.d.ts +7 -1
  422. package/dist/detectors/sentence-ending.d.ts.map +1 -1
  423. package/dist/detectors/sentence-ending.js +47 -11
  424. package/dist/detectors/sentence-ending.js.map +1 -1
  425. package/dist/detectors/sentence-length.d.ts.map +1 -1
  426. package/dist/detectors/sentence-length.js +37 -12
  427. package/dist/detectors/sentence-length.js.map +1 -1
  428. package/dist/detectors/sentence-load.d.ts +5 -3
  429. package/dist/detectors/sentence-load.d.ts.map +1 -1
  430. package/dist/detectors/sentence-load.js +3 -5
  431. package/dist/detectors/sentence-load.js.map +1 -1
  432. package/dist/detectors/sentence-parts.d.ts +11 -0
  433. package/dist/detectors/sentence-parts.d.ts.map +1 -0
  434. package/dist/detectors/sentence-parts.js +64 -0
  435. package/dist/detectors/sentence-parts.js.map +1 -0
  436. package/dist/detectors/sentence-title.d.ts +3 -0
  437. package/dist/detectors/sentence-title.d.ts.map +1 -1
  438. package/dist/detectors/sentence-title.js +10 -0
  439. package/dist/detectors/sentence-title.js.map +1 -1
  440. package/dist/detectors/signals.d.ts +0 -2
  441. package/dist/detectors/signals.d.ts.map +1 -1
  442. package/dist/detectors/signals.js +18 -167
  443. package/dist/detectors/signals.js.map +1 -1
  444. package/dist/detectors/spelling-variety.d.ts.map +1 -1
  445. package/dist/detectors/spelling-variety.js +20 -2
  446. package/dist/detectors/spelling-variety.js.map +1 -1
  447. package/dist/detectors/structure-tree.d.ts +2 -1
  448. package/dist/detectors/structure-tree.d.ts.map +1 -1
  449. package/dist/detectors/structure-tree.js +3 -8
  450. package/dist/detectors/structure-tree.js.map +1 -1
  451. package/dist/detectors/structure.d.ts +9 -1
  452. package/dist/detectors/structure.d.ts.map +1 -1
  453. package/dist/detectors/structure.js +43 -16
  454. package/dist/detectors/structure.js.map +1 -1
  455. package/dist/detectors/superlative-clause.d.ts.map +1 -1
  456. package/dist/detectors/superlative-clause.js +19 -2
  457. package/dist/detectors/superlative-clause.js.map +1 -1
  458. package/dist/detectors/superlative-context.d.ts +35 -0
  459. package/dist/detectors/superlative-context.d.ts.map +1 -0
  460. package/dist/detectors/superlative-context.js +71 -0
  461. package/dist/detectors/superlative-context.js.map +1 -0
  462. package/dist/detectors/superlative-scope.d.ts +6 -2
  463. package/dist/detectors/superlative-scope.d.ts.map +1 -1
  464. package/dist/detectors/superlative-scope.js +20 -6
  465. package/dist/detectors/superlative-scope.js.map +1 -1
  466. package/dist/detectors/team.d.ts +0 -1
  467. package/dist/detectors/team.d.ts.map +1 -1
  468. package/dist/detectors/team.js +0 -46
  469. package/dist/detectors/team.js.map +1 -1
  470. package/dist/detectors/titled-code-citation.d.ts +12 -0
  471. package/dist/detectors/titled-code-citation.d.ts.map +1 -0
  472. package/dist/detectors/titled-code-citation.js +11 -0
  473. package/dist/detectors/titled-code-citation.js.map +1 -0
  474. package/dist/detectors/titled-run.d.ts +8 -1
  475. package/dist/detectors/titled-run.d.ts.map +1 -1
  476. package/dist/detectors/titled-run.js +14 -4
  477. package/dist/detectors/titled-run.js.map +1 -1
  478. package/dist/detectors/token-shape.d.ts.map +1 -1
  479. package/dist/detectors/token-shape.js +33 -16
  480. package/dist/detectors/token-shape.js.map +1 -1
  481. package/dist/detectors/topic-predicate-distance.d.ts +4 -0
  482. package/dist/detectors/topic-predicate-distance.d.ts.map +1 -0
  483. package/dist/detectors/topic-predicate-distance.js +22 -0
  484. package/dist/detectors/topic-predicate-distance.js.map +1 -0
  485. package/dist/detectors/undefined-term.d.ts +5 -0
  486. package/dist/detectors/undefined-term.d.ts.map +1 -1
  487. package/dist/detectors/undefined-term.js +22 -1
  488. package/dist/detectors/undefined-term.js.map +1 -1
  489. package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
  490. package/dist/detectors/unfilled-placeholder.js +15 -1
  491. package/dist/detectors/unfilled-placeholder.js.map +1 -1
  492. package/dist/detectors/unknown-word-context.d.ts +35 -0
  493. package/dist/detectors/unknown-word-context.d.ts.map +1 -0
  494. package/dist/detectors/unknown-word-context.js +100 -0
  495. package/dist/detectors/unknown-word-context.js.map +1 -0
  496. package/dist/detectors/unknown-word.d.ts +0 -5
  497. package/dist/detectors/unknown-word.d.ts.map +1 -1
  498. package/dist/detectors/unknown-word.js +17 -19
  499. package/dist/detectors/unknown-word.js.map +1 -1
  500. package/dist/detectors/unprompted-denial.d.ts +25 -0
  501. package/dist/detectors/unprompted-denial.d.ts.map +1 -0
  502. package/dist/detectors/unprompted-denial.js +100 -0
  503. package/dist/detectors/unprompted-denial.js.map +1 -0
  504. package/dist/document-sections.d.ts.map +1 -1
  505. package/dist/document-sections.js +3 -1
  506. package/dist/document-sections.js.map +1 -1
  507. package/dist/fix-plan/all-signs.d.ts +17 -0
  508. package/dist/fix-plan/all-signs.d.ts.map +1 -0
  509. package/dist/fix-plan/all-signs.js +26 -0
  510. package/dist/fix-plan/all-signs.js.map +1 -0
  511. package/dist/fix-plan/plan.d.ts +31 -0
  512. package/dist/fix-plan/plan.d.ts.map +1 -1
  513. package/dist/fix-plan/plan.js +23 -3
  514. package/dist/fix-plan/plan.js.map +1 -1
  515. package/dist/fix-plan/render.d.ts.map +1 -1
  516. package/dist/fix-plan/render.js +31 -2
  517. package/dist/fix-plan/render.js.map +1 -1
  518. package/dist/fix-plan/risen.d.ts +10 -0
  519. package/dist/fix-plan/risen.d.ts.map +1 -0
  520. package/dist/fix-plan/risen.js +7 -0
  521. package/dist/fix-plan/risen.js.map +1 -0
  522. package/dist/fix-plan/text.d.ts +15 -0
  523. package/dist/fix-plan/text.d.ts.map +1 -1
  524. package/dist/fix-plan/text.js +38 -2
  525. package/dist/fix-plan/text.js.map +1 -1
  526. package/dist/heading-numbering.d.ts +2 -1
  527. package/dist/heading-numbering.d.ts.map +1 -1
  528. package/dist/heading-numbering.js +40 -10
  529. package/dist/heading-numbering.js.map +1 -1
  530. package/dist/html/html-site-chrome.d.ts.map +1 -1
  531. package/dist/html/html-site-chrome.js +7 -2
  532. package/dist/html/html-site-chrome.js.map +1 -1
  533. package/dist/latin-spacing-source.d.ts +12 -0
  534. package/dist/latin-spacing-source.d.ts.map +1 -0
  535. package/dist/latin-spacing-source.js +25 -0
  536. package/dist/latin-spacing-source.js.map +1 -0
  537. package/dist/law-title.d.ts +7 -0
  538. package/dist/law-title.d.ts.map +1 -0
  539. package/dist/law-title.js +29 -0
  540. package/dist/law-title.js.map +1 -0
  541. package/dist/name-ending-run.d.ts +11 -0
  542. package/dist/name-ending-run.d.ts.map +1 -0
  543. package/dist/name-ending-run.js +37 -0
  544. package/dist/name-ending-run.js.map +1 -0
  545. package/dist/name-separator.d.ts.map +1 -1
  546. package/dist/name-separator.js +4 -1
  547. package/dist/name-separator.js.map +1 -1
  548. package/dist/name-title-slip.d.ts +11 -0
  549. package/dist/name-title-slip.d.ts.map +1 -0
  550. package/dist/name-title-slip.js +51 -0
  551. package/dist/name-title-slip.js.map +1 -0
  552. package/dist/name-variant-shapes.d.ts +14 -0
  553. package/dist/name-variant-shapes.d.ts.map +1 -0
  554. package/dist/name-variant-shapes.js +43 -0
  555. package/dist/name-variant-shapes.js.map +1 -0
  556. package/dist/name-word-use.d.ts +5 -0
  557. package/dist/name-word-use.d.ts.map +1 -0
  558. package/dist/name-word-use.js +12 -0
  559. package/dist/name-word-use.js.map +1 -0
  560. package/dist/opening-passage.d.ts +8 -0
  561. package/dist/opening-passage.d.ts.map +1 -0
  562. package/dist/opening-passage.js +24 -0
  563. package/dist/opening-passage.js.map +1 -0
  564. package/dist/paragraph-length.d.ts +14 -0
  565. package/dist/paragraph-length.d.ts.map +1 -1
  566. package/dist/paragraph-length.js +25 -0
  567. package/dist/paragraph-length.js.map +1 -1
  568. package/dist/paragraph-runs.d.ts +2 -2
  569. package/dist/paragraph-runs.d.ts.map +1 -1
  570. package/dist/paragraph-runs.js +65 -14
  571. package/dist/paragraph-runs.js.map +1 -1
  572. package/dist/plugin.d.ts +2 -0
  573. package/dist/plugin.d.ts.map +1 -1
  574. package/dist/quote-echo.d.ts +6 -0
  575. package/dist/quote-echo.d.ts.map +1 -0
  576. package/dist/quote-echo.js +14 -0
  577. package/dist/quote-echo.js.map +1 -0
  578. package/dist/quote-gloss.d.ts +4 -0
  579. package/dist/quote-gloss.d.ts.map +1 -0
  580. package/dist/quote-gloss.js +7 -0
  581. package/dist/quote-gloss.js.map +1 -0
  582. package/dist/quoted-spelling.d.ts +17 -0
  583. package/dist/quoted-spelling.d.ts.map +1 -0
  584. package/dist/quoted-spelling.js +27 -0
  585. package/dist/quoted-spelling.js.map +1 -0
  586. package/dist/render/semantic.d.ts +1 -1
  587. package/dist/render/semantic.d.ts.map +1 -1
  588. package/dist/render/semantic.js +2 -1
  589. package/dist/render/semantic.js.map +1 -1
  590. package/dist/rule-of-three.d.ts +19 -0
  591. package/dist/rule-of-three.d.ts.map +1 -0
  592. package/dist/rule-of-three.js +33 -0
  593. package/dist/rule-of-three.js.map +1 -0
  594. package/dist/run-semantic.d.ts.map +1 -1
  595. package/dist/run-semantic.js +2 -2
  596. package/dist/run-semantic.js.map +1 -1
  597. package/dist/section-levels.d.ts +18 -0
  598. package/dist/section-levels.d.ts.map +1 -0
  599. package/dist/section-levels.js +80 -0
  600. package/dist/section-levels.js.map +1 -0
  601. package/dist/semantic.d.ts +2 -0
  602. package/dist/semantic.d.ts.map +1 -1
  603. package/dist/semantic.js +15 -2
  604. package/dist/semantic.js.map +1 -1
  605. package/dist/sentence-load.d.ts +2 -1
  606. package/dist/sentence-load.d.ts.map +1 -1
  607. package/dist/sentence-load.js +4 -2
  608. package/dist/sentence-load.js.map +1 -1
  609. package/dist/set-phrase-particles.d.ts +4 -0
  610. package/dist/set-phrase-particles.d.ts.map +1 -0
  611. package/dist/set-phrase-particles.js +26 -0
  612. package/dist/set-phrase-particles.js.map +1 -0
  613. package/dist/spelling.d.ts +11 -0
  614. package/dist/spelling.d.ts.map +1 -1
  615. package/dist/spelling.js +19 -5
  616. package/dist/spelling.js.map +1 -1
  617. package/dist/structure/alternative-clause.d.ts +7 -0
  618. package/dist/structure/alternative-clause.d.ts.map +1 -1
  619. package/dist/structure/alternative-clause.js +23 -8
  620. package/dist/structure/alternative-clause.js.map +1 -1
  621. package/dist/structure/cited-document-section.d.ts +2 -0
  622. package/dist/structure/cited-document-section.d.ts.map +1 -1
  623. package/dist/structure/cited-document-section.js +23 -1
  624. package/dist/structure/cited-document-section.js.map +1 -1
  625. package/dist/structure/issues.d.ts +4 -2
  626. package/dist/structure/issues.d.ts.map +1 -1
  627. package/dist/structure/issues.js +17 -9
  628. package/dist/structure/issues.js.map +1 -1
  629. package/dist/structure/numbering.d.ts +10 -1
  630. package/dist/structure/numbering.d.ts.map +1 -1
  631. package/dist/structure/numbering.js +41 -4
  632. package/dist/structure/numbering.js.map +1 -1
  633. package/dist/structure/unread-label.d.ts +13 -0
  634. package/dist/structure/unread-label.d.ts.map +1 -0
  635. package/dist/structure/unread-label.js +70 -0
  636. package/dist/structure/unread-label.js.map +1 -0
  637. package/dist/structure-shape/template-outline.d.ts +11 -0
  638. package/dist/structure-shape/template-outline.d.ts.map +1 -0
  639. package/dist/structure-shape/template-outline.js +25 -0
  640. package/dist/structure-shape/template-outline.js.map +1 -0
  641. package/dist/title-case-name.d.ts +12 -0
  642. package/dist/title-case-name.d.ts.map +1 -0
  643. package/dist/title-case-name.js +37 -0
  644. package/dist/title-case-name.js.map +1 -0
  645. package/dist/topic-clause.d.ts +6 -1
  646. package/dist/topic-clause.d.ts.map +1 -1
  647. package/dist/topic-clause.js +90 -3
  648. package/dist/topic-clause.js.map +1 -1
  649. package/dist/word-use.d.ts +12 -4
  650. package/dist/word-use.d.ts.map +1 -1
  651. package/dist/word-use.js +47 -5
  652. package/dist/word-use.js.map +1 -1
  653. package/package.json +4 -3
  654. package/rules/ai-generated-composite.yaml +12 -3
  655. package/rules/ai-structure.yaml +7 -6
  656. package/rules/ai-tell.yaml +10 -6
  657. package/rules/all-caps-shouting.yaml +2 -2
  658. package/rules/bold-emphasis.yaml +5 -4
  659. package/rules/bold-label-list.yaml +6 -6
  660. package/rules/closing-cliche.yaml +4 -5
  661. package/rules/closing-exhortation.yaml +74 -0
  662. package/rules/cold-open.yaml +95 -0
  663. package/rules/colon-lead-in.yaml +68 -10
  664. package/rules/comparative-without-baseline.yaml +2 -2
  665. package/rules/concrete-evidence-density.yaml +2 -2
  666. package/rules/contraction-consistency.yaml +2 -2
  667. package/rules/contrast-framing.yaml +16 -13
  668. package/rules/dangling-reference.yaml +2 -2
  669. package/rules/date-format-consistency.yaml +2 -2
  670. package/rules/duplicate-definition.yaml +2 -2
  671. package/rules/duplicate-heading.yaml +5 -2
  672. package/rules/email-greeting-closing.yaml +2 -2
  673. package/rules/email-stock-courtesy.yaml +62 -0
  674. package/rules/fullwidth-alnum-consistency.yaml +2 -2
  675. package/rules/generic-opening.yaml +63 -0
  676. package/rules/heading-level-skip.yaml +2 -2
  677. package/rules/heading-numbering-mix.yaml +20 -20
  678. package/rules/honesty-marker.yaml +84 -0
  679. package/rules/hyphen-as-dash.yaml +2 -2
  680. package/rules/kutoten-consistency.yaml +4 -4
  681. package/rules/latin-spacing.yaml +6 -4
  682. package/rules/list-item-form-mix.yaml +2 -2
  683. package/rules/max-kanji-continuous.yaml +7 -3
  684. package/rules/max-paragraph-length.yaml +2 -2
  685. package/rules/max-sentence-length.yaml +6 -2
  686. package/rules/missing-final-period.yaml +2 -2
  687. package/rules/name-variant.yaml +5 -2
  688. package/rules/ngram-repetition.yaml +2 -2
  689. package/rules/no-doubled-joshi.yaml +2 -2
  690. package/rules/no-em-dash.yaml +2 -2
  691. package/rules/no-mixed-desumasu.yaml +16 -3
  692. package/rules/nominalization.yaml +1 -1
  693. package/rules/numbering-gap.yaml +2 -2
  694. package/rules/one-sentence-paragraph-run.yaml +2 -2
  695. package/rules/orthographic-variant.yaml +2 -2
  696. package/rules/over-general-claim.yaml +2 -2
  697. package/rules/oxford-comma-consistency.yaml +15 -3
  698. package/rules/proper-noun-density.yaml +14 -7
  699. package/rules/quote-without-source.yaml +2 -2
  700. package/rules/request-without-deadline.yaml +2 -2
  701. package/rules/requirement-smell.yaml +2 -2
  702. package/rules/rule-of-three.yaml +3 -3
  703. package/rules/section-length-uniformity.yaml +2 -2
  704. package/rules/spelling-consistency.yaml +4 -4
  705. package/rules/teki-overuse.yaml +2 -2
  706. package/rules/topic-predicate-distance.yaml +3 -2
  707. package/rules/undefined-acronym.yaml +9 -2
  708. package/rules/undefined-term.yaml +2 -2
  709. package/rules/unfilled-placeholder.yaml +2 -2
  710. package/rules/unknown-word.yaml +2 -2
  711. package/rules/unprompted-denial.yaml +88 -0
  712. package/rules/unqualified-superlative.yaml +8 -2
  713. package/skills/chaff/SKILL.md +39 -6
  714. package/src/acronym-expansion.ts +57 -0
  715. package/src/ai-score/human-shares.ts +54 -12
  716. package/src/ai-score/of-document.ts +5 -2
  717. package/src/alternative-words.ts +15 -0
  718. package/src/body-section.ts +11 -2
  719. package/src/capitals-with-small.ts +16 -0
  720. package/src/checks.ts +32 -1
  721. package/src/cli-args.ts +1 -1
  722. package/src/cli-text.ts +4 -0
  723. package/src/closing-code.ts +21 -0
  724. package/src/commands/fix-plan.ts +72 -5
  725. package/src/commands/test.ts +18 -2
  726. package/src/date-format.ts +54 -7
  727. package/src/detectors/acronym-context.ts +23 -4
  728. package/src/detectors/acronym-expansion.ts +26 -0
  729. package/src/detectors/acronym-gloss.ts +123 -0
  730. package/src/detectors/acronym-mention.ts +17 -0
  731. package/src/detectors/acronym-name.ts +40 -3
  732. package/src/detectors/acronym-series.ts +27 -0
  733. package/src/detectors/ai-phrasing.ts +18 -17
  734. package/src/detectors/ai-structure.ts +23 -6
  735. package/src/detectors/alnum-number.ts +8 -3
  736. package/src/detectors/bare-comparative.ts +41 -13
  737. package/src/detectors/blank-runs.ts +30 -0
  738. package/src/detectors/bold-emphasis-form.ts +58 -0
  739. package/src/detectors/bold-emphasis.ts +16 -17
  740. package/src/detectors/bold-label.ts +22 -6
  741. package/src/detectors/capitalised-term.ts +36 -9
  742. package/src/detectors/caps-caption.ts +24 -2
  743. package/src/detectors/char-shape.ts +118 -29
  744. package/src/detectors/chat-log-line.ts +17 -0
  745. package/src/detectors/citation-string.ts +93 -0
  746. package/src/detectors/closing-cliche.ts +74 -0
  747. package/src/detectors/closing-exhortation.ts +74 -0
  748. package/src/detectors/cold-open.ts +145 -0
  749. package/src/detectors/comparative-context.ts +74 -0
  750. package/src/detectors/concrete-evidence-density.ts +99 -0
  751. package/src/detectors/concrete-evidence.ts +40 -0
  752. package/src/detectors/contraction-emphasis.ts +46 -0
  753. package/src/detectors/contraction-mention.ts +52 -6
  754. package/src/detectors/contraction-mix.ts +94 -0
  755. package/src/detectors/contrast-frame.ts +65 -7
  756. package/src/detectors/coordinate-adjective.ts +4 -2
  757. package/src/detectors/date-format.ts +18 -2
  758. package/src/detectors/duplicate-definition.ts +21 -0
  759. package/src/detectors/duplicate-heading.ts +44 -15
  760. package/src/detectors/email-frame-words.ts +39 -0
  761. package/src/detectors/email-letter.ts +15 -20
  762. package/src/detectors/final-period-captions.ts +78 -0
  763. package/src/detectors/fullwidth-alnum.ts +24 -4
  764. package/src/detectors/gram-furniture.ts +87 -1
  765. package/src/detectors/gram-openers.ts +71 -0
  766. package/src/detectors/gram-predicate.ts +49 -6
  767. package/src/detectors/gram-repetition.ts +199 -0
  768. package/src/detectors/heading-level-skip.ts +31 -1
  769. package/src/detectors/heading-numbering.ts +2 -2
  770. package/src/detectors/heading-sentences.ts +36 -0
  771. package/src/detectors/hyphen-copied-text.ts +65 -0
  772. package/src/detectors/kanji-name-edge.ts +31 -0
  773. package/src/detectors/kanji-run-pieces.ts +26 -0
  774. package/src/detectors/kutoten-consistency.ts +24 -4
  775. package/src/detectors/lead-in-dash.ts +11 -0
  776. package/src/detectors/letter-joined-name.ts +14 -0
  777. package/src/detectors/lexicon.ts +20 -63
  778. package/src/detectors/list-item.ts +37 -1
  779. package/src/detectors/list-items.ts +4 -1
  780. package/src/detectors/list-joint.ts +44 -0
  781. package/src/detectors/list-layout.ts +39 -0
  782. package/src/detectors/list-lead-in.ts +88 -7
  783. package/src/detectors/list-parallel.ts +119 -13
  784. package/src/detectors/list-run.ts +86 -0
  785. package/src/detectors/list-sentence.ts +11 -0
  786. package/src/detectors/mark-shape.ts +12 -7
  787. package/src/detectors/missing-final-period.ts +9 -1
  788. package/src/detectors/name-run.ts +2 -1
  789. package/src/detectors/name-variant-two-things.ts +136 -0
  790. package/src/detectors/name-variant.ts +14 -19
  791. package/src/detectors/numbering-readings.ts +10 -2
  792. package/src/detectors/open-end-anaphor.ts +31 -0
  793. package/src/detectors/open-end-lead.ts +46 -0
  794. package/src/detectors/open-end-scope.ts +8 -1
  795. package/src/detectors/ordinal-run-gaps.ts +1 -1
  796. package/src/detectors/organisation-run.ts +26 -2
  797. package/src/detectors/orthographic-variant-open.ts +124 -0
  798. package/src/detectors/orthographic-variant.ts +82 -82
  799. package/src/detectors/orthography.ts +20 -7
  800. package/src/detectors/over-general-claim.ts +106 -5
  801. package/src/detectors/oxford-comma.ts +68 -28
  802. package/src/detectors/particle-run-names.ts +17 -0
  803. package/src/detectors/placeholder-text.ts +21 -4
  804. package/src/detectors/proper-noun-density.ts +109 -0
  805. package/src/detectors/quote-without-source.ts +52 -10
  806. package/src/detectors/quoted-excerpt.ts +68 -0
  807. package/src/detectors/reference-entry.ts +42 -0
  808. package/src/detectors/register-neutral-shape.ts +26 -6
  809. package/src/detectors/register-separate-part.ts +42 -0
  810. package/src/detectors/register-set-apart.ts +124 -0
  811. package/src/detectors/register-voice.ts +63 -0
  812. package/src/detectors/register.ts +15 -0
  813. package/src/detectors/registry/closing-cliche.ts +4 -0
  814. package/src/detectors/registry/closing-exhortation.ts +4 -0
  815. package/src/detectors/registry/cold-open.ts +4 -0
  816. package/src/detectors/registry/colon-lead-in.ts +1 -1
  817. package/src/detectors/registry/concrete-evidence.ts +1 -1
  818. package/src/detectors/registry/contraction-mix.ts +1 -1
  819. package/src/detectors/registry/duplicate-definition.ts +1 -1
  820. package/src/detectors/registry/ngram-repetition.ts +1 -1
  821. package/src/detectors/registry/proper-noun-density.ts +1 -1
  822. package/src/detectors/registry/topic-predicate-distance.ts +1 -1
  823. package/src/detectors/registry/unprompted-denial.ts +4 -0
  824. package/src/detectors/reproduced-text.ts +33 -0
  825. package/src/detectors/request-owner.ts +31 -8
  826. package/src/detectors/requirement-smell.ts +21 -5
  827. package/src/detectors/sentence-counts.ts +27 -7
  828. package/src/detectors/sentence-ending.ts +66 -14
  829. package/src/detectors/sentence-length.ts +43 -11
  830. package/src/detectors/sentence-load.ts +3 -6
  831. package/src/detectors/sentence-parts.ts +73 -0
  832. package/src/detectors/sentence-title.ts +14 -0
  833. package/src/detectors/signals.ts +20 -202
  834. package/src/detectors/spelling-variety.ts +26 -2
  835. package/src/detectors/structure-tree.ts +5 -9
  836. package/src/detectors/structure.ts +47 -19
  837. package/src/detectors/superlative-clause.ts +21 -2
  838. package/src/detectors/superlative-context.ts +99 -0
  839. package/src/detectors/superlative-scope.ts +27 -9
  840. package/src/detectors/team.ts +1 -50
  841. package/src/detectors/titled-code-citation.ts +19 -0
  842. package/src/detectors/titled-run.ts +22 -5
  843. package/src/detectors/token-shape.ts +40 -18
  844. package/src/detectors/topic-predicate-distance.ts +25 -0
  845. package/src/detectors/undefined-term.ts +26 -1
  846. package/src/detectors/unfilled-placeholder.ts +20 -2
  847. package/src/detectors/unknown-word-context.ts +129 -0
  848. package/src/detectors/unknown-word.ts +29 -20
  849. package/src/detectors/unprompted-denial.ts +133 -0
  850. package/src/document-sections.ts +3 -1
  851. package/src/fix-plan/all-signs.ts +35 -0
  852. package/src/fix-plan/plan.ts +50 -3
  853. package/src/fix-plan/render.ts +41 -3
  854. package/src/fix-plan/risen.ts +13 -0
  855. package/src/fix-plan/text.ts +56 -2
  856. package/src/heading-numbering.ts +44 -10
  857. package/src/html/html-site-chrome.ts +9 -2
  858. package/src/latin-spacing-source.ts +33 -0
  859. package/src/law-title.ts +38 -0
  860. package/src/name-ending-run.ts +49 -0
  861. package/src/name-separator.ts +4 -1
  862. package/src/name-title-slip.ts +59 -0
  863. package/src/name-variant-shapes.ts +58 -0
  864. package/src/name-word-use.ts +17 -0
  865. package/src/opening-passage.ts +31 -0
  866. package/src/paragraph-length.ts +31 -0
  867. package/src/paragraph-runs.ts +71 -13
  868. package/src/plugin.ts +2 -0
  869. package/src/quote-echo.ts +18 -0
  870. package/src/quote-gloss.ts +11 -0
  871. package/src/quoted-spelling.ts +48 -0
  872. package/src/render/semantic.ts +2 -2
  873. package/src/rule-of-three.ts +50 -0
  874. package/src/run-semantic.ts +2 -2
  875. package/src/section-levels.ts +98 -0
  876. package/src/semantic.ts +16 -3
  877. package/src/sentence-load.ts +5 -3
  878. package/src/set-phrase-particles.ts +32 -0
  879. package/src/spelling.ts +37 -7
  880. package/src/structure/alternative-clause.ts +32 -7
  881. package/src/structure/cited-document-section.ts +24 -1
  882. package/src/structure/issues.ts +29 -10
  883. package/src/structure/numbering.ts +50 -3
  884. package/src/structure/unread-label.ts +74 -0
  885. package/src/structure-shape/template-outline.ts +34 -0
  886. package/src/title-case-name.ts +55 -0
  887. package/src/topic-clause.ts +110 -5
  888. package/src/word-use.ts +57 -6
  889. package/dist/legal-address.d.ts +0 -2
  890. package/dist/legal-address.d.ts.map +0 -1
  891. package/dist/legal-address.js +0 -16
  892. package/dist/legal-address.js.map +0 -1
@@ -3,13 +3,14 @@ import { conjugatedStartsOutside } from "./conjugated-entry.ts";
3
3
  import { calendarRuns, calendarUnitsOf, type CalendarUnits } from "../calendar-number.ts";
4
4
  import { escapeRegExp, latinBoundaries, occurrencesOutside, type Boundary, type SpacingKind } from "../orthography.ts";
5
5
  import { minorityReport, withoutSideOnTie } from "../spacing-minority.ts";
6
- import { isWithinAny, quotedSpans } from "../quoted-span.ts";
6
+ import { isWithinAny, QUOTATION_MARKS, quotedSpans } from "../quoted-span.ts";
7
7
  import { digitRunAround, endsWithDivisionLabel, isNumberName, sequenceLabelStarts, type NameContext } from "../number-name.ts";
8
8
  import { isSpacedLocationPart, type FloorWords } from "../location-part.ts";
9
9
  import { isFieldSeparator, isNameSeparator, type OrganizationWords } from "../name-separator.ts";
10
10
  import { addressSpans, clockTimeSpans, identifierSpans, isInsideSpan } from "../spacing-code.ts";
11
11
  import { followsHandle, isBoundSuffix, isJoinerSpace } from "../latin-word-boundary.ts";
12
12
  import { licenceNoticeSentences } from "./licence-notice.ts";
13
+ import { followsCaptionLabel, isCitedEntryLine, isNumberTableBoundary, lineAt } from "../latin-spacing-source.ts";
13
14
 
14
15
  /** 書いた形の出現に、動詞の活用した形(行う → 行います)を足したもの。同じ位置は一度だけ。 */
15
16
  const avoidedStarts = (sentence: Sentence, entry: LexiconEntry, use: string): number[] => {
@@ -59,6 +60,8 @@ type NumberContext = NameContext & {
59
60
  readonly organizations: OrganizationWords;
60
61
  /** 日本語の句をつなぐ英語の語(or、vs.)と、英字の語に付ける接尾の語(版、化)。 */
61
62
  readonly latinWords: { readonly joiners: ReadonlySet<string>; readonly boundSuffixes: ReadonlySet<string> };
63
+ /** 図表の札(表、図)。行の頭にこれだけを書いた後ろの空白は、札と題の区切り。 */
64
+ readonly captionLabels: ReadonlySet<string>;
62
65
  };
63
66
 
64
67
  /** 文頭の項目の番号の後ろと見る境目の位置の上限。番号は短く文の頭にあるので、これより後ろの境目は番号の後ろではない。長い文で文頭からの切り出しを繰り返さない。 */
@@ -107,7 +110,10 @@ type SentenceCodes = {
107
110
  */
108
111
  /** 項目の番号・識別子・チャンネルや宛先の名前(#pj_oss-team)の端の境目。どれも名前や番号を閉じる空白で、空け方の好みではない。 */
109
112
  const closesName = (sentence: Sentence, boundary: Boundary, context: NumberContext, codes: SentenceCodes): boolean =>
110
- followsItemNumber(sentence.text, boundary, context.itemNumbers) || besideSpan(codes.identifiers, boundary) || followsHandle(sentence.text, boundary);
113
+ followsItemNumber(sentence.text, boundary, context.itemNumbers) ||
114
+ followsCaptionLabel(sentence.text, boundary, context.captionLabels) ||
115
+ besideSpan(codes.identifiers, boundary) ||
116
+ followsHandle(sentence.text, boundary);
111
117
 
112
118
  const isCounted = (sentence: Sentence, boundary: Boundary, context: NumberContext, codes: SentenceCodes): boolean => {
113
119
  if (closesName(sentence, boundary, context, codes)) return false;
@@ -194,22 +200,29 @@ export const latinSpacing: Detector = (doc, options): Finding[] => {
194
200
  floors: { units: patternsOf(doc, "floor-unit"), levels: patternsOf(doc, "floor-level") },
195
201
  organizations: { units: patternsOf(doc, "organization-unit"), forms: patternList(doc, "company-form") },
196
202
  latinWords: { joiners: patternsOf(doc, "latin-joiner"), boundSuffixes: patternsOf(doc, "latin-bound-suffix") },
203
+ captionLabels: patternsOf(doc, "figure-label"),
197
204
  };
198
205
  // 文書の最後の利用条件の断り書き(クリエイティブ・コモンズ 表示 4.0 国際)は、掲載先の書き方で書き手の空け方ではない。
199
206
  const licence = licenceNoticeSentences(doc, doc.lexicons["licence-word"] ?? []);
200
207
  const located: Located[] = doc.sentences.flatMap((sentence) => {
201
208
  if (licence.has(sentence)) return [];
202
- const quoted = quotedSpans(sentence.text);
209
+ // 「」『』のほか、“”で引いた題名(“パブリック・ドメイン・マーク 1.0 全世界コモンズ証”)も元の書き方。
210
+ const quoted = quotedSpans(sentence.text, QUOTATION_MARKS);
203
211
  const codes = {
204
212
  calendar: calendarStarts(sentence, context.calendar),
205
213
  clockTimes: clockTimeSpans(sentence.text),
206
214
  addresses: addressSpans(sentence.text),
207
215
  identifiers: identifierSpans(sentence.text),
208
216
  };
209
- return latinBoundaries(sentence.text, doc.source.slice(sentence.span.start, sentence.span.end))
210
- .filter((boundary) => !isQuoted(quoted, boundary) && !isInsideLink(doc.links, sentence.span.start + boundary.offset))
211
- .filter((boundary) => isCounted(sentence, boundary, context, codes))
212
- .map((boundary) => ({ sentence, ...boundary }));
217
+ return (
218
+ latinBoundaries(sentence.text, doc.source.slice(sentence.span.start, sentence.span.end))
219
+ .filter((boundary) => !isQuoted(quoted, boundary) && !isInsideLink(doc.links, sentence.span.start + boundary.offset))
220
+ .filter((boundary) => !isCitedEntryLine(lineAt(doc.source, sentence.span.start + boundary.offset)))
221
+ // 変換で一続きになった数の表の、升の区切りの空白。
222
+ .filter((boundary) => !isNumberTableBoundary(sentence.text, boundary))
223
+ .filter((boundary) => isCounted(sentence, boundary, context, codes))
224
+ .map((boundary) => ({ sentence, ...boundary }))
225
+ );
213
226
  });
214
227
  return KINDS.flatMap((kind) =>
215
228
  findingsOf(
@@ -1,5 +1,5 @@
1
- import type { Detector, Finding, Lexicon, ProseDocument, Sentence } from "../plugin.ts";
2
- import { entryEnds, entryIn } from "./lexicon-match.ts";
1
+ import type { Detector, Finding, Lexicon, LexiconEntry, ProseDocument, Sentence, Token } from "../plugin.ts";
2
+ import { comparableWords, entryEnds, entryIn, entryRanges, type TokenRange } from "./lexicon-match.ts";
3
3
  import { wordsOf } from "./structure.ts";
4
4
  import { MIN_DOCUMENT_LENGTH } from "./signals.ts";
5
5
 
@@ -13,14 +13,115 @@ const MIN_PHRASES = 2;
13
13
  /** 一つの文の、大きく括る言い方。使った回数だけ並ぶ。 */
14
14
  export type SweepingSentence = { readonly sentence: Sentence; readonly phrases: readonly string[] };
15
15
 
16
- const usesIn = (sentence: Sentence, lexicon: Lexicon): string[] => lexicon.flatMap((entry) => entryEnds(sentence, entry).map(() => entry.pattern));
16
+ /** 語彙表の組。general は常に、subject は動詞の主語のときだけ数え、who は誰のことかが近くで決まっていれば数えない。残りはその決まり方を言う語。 */
17
+ type Vocabulary = {
18
+ readonly general: Lexicon;
19
+ readonly subject: Lexicon;
20
+ readonly who: Lexicon;
21
+ readonly groupNouns: Lexicon;
22
+ readonly addressees: Lexicon;
23
+ readonly rightAfter: Lexicon;
24
+ readonly presentForms: Lexicon;
25
+ readonly relatives: Lexicon;
26
+ };
27
+
28
+ const inGroup = (lexicon: Lexicon, group: string): Lexicon => lexicon.filter((entry) => entry.group === group);
29
+
30
+ const vocabularyOf = (lexicon: Lexicon): Vocabulary => ({
31
+ general: inGroup(lexicon, "general"),
32
+ subject: inGroup(lexicon, "subject"),
33
+ who: inGroup(lexicon, "who"),
34
+ groupNouns: inGroup(lexicon, "group-noun"),
35
+ addressees: inGroup(lexicon, "addressee"),
36
+ rightAfter: inGroup(lexicon, "right-after"),
37
+ presentForms: inGroup(lexicon, "present-form"),
38
+ relatives: inGroup(lexicon, "relative"),
39
+ });
40
+
41
+ const NOMINAL = new Set(["NOUN", "PROPN"]);
42
+ const VERBAL = new Set(["VERB", "AUX", "PART"]);
43
+
44
+ const isNominal = (token: Token | undefined): boolean => NOMINAL.has(token?.pos ?? "");
45
+ const isWord = (token: Token | undefined, entries: Lexicon): boolean =>
46
+ token !== undefined && entries.some((entry) => comparableWords(entry.pattern) === comparableWords(token.surface));
47
+
48
+ /** 後ろの名詞を飾る位置(family photos)。動詞とも読める語(family shares)は、tagger が動詞を名詞と読み違えたことがあるので数えない。 */
49
+ const modifiesNext = (next: Token | undefined): boolean => isNominal(next) && next?.features?.["AlsoVerb"] !== "Yes";
50
+
51
+ /** 人の集まりを名指す名詞が、句の中心に立つ(the team、family members)。後ろの名詞を飾るだけ(family photos)なら名指していない。 */
52
+ const headsPhrase = (tokens: readonly Token[], range: TokenRange): boolean => isNominal(tokens[range.start]) && !modifiesNext(tokens[range.end]);
53
+
54
+ /** 文が人の集まりを名指す(the team、our family、all of you)。 */
55
+ const namesGroup = (sentence: Sentence | undefined, vocabulary: Vocabulary): boolean => {
56
+ if (sentence === undefined) return false;
57
+ const tokens = sentence.tokens ?? [];
58
+ const named = vocabulary.groupNouns.some((entry) => entryRanges(sentence, entry).some((range) => headsPhrase(tokens, range)));
59
+ return named || vocabulary.addressees.some((entry) => entryIn(sentence, entry));
60
+ };
61
+
62
+ /** 規則どおりの三人称単数現在(loves、watches、tries)。 */
63
+ const isThirdPersonPresent = (surface: string, lemma: string): boolean => [`${lemma}s`, `${lemma}es`, `${lemma.replace(/y$/u, "")}ies`].includes(surface);
64
+
65
+ /** 過去形の動詞(caught、jumped、was)。原形・現在形・-ing 形は過去でない。 */
66
+ const isPastVerb = (token: Token | undefined, vocabulary: Vocabulary): boolean => {
67
+ if (token?.pos !== "VERB" || token.lemma === undefined || token.features?.["VerbForm"] === "Ger") return false;
68
+ const surface = token.surface.toLowerCase();
69
+ const lemma = token.lemma.toLowerCase();
70
+ return surface !== lemma && !isThirdPersonPresent(surface, lemma) && !isWord(token, vocabulary.presentForms);
71
+ };
72
+
73
+ /** 括る言い方のすぐ後の動詞。副詞と関係代名詞(everyone who quickly jumped)は飛ばす。動詞の前に別の語があれば無い。 */
74
+ const verbAfter = (tokens: readonly Token[], from: number, vocabulary: Vocabulary): Token | undefined => {
75
+ const rest = tokens.slice(from);
76
+ const verb = rest.find((token) => token.pos !== "ADV" && !isWord(token, vocabulary.relatives));
77
+ return VERBAL.has(verb?.pos ?? "") ? verb : undefined;
78
+ };
79
+
80
+ const UNFINISHED = new Set(["Part", "Ger"]);
81
+
82
+ /** 主語として動詞が続く(many people keep)。名詞の前の飾り(the many people connected)や目的語(see many people on the trail)は人の一般論でない。 */
83
+ const isSubject = (tokens: readonly Token[], range: TokenRange, vocabulary: Vocabulary): boolean => {
84
+ const verb = verbAfter(tokens, range.end, vocabulary);
85
+ return verb !== undefined && verb.pos !== "PART" && !UNFINISHED.has(verb.features?.["VerbForm"] ?? "");
86
+ };
87
+
88
+ /** 主語として使った subject の組の語の数。品詞が無ければ位置を言えないので、すべて数える。 */
89
+ const subjectUses = (sentence: Sentence, entry: LexiconEntry, vocabulary: Vocabulary): number => {
90
+ if (sentence.tokens === undefined || entry.tokens === undefined) return entryEnds(sentence, entry).length;
91
+ const tokens = sentence.tokens;
92
+ return entryRanges(sentence, entry).filter((range) => isSubject(tokens, range, vocabulary)).length;
93
+ };
94
+
95
+ /** 誰のことかが決まっている: すぐ後の語(everyone here)、過去形の動詞(nobody caught it、一度の出来事)、この文か前の文の集まり。 */
96
+ const isBounded = (sentence: Sentence, previous: Sentence | undefined, range: TokenRange, vocabulary: Vocabulary): boolean => {
97
+ const tokens = sentence.tokens ?? [];
98
+ if (isWord(tokens[range.end], vocabulary.rightAfter)) return true;
99
+ if (isPastVerb(verbAfter(tokens, range.end, vocabulary), vocabulary)) return true;
100
+ return namesGroup(sentence, vocabulary) || namesGroup(previous, vocabulary);
101
+ };
102
+
103
+ /** who の組の語の、誰のことかが決まっていない出現。品詞が無ければ位置を言えないので、すべて数える。 */
104
+ const openUses = (sentence: Sentence, previous: Sentence | undefined, entry: LexiconEntry, vocabulary: Vocabulary): number => {
105
+ if (sentence.tokens === undefined || entry.tokens === undefined) return entryEnds(sentence, entry).length;
106
+ return entryRanges(sentence, entry).filter((range) => !isBounded(sentence, previous, range, vocabulary)).length;
107
+ };
108
+
109
+ const repeated = (pattern: string, times: number): string[] => Array.from({ length: times }, () => pattern);
110
+
111
+ const usesIn = (sentence: Sentence, previous: Sentence | undefined, vocabulary: Vocabulary): string[] => [
112
+ ...vocabulary.general.flatMap((entry) => repeated(entry.pattern, entryEnds(sentence, entry).length)),
113
+ ...vocabulary.subject.flatMap((entry) => repeated(entry.pattern, subjectUses(sentence, entry, vocabulary))),
114
+ ...vocabulary.who.flatMap((entry) => repeated(entry.pattern, openUses(sentence, previous, entry, vocabulary))),
115
+ ];
17
116
 
18
117
  /** 大きく括る言い方を使った文。weasel-word が言う文(most people agree)は、同じ文を二度言わないので数えない。 */
19
118
  export const sweepingSentences = (doc: ProseDocument, lexicon: Lexicon): SweepingSentence[] => {
20
119
  const weasel = doc.lexicons["weasel-word"] ?? [];
120
+ const vocabulary = vocabularyOf(lexicon);
21
121
  return doc.sentences
22
- .filter((sentence) => sentence.embeddedLanguage === undefined && !weasel.some((entry) => entryIn(sentence, entry)))
23
- .map((sentence) => ({ sentence, phrases: usesIn(sentence, lexicon) }))
122
+ .map((sentence, index) => ({ sentence, previous: doc.sentences[index - 1] }))
123
+ .filter(({ sentence }) => sentence.embeddedLanguage === undefined && !weasel.some((entry) => entryIn(sentence, entry)))
124
+ .map(({ sentence, previous }) => ({ sentence, phrases: usesIn(sentence, previous, vocabulary) }))
24
125
  .filter((found) => found.phrases.length > 0);
25
126
  };
26
127
 
@@ -1,5 +1,6 @@
1
1
  import type { Detector, Finding, Lexicon, Token } from "../plugin.ts";
2
2
  import {
3
+ commaBefore,
3
4
  contentCount,
4
5
  exampleEnd,
5
6
  firstAt,
@@ -11,6 +12,8 @@ import {
11
12
  hasListConjunction,
12
13
  hasParticiple,
13
14
  hasVerb,
15
+ endsWithPreposition,
16
+ hasNonAdverbContent,
14
17
  isClause,
15
18
  isModifiedNoun,
16
19
  isModifier,
@@ -19,11 +22,11 @@ import {
19
22
  itemAfter,
20
23
  lastContent,
21
24
  lastNoun,
22
- leadShape,
23
25
  openingKind,
24
26
  openingOf,
25
27
  participleOpening,
26
28
  shapeOf,
29
+ shapeOfHead,
27
30
  } from "./list-item.ts";
28
31
  import { listReader, type ItemList } from "./list-items.ts";
29
32
  import { APPOSITIVE_ANCHOR, isListConjunction, listSentenceOf, NOMINAL, VERBAL, type ItemScope, type ListWords } from "./list-sentence.ts";
@@ -50,11 +53,12 @@ import { followsPostcode } from "./postcode-end.ts";
50
53
  import { withoutCoordinateAdjective } from "./coordinate-adjective.ts";
51
54
  import { dashBreaks } from "./dash-break.ts";
52
55
  import { namesDivision, qualifiesPrevious } from "./list-comma-aside.ts";
56
+ import { inExcerpt } from "./quoted-excerpt.ts";
57
+ import { listContinues, walker, type Walk } from "./list-run.ts";
58
+ import { joinsUnfinished, repeatsConjunction } from "./list-joint.ts";
53
59
 
54
60
  const EMPTY: TokenRange = { start: 0, end: 0 };
55
61
 
56
- const commaBefore = (scope: ItemScope, at: number): boolean => scope.sentence.tokens[at - 1]?.surface === ",";
57
-
58
62
  /**
59
63
  * 導入の句(After the review, / If it fails, / Finally, / To test it, / Based on the review,)は並列の項目ではない。
60
64
  * 節の最初の項目が前置詞・接続詞・副詞・to・過去分詞で始まり、次の項目と頭の形が違えば外す。
@@ -66,10 +70,14 @@ const LEAD_POS = new Set(["ADP", "SCONJ", "ADV", "PART"]);
66
70
 
67
71
  const isSequenceWord = (scope: ItemScope, token: Token | undefined): boolean => scope.sentence.words.sequence?.has(token?.surface.toLowerCase() ?? "") ?? false;
68
72
 
73
+ /** 順番の語か、前の文とつなぐ語(However,)。どちらも文頭の導入で、並びの項目ではない。 */
74
+ const isOpenerWord = (scope: ItemScope, token: Token | undefined): boolean =>
75
+ isSequenceWord(scope, token) || (scope.sentence.words.connective?.has(token?.surface.toLowerCase() ?? "") ?? false);
76
+
69
77
  const SENTENCE_MARKS = new Set(["PUNCT", "SYM"]);
70
78
 
71
79
  /**
72
- * 順番の語と読点(First, / Next,)で始まる最初の項目から、その語を外した並び。解析器は First を形容詞と読み、読点で項目を切らないことがある。
80
+ * 順番の語やつなぎの語と読点(First, / Next, / However,)で始まる最初の項目から、その語を外した並び。解析器は First を形容詞と読み、読点で項目を切らないことがある。
73
81
  * 文頭の語だけ。文の途中の first は項目のことがある(We support first, fallback, and legacy modes)。
74
82
  * 次の項目も順番の語なら、順番の語の並び(first, second and third)なので外さない。
75
83
  */
@@ -80,7 +88,7 @@ const withoutSequenceWord = (view: View): View | undefined => {
80
88
  const at = firstAt(scope, "open", first.item);
81
89
  const { tokens } = scope.sentence;
82
90
  const opensSentence = tokens.slice(0, at).every((token) => SENTENCE_MARKS.has(token.pos));
83
- if (!opensSentence || !isSequenceWord(scope, tokens[at]) || tokens[at + 1]?.surface !== "," || isSequenceWord(scope, openingOf(scope, second.item)))
91
+ if (!opensSentence || !isOpenerWord(scope, tokens[at]) || tokens[at + 1]?.surface !== "," || isSequenceWord(scope, openingOf(scope, second.item)))
84
92
  return undefined;
85
93
  const rest = { start: at + 2, end: first.item.end };
86
94
  return hasContent(scope, rest) ? { ...withoutFirst(view), pre: rest } : withoutFirst(view);
@@ -110,7 +118,30 @@ const afterClosedList = (view: View): View => {
110
118
  const body = { start: conjunction === -1 ? closing.item.start : conjunction + 1, end: closing.item.end };
111
119
  const head = firstAt(scope, "content", body);
112
120
  const rest = VERBAL.has(scope.sentence.tokens[head]?.pos ?? "") ? { start: head + 1, end: body.end } : body;
113
- return hasContent(scope, rest) ? { ...after(view, closing), pre: rest } : withoutLead(after(view, closing));
121
+ return isItem(scope, rest) ? { ...after(view, closing), pre: rest } : withoutLead(after(view, closing));
122
+ };
123
+
124
+ /**
125
+ * 項目として立つ切れ端か。副詞だけ(does not の not)や、目的語を後ろに残した前置詞で終わるもの(or impose conditions upon,
126
+ * certain transmittals / directly related to, and necessary for, the licensing)は、読点の後ろへ続く句の頭で、項目ではない。
127
+ */
128
+ const isItem = (scope: ItemScope, rest: TokenRange): boolean => hasNonAdverbContent(scope, rest) && !endsWithPreposition(scope, rest);
129
+
130
+ /**
131
+ * 節だけをつなぐ接続詞(but / yet)で始まる項目があれば、そこまでは節の並びで、項目の並びは後ろから
132
+ * (If you need help with something, but it's not a priority right now, add it to the backlog and bring it up は並びではない)。
133
+ * 節の最後の語が次の項目の頭と同じ品詞なら、その語が並びの最初の項目(but other teams may use JIRA, waffle.io, or another
134
+ * system / but your system for issuing, receiving and storing invoices)なので、切らない。目的語を待つ語で終われば節ではない
135
+ * (including, but not limited to, BB, Pellet and Paint Guns)。
136
+ */
137
+ const afterClauseTurn = (view: View, afterItem: TokenRange): View => {
138
+ const turn = findLast(view, "turn");
139
+ if (turn === undefined) return view;
140
+ const { scope } = view.list;
141
+ const rest = after(view, turn);
142
+ const next = firstOf(rest)?.item ?? afterItem;
143
+ const carriesFirstItem = shapeOfHead(lastContent(scope, turn.item)) === shapeOf(scope, next);
144
+ return carriesFirstItem || endsWithPreposition(scope, turn.item) ? view : rest;
114
145
  };
115
146
 
116
147
  const opensAsNoun = (scope: ItemScope, item: TokenRange): boolean => {
@@ -118,6 +149,9 @@ const opensAsNoun = (scope: ItemScope, item: TokenRange): boolean => {
118
149
  return opening !== undefined && (opening.pos === "DET" || NOMINAL.has(opening.pos));
119
150
  };
120
151
 
152
+ /** 項目が読点で閉じず、節の終わり(文の終わりか ; : —)まで続く。 */
153
+ const runsToClauseEnd = (scope: ItemScope, item: TokenRange): boolean => scope.sentence.tokens[item.end]?.surface !== ",";
154
+
121
155
  const opensAsPredicate = (scope: ItemScope, item: TokenRange): boolean => {
122
156
  const opening = openingOf(scope, item);
123
157
  return opening !== undefined && VERBAL.has(opening.pos) && !isParticiple(opening);
@@ -129,13 +163,19 @@ const opensAsPredicate = (scope: ItemScope, item: TokenRange): boolean => {
129
163
  * 並びがあるなら句の後ろから(are excluded and are not authorized は 2 つ)。例の中の分詞(connected)は名詞にかかる語で、
130
164
  * 述語と同じ形と読まない。句の前は並びの最初の項目で、名詞の句(主語)。動詞で始まれば述語の並びの項目
131
165
  * (Review backups, such as daily snapshots, update indexes and archive logs は 3 つ)。
166
+ * 解析器が述語の動詞を名詞と読んでも(Financial institutions, including CDFIs, support housing through lending and investment の
167
+ * support)、動詞の無い主語のあとの句で、句の後ろの項目が前置詞を連れ、and / or の後ろが読点で閉じずに節の終わりまで続けば、
168
+ * and / or は述語の中で前置詞の目的語を結ぶ。句の中の並びなら、述語の前で句を閉じる読点がある。主語だけの断片の終わりの例の並び
169
+ * (Full details of the parameters, including meaning, data type and any other constraints.)は前置詞を連れないので並びのまま。
132
170
  */
133
- const isAsideBeforePredicate = (view: View, phrase: Member, examples: TokenRange): boolean => {
171
+ const isAsideBeforePredicate = (view: View, phrase: Member, examples: TokenRange, afterItem: TokenRange): boolean => {
134
172
  const { scope } = view.list;
135
173
  const [subject, next] = [firstOf(view), firstOf(after(view, phrase))];
136
174
  if (subject === undefined || next === undefined || subject.j !== phrase.j - 1) return false;
137
175
  const opensPhrase = (scope.sentence.exampleEnds[phrase.item.start]?.length ?? 0) > 0;
138
- return opensPhrase && opensAsNoun(scope, subject.item) && opensAsNoun(scope, examples) && opensAsPredicate(scope, next.item);
176
+ const objectsInPredicate = !hasVerb(scope, subject.item) && hasAdposition(scope, next.item) && runsToClauseEnd(scope, afterItem);
177
+ const predicate = opensAsPredicate(scope, next.item) || objectsInPredicate;
178
+ return opensPhrase && opensAsNoun(scope, subject.item) && opensAsNoun(scope, examples) && predicate;
139
179
  };
140
180
 
141
181
  /**
@@ -144,14 +184,14 @@ const isAsideBeforePredicate = (view: View, phrase: Member, examples: TokenRange
144
184
  * adopting ... / (e.g., by location, contract type, or contract preference))。句の中に and / or があれば句はもう閉じていて、
145
185
  * 句ごと 1 つの項目(apples, oranges such as navels and mandarins, and pears)。
146
186
  */
147
- const fromExample = (view: View): View => {
187
+ const fromExample = (view: View, afterItem: TokenRange): View => {
148
188
  const phrase = findLast(view, "example");
149
189
  if (phrase === undefined) return view;
150
190
  const { scope } = view.list;
151
191
  const examples = { start: exampleEnd(scope, phrase.item), end: phrase.item.end };
152
192
  if (hasListConjunction(scope, examples)) return view;
153
193
  const rest = after(view, phrase);
154
- if (isAsideBeforePredicate(view, phrase, examples)) return rest;
194
+ if (isAsideBeforePredicate(view, phrase, examples, afterItem)) return rest;
155
195
  const inPhrase = contentOnlyWith(rest, examples);
156
196
  return sameShapes(inPhrase) ? inPhrase : view;
157
197
  };
@@ -209,18 +249,6 @@ const isAppositive = (scope: ItemScope, at: number, view: View, afterItem: Token
209
249
  return closed && APPOSITIVE_ANCHOR.has(lastContent(scope, anchor.item)?.pos ?? "") && !hasVerb(scope, head.item) && !hasVerb(scope, afterItem);
210
250
  };
211
251
 
212
- /**
213
- * and の後ろの項目に読点と、同じ形の項目を連れた and / or が続くなら、この and は項目の中にある(searches and seizures, and
214
- * the Eighth's ban)。頭の形か、節かどうかが違えば別の節をつなぐ and で、この and までが並び(apples, pears and plums, and went home / and figs fell)。
215
- */
216
- const listContinues = (scope: ItemScope, afterItem: TokenRange): boolean => {
217
- const next = afterItem.end;
218
- if (scope.sentence.tokens[next]?.surface !== "," || !isListConjunction(scope.sentence.tokens[next + 1])) return false;
219
- const following = itemAfter(scope, next + 1);
220
- const shape = leadShape(scope, following);
221
- return shape !== undefined && shape === leadShape(scope, afterItem) && isClause(scope, following) === isClause(scope, afterItem);
222
- };
223
-
224
252
  /**
225
253
  * 語のあとが複数形の名詞句なら、語は名詞にかかる語で、2 つはもう揃っている(the renderer in both modes and the exporter)。
226
254
  * and の後ろも冠詞の無い複数形の名詞句なら、2 つを結ぶ語(both project goals and business goals)。
@@ -280,7 +308,11 @@ const joinsObjects = (scope: ItemScope, at: number, view: View, afterItem: Token
280
308
 
281
309
  /** and / or が並びの最後の継ぎ目ではなく、最後の項目の中にある。 */
282
310
  const insideLastItem = (scope: ItemScope, at: number, view: View, afterItem: TokenRange): boolean =>
283
- pairsInLastItem(scope, at, view, afterItem) || sharesNoun(scope, at, view, afterItem) || joinsObjects(scope, at, view, afterItem);
311
+ pairsInLastItem(scope, at, view, afterItem) ||
312
+ sharesNoun(scope, at, view, afterItem) ||
313
+ joinsObjects(scope, at, view, afterItem) ||
314
+ joinsUnfinished(scope, at, view, afterItem) ||
315
+ repeatsConjunction(scope, at, view, afterItem);
284
316
 
285
317
  /**
286
318
  * 節を並べるなら、どの項目も節。Additionally, others can learn, and the mistake is rarer. の Additionally は項目ではなく、
@@ -309,12 +341,13 @@ const opensContrast = (scope: ItemScope, item: TokenRange): boolean => CONTRAST.
309
341
  * (We tested it, and the team shipped it.)は、Oxford comma を打つかどうかの選択を見せない。
310
342
  * 題名の読点は題名を付けた人のもの。書き手の流儀の票にしない。
311
343
  */
312
- const listAt = (list: ItemList, at: number): boolean | undefined => {
344
+ const listAt = (list: ItemList, at: number, walk: Walk): boolean | undefined => {
313
345
  const { scope } = list;
314
346
  if (closesExampleAside(wholeList(list), at)) return undefined;
315
347
  const afterItem = itemAfter(scope, at);
316
- const items = fromParticiplePhrase(fromExample(afterClosedList(withoutLead(withoutCoordinateAdjective(wholeList(list))))), afterItem);
317
- if (listContinues(scope, afterItem) || isAppositive(scope, at, items, afterItem) || insideLastItem(scope, at, items, afterItem)) return undefined;
348
+ const opened = afterClosedList(withoutLead(afterClauseTurn(withoutCoordinateAdjective(wholeList(list)), afterItem)));
349
+ const items = fromParticiplePhrase(fromExample(opened, afterItem), afterItem);
350
+ if (listContinues(scope, afterItem, walk) || isAppositive(scope, at, items, afterItem) || insideLastItem(scope, at, items, afterItem)) return undefined;
318
351
  if (namesDivision(items) || qualifiesPrevious(items)) return undefined;
319
352
  const last = lastOf(items);
320
353
  if (last !== undefined && opensContrast(scope, last.item)) return undefined;
@@ -334,12 +367,14 @@ export const listVerdicts = (tokens: readonly Token[], words: ListWords, source:
334
367
  const sentence = listSentenceOf(tokens, words, source);
335
368
  const readItems = listReader(sentence);
336
369
  const breaks = dashBreaks(tokens, source);
370
+ const excerpt = inExcerpt(tokens, source, words.elision ?? []);
371
+ const walk = walker();
337
372
  return tokens.flatMap((token, at) => {
338
373
  if (!isJudgedConjunction(token, at)) return [];
339
374
  // 郵便番号で終わる住所のあとの and / or は、住所の行を区切る読点のあと。並びの読点ではない。
340
375
  // 最後の読点のあとに前後を空けたダッシュがあれば(Washington, DC – The …)、読点はダッシュの前で閉じた日付行や見出しのもの。
341
- const notList = sentence.inCitedTitle(at) || followsPostcode(source, token.span.start) || breaks[at] === true;
342
- return [notList ? undefined : listAt(readItems(at), at)];
376
+ const notList = sentence.inCitedTitle(at) || excerpt(at) || followsPostcode(source, token.span.start) || breaks[at] === true;
377
+ return [notList ? undefined : listAt(readItems(at), at, walk)];
343
378
  });
344
379
  };
345
380
 
@@ -363,6 +398,11 @@ export const oxfordComma: Detector = (doc, options): Finding[] => {
363
398
  titleCue: (doc.lexicons["title-cue"] ?? []).map((entry) => entry.pattern),
364
399
  sequence: patternsOf(doc.lexicons["sequence-opener"]),
365
400
  unit: patternsOf(doc.lexicons["enclosing-unit"]),
401
+ connective: patternsOf(doc.lexicons["connective-opener"]),
402
+ clauseConjunction: patternsOf(doc.lexicons["clause-conjunction"]),
403
+ indefinite: patternsOf(doc.lexicons["indefinite-article"]),
404
+ elision: (doc.lexicons["elision-mark"] ?? []).map((entry) => entry.pattern),
405
+ openListEnd: patternsOf(doc.lexicons["open-list-end"]),
366
406
  };
367
407
  const judged = doc.sentences.flatMap((sentence) => {
368
408
  const oxford = oxfordIn(sentence.tokens ?? [], words, doc.source);
@@ -0,0 +1,17 @@
1
+ import type { DocumentNamer, Span } from "../plugin.ts";
2
+
3
+ /**
4
+ * 文の中に書いた文書の名前(「高齢者、障害者等の移動等の円滑化の促進に関する法律」)の位置。
5
+ * 題名は書き手が言い換えられないので、鉤括弧で引いた題名と同じく、中の助詞を数えず一つの名詞として読む。
6
+ * 名前は言語パッケージが読む(名前の終わりの位置を渡すと、そこで終わる名前を返す)。読めない言語では何も返さない。
7
+ */
8
+ export const documentNameSpans = (text: string, within: Span, namer: DocumentNamer | undefined): Span[] => {
9
+ if (namer === undefined) return [];
10
+ const ends = Array.from({ length: within.end - within.start }, (_, index) => within.start + index + 1);
11
+ return ends.flatMap((end) => {
12
+ const named = namer(text, end);
13
+ // 名前の後ろの括弧書きやつなぎの語(「民法の」の「の」)を読み飛ばした名前は、ここで終わる名前ではない。
14
+ const endsHere = named !== undefined && named.name !== "" && text.slice(end - named.name.length, end) === named.name;
15
+ return endsHere ? [{ start: end - named.name.length, end }] : [];
16
+ });
17
+ };
@@ -1,4 +1,5 @@
1
1
  import type { Lexicon } from "../plugin.ts";
2
+ import { joinedBlanks } from "./blank-runs.ts";
2
3
 
3
4
  type Span = { readonly start: number; readonly end: number };
4
5
 
@@ -110,6 +111,18 @@ const endsWithAny = (text: string, words: Lexicon): boolean => words.some((word)
110
111
 
111
112
  type BlankWords = { readonly suffixes: Lexicon; readonly prefixes: Lexicon; readonly units: Lexicon };
112
113
 
114
+ /** 行の残りが空白と伏せ字だけか(「代表取締役 〇〇 〇〇」の姓の後ろ)。 */
115
+ const ONLY_BLANKS = /^[\s○〇◯△]*$/u;
116
+ /** 項目名のコロンか空白の後ろ(「氏名:〇〇」「総務部長 〇〇」)。行の終わりまで伏せ字なら、その値が空欄。 */
117
+ const VALUE_SEPARATOR = /[\s::]$/u;
118
+ /** 番号の組を繋ぐハイフン(〒〇〇〇-〇〇〇〇、03-〇〇〇〇-〇〇〇〇)。伏せ字がその一組なら、番号の空欄。 */
119
+ const NUMBER_JOIN_BEFORE = /[-‐-][\d○〇◯]*$/u;
120
+ const NUMBER_JOIN_AFTER = /^[-‐-]/u;
121
+
122
+ /** 名前の長さの伏せ字が、行の終わりまで続く値か、番号の一組か。 */
123
+ const isValueOrNumberBlank = (lineBefore: string, lineAfter: string): boolean =>
124
+ (VALUE_SEPARATOR.test(lineBefore) && ONLY_BLANKS.test(lineAfter)) || NUMBER_JOIN_BEFORE.test(lineBefore) || NUMBER_JOIN_AFTER.test(lineAfter);
125
+
113
126
  /** 記号の並びが空欄の位置にあるか。あれば、空欄として言う範囲(後ろに付いた語まで)。 */
114
127
  const blankSpanAt = (text: string, match: RegExpExecArray, words: BlankWords): Span | undefined => {
115
128
  const start = match.index;
@@ -122,6 +135,7 @@ const blankSpanAt = (text: string, match: RegExpExecArray, words: BlankWords): S
122
135
  if (suffix !== undefined) return { start, end: end + suffix.pattern.length };
123
136
  if (endsWithAny(before.trimEnd(), words.prefixes)) return { start, end };
124
137
  if (atLineHead(before) && lineAfter.trim() === "") return { start, end };
138
+ if (isValueOrNumberBlank(before.split("\n").at(-1) ?? "", lineAfter)) return { start, end };
125
139
  }
126
140
  const unit = startsWithAny(after, words.units);
127
141
  if (unit === undefined || NUMERAL_BEFORE.test(before)) return undefined;
@@ -135,10 +149,13 @@ const blankSpanAt = (text: string, match: RegExpExecArray, words: BlankWords): S
135
149
  const blankMarkSpans = (text: string, words: BlankWords): Span[] =>
136
150
  words.suffixes.length + words.prefixes.length + words.units.length === 0
137
151
  ? []
138
- : [...text.matchAll(BLANK_MARKS)].flatMap((match) => {
139
- const span = blankSpanAt(text, match, words);
140
- return span === undefined ? [] : [span];
141
- });
152
+ : joinedBlanks(
153
+ text,
154
+ [...text.matchAll(BLANK_MARKS)].flatMap((match) => {
155
+ const span = blankSpanAt(text, match, words);
156
+ return span === undefined ? [] : [span];
157
+ }),
158
+ );
142
159
 
143
160
  /** 文の中の、埋め忘れた雛形の空欄([Your Name]、【会社名】、(ここに会社名を書く)、TBD: …、〇〇様)の範囲。words は placeholder-word の語彙表。 */
144
161
  export const placeholderSpans = (text: string, words: Lexicon): Span[] => {
@@ -0,0 +1,109 @@
1
+ // proper-noun-density: names per 1000 words (characters in Japanese) of prose. A name counts once however many words
2
+ // it has, a line that is not a sentence is not prose, and the everyday names of lexicon everyday-name are not counted.
3
+ import { lengthOf, proseText } from "../measure.ts";
4
+ import { nameSpans } from "../team-names.ts";
5
+ import { QUOTATION_MARKS, quotedIn } from "../quoted-span.ts";
6
+ import type { Detector, Finding, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
7
+
8
+ const PER = 1000;
9
+ /** 密度を見る rule は短い文書を測らない。単位は言語で違うので床も分ける。 */
10
+ const FLOOR = { word: 200, char: 500 };
11
+ const EVERYDAY_NAME = "everyday-name";
12
+ const PREDICATES: ReadonlySet<string> = new Set(["VERB", "AUX"]);
13
+ /**
14
+ * What may stand between two words of one name: spaces, a hyphen, a slash, an initial's full stop, an ampersand, an apostrophe,
15
+ * and an opening bracket, since a name's short form in brackets right after it is the same name (Office of the Comptroller (OCC)).
16
+ */
17
+ const INSIDE_NAME = /^[\s\-‐/.&'’((]*$/u;
18
+ const LATIN = /\p{Script=Latin}/u;
19
+ const CAPITAL = /\p{Lu}/u;
20
+ const LETTER = /\p{L}/u;
21
+ const LOWER_START = /^\p{Ll}/u;
22
+ const CONTENT: ReadonlySet<string> = new Set(["NOUN", "ADJ", "ADV"]);
23
+
24
+ /**
25
+ * A word only prose has: a verb in lower case or in a script without case (a capitalised one is a title's: Arrangements to
26
+ * Deliver Services), or any other lower-case content word, since the tagger can read a verb among many names as a noun (flew).
27
+ */
28
+ const isProseWord = (token: Token): boolean => {
29
+ if (PREDICATES.has(token.pos)) return !CAPITAL.test(token.surface.charAt(0));
30
+ return CONTENT.has(token.pos) && LATIN.test(token.surface) && LOWER_START.test(token.surface);
31
+ };
32
+
33
+ /** A sentence may open with its verb (Moved by D. Kim, ...; Meet Alice at Contoso.). */
34
+ const opensWithVerb = (tokens: readonly Token[]): boolean => {
35
+ const first = tokens.find((token) => LETTER.test(token.surface));
36
+ return first !== undefined && PREDICATES.has(first.pos);
37
+ };
38
+
39
+ /**
40
+ * A sentence with no word of prose is a line, not prose: a letterhead, a roster, a signature, an address, a heading, a list of
41
+ * document titles or a table row read as text. A reader does not parse it as a sentence, so its names hide no sentence's shape.
42
+ */
43
+ export const isProse = (sentence: Sentence): boolean => {
44
+ const tokens = sentence.tokens ?? [];
45
+ return opensWithVerb(tokens) || tokens.some(isProseWord);
46
+ };
47
+
48
+ /** A Latin word with no capital is no name, whatever the tagger said: the Japanese tagger marks English words (rule, requests) as proper nouns. */
49
+ const isNameWord = (token: Token): boolean => token.pos === "PROPN" && !(LATIN.test(token.surface) && !CAPITAL.test(token.surface));
50
+
51
+ const within = (spans: readonly Span[], token: Token): Span | undefined => spans.find((span) => token.span.start >= span.start && token.span.end <= span.end);
52
+
53
+ const spansIn = (sentence: Sentence, names: readonly string[]): Span[] =>
54
+ nameSpans(sentence.text, names).map((span) => ({ start: sentence.span.start + span.start, end: sentence.span.start + span.end }));
55
+
56
+ const between = (sentence: Sentence, end: number, start: number): string => sentence.text.slice(end - sentence.span.start, start - sentence.span.start);
57
+
58
+ /** The first word of each name: adjacent name words (Federal Reserve System, 赤堀 政明, Randall D. Guynn) are one name. */
59
+ const nameStarts = (sentence: Sentence, everyday: readonly Span[]): Token[] => {
60
+ const words = (sentence.tokens ?? []).filter((token) => isNameWord(token) && within(everyday, token) === undefined);
61
+ return words.filter((token, index) => {
62
+ const previous = words[index - 1];
63
+ return previous === undefined || !INSIDE_NAME.test(between(sentence, previous.span.end, token.span.start));
64
+ });
65
+ };
66
+
67
+ const tokensWithin = (sentence: Sentence, span: Span): Token[] =>
68
+ (sentence.tokens ?? []).filter((token) => token.span.start >= span.start && token.span.end <= span.end);
69
+
70
+ /** Quoted words with no word of prose are a title: “Joint Statement on the Risk-Based Approach to Assessing Customer Relationships” is one name. */
71
+ const titlesIn = (sentence: Sentence): Span[] => quotedIn(sentence, QUOTATION_MARKS).filter((span) => !tokensWithin(sentence, span).some(isProseWord));
72
+
73
+ /**
74
+ * The names one sentence counts. A name the team listed in chaff.yaml is one, however many names the words in it make
75
+ * (Bank of England is one, not two), and so is a quoted title.
76
+ */
77
+ export const namesIn = (sentence: Sentence, listed: readonly string[], everyday: readonly string[]): Token[] => {
78
+ const named = [...spansIn(sentence, listed), ...titlesIn(sentence)];
79
+ const counted = new Set<Span>();
80
+ return nameStarts(sentence, spansIn(sentence, everyday)).filter((token) => {
81
+ const name = within(named, token);
82
+ if (name === undefined) return true;
83
+ if (counted.has(name)) return false;
84
+ counted.add(name);
85
+ return true;
86
+ });
87
+ };
88
+
89
+ const everydayNamesOf = (doc: ProseDocument): string[] => (doc.lexicons[EVERYDAY_NAME] ?? []).map((entry) => entry.pattern);
90
+
91
+ export const properNounDensity: Detector = (doc, options): Finding[] => {
92
+ const prose = doc.sentences.filter(isProse);
93
+ const everyday = everydayNamesOf(doc);
94
+ const hits = prose.flatMap((sentence) => namesIn(sentence, doc.names ?? [], everyday).map((token) => ({ sentence, token })));
95
+ const length = prose.reduce((sum, sentence) => sum + lengthOf(sentence, doc.lengthUnit), 0);
96
+ const rate = length === 0 ? 0 : Math.round((hits.length / length) * PER);
97
+ const first = hits[0];
98
+ if (length < FLOOR[doc.lengthUnit] || first === undefined || rate <= options.limit) return [];
99
+ return [
100
+ {
101
+ rule: "proper-noun-density",
102
+ severity: "info",
103
+ line: 0,
104
+ column: 0,
105
+ quote: proseText(first.sentence),
106
+ values: { count: hits.length, density: rate, limit: options.limit, offset: first.token.span.start },
107
+ },
108
+ ];
109
+ };