chaffjs 0.38.0 → 0.39.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 (675) hide show
  1. package/README.ja.md +20 -4
  2. package/README.md +19 -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 +53 -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/body-section.d.ts +3 -1
  15. package/dist/body-section.d.ts.map +1 -1
  16. package/dist/body-section.js +9 -2
  17. package/dist/body-section.js.map +1 -1
  18. package/dist/capitals-with-small.d.ts +5 -0
  19. package/dist/capitals-with-small.d.ts.map +1 -1
  20. package/dist/capitals-with-small.js +15 -0
  21. package/dist/capitals-with-small.js.map +1 -1
  22. package/dist/checks.d.ts +11 -0
  23. package/dist/checks.d.ts.map +1 -1
  24. package/dist/checks.js +27 -1
  25. package/dist/checks.js.map +1 -1
  26. package/dist/cli-args.js +1 -1
  27. package/dist/cli-args.js.map +1 -1
  28. package/dist/cli-text.d.ts.map +1 -1
  29. package/dist/cli-text.js +4 -0
  30. package/dist/cli-text.js.map +1 -1
  31. package/dist/commands/fix-plan.d.ts.map +1 -1
  32. package/dist/commands/fix-plan.js +64 -4
  33. package/dist/commands/fix-plan.js.map +1 -1
  34. package/dist/commands/test.d.ts.map +1 -1
  35. package/dist/commands/test.js +16 -2
  36. package/dist/commands/test.js.map +1 -1
  37. package/dist/detectors/acronym-context.d.ts +4 -1
  38. package/dist/detectors/acronym-context.d.ts.map +1 -1
  39. package/dist/detectors/acronym-context.js +16 -2
  40. package/dist/detectors/acronym-context.js.map +1 -1
  41. package/dist/detectors/acronym-expansion.d.ts.map +1 -1
  42. package/dist/detectors/acronym-expansion.js +25 -0
  43. package/dist/detectors/acronym-expansion.js.map +1 -1
  44. package/dist/detectors/acronym-gloss.d.ts +19 -0
  45. package/dist/detectors/acronym-gloss.d.ts.map +1 -1
  46. package/dist/detectors/acronym-gloss.js +115 -0
  47. package/dist/detectors/acronym-gloss.js.map +1 -1
  48. package/dist/detectors/acronym-name.d.ts +9 -2
  49. package/dist/detectors/acronym-name.d.ts.map +1 -1
  50. package/dist/detectors/acronym-name.js +13 -3
  51. package/dist/detectors/acronym-name.js.map +1 -1
  52. package/dist/detectors/acronym-series.d.ts +7 -0
  53. package/dist/detectors/acronym-series.d.ts.map +1 -0
  54. package/dist/detectors/acronym-series.js +25 -0
  55. package/dist/detectors/acronym-series.js.map +1 -0
  56. package/dist/detectors/ai-phrasing.d.ts +3 -6
  57. package/dist/detectors/ai-phrasing.d.ts.map +1 -1
  58. package/dist/detectors/ai-phrasing.js +17 -16
  59. package/dist/detectors/ai-phrasing.js.map +1 -1
  60. package/dist/detectors/ai-structure.d.ts +1 -0
  61. package/dist/detectors/ai-structure.d.ts.map +1 -1
  62. package/dist/detectors/ai-structure.js +15 -4
  63. package/dist/detectors/ai-structure.js.map +1 -1
  64. package/dist/detectors/alnum-number.d.ts +1 -0
  65. package/dist/detectors/alnum-number.d.ts.map +1 -1
  66. package/dist/detectors/alnum-number.js +7 -3
  67. package/dist/detectors/alnum-number.js.map +1 -1
  68. package/dist/detectors/bare-comparative.d.ts +6 -0
  69. package/dist/detectors/bare-comparative.d.ts.map +1 -1
  70. package/dist/detectors/bare-comparative.js +31 -12
  71. package/dist/detectors/bare-comparative.js.map +1 -1
  72. package/dist/detectors/bold-emphasis-form.d.ts +8 -0
  73. package/dist/detectors/bold-emphasis-form.d.ts.map +1 -0
  74. package/dist/detectors/bold-emphasis-form.js +40 -0
  75. package/dist/detectors/bold-emphasis-form.js.map +1 -0
  76. package/dist/detectors/bold-emphasis.d.ts +0 -1
  77. package/dist/detectors/bold-emphasis.d.ts.map +1 -1
  78. package/dist/detectors/bold-emphasis.js +14 -12
  79. package/dist/detectors/bold-emphasis.js.map +1 -1
  80. package/dist/detectors/caps-caption.d.ts +5 -0
  81. package/dist/detectors/caps-caption.d.ts.map +1 -1
  82. package/dist/detectors/caps-caption.js +20 -2
  83. package/dist/detectors/caps-caption.js.map +1 -1
  84. package/dist/detectors/char-shape.d.ts.map +1 -1
  85. package/dist/detectors/char-shape.js +86 -27
  86. package/dist/detectors/char-shape.js.map +1 -1
  87. package/dist/detectors/chat-log-line.d.ts +8 -0
  88. package/dist/detectors/chat-log-line.d.ts.map +1 -0
  89. package/dist/detectors/chat-log-line.js +13 -0
  90. package/dist/detectors/chat-log-line.js.map +1 -0
  91. package/dist/detectors/citation-string.d.ts +3 -0
  92. package/dist/detectors/citation-string.d.ts.map +1 -0
  93. package/dist/detectors/citation-string.js +34 -0
  94. package/dist/detectors/citation-string.js.map +1 -0
  95. package/dist/detectors/closing-cliche.d.ts +18 -0
  96. package/dist/detectors/closing-cliche.d.ts.map +1 -0
  97. package/dist/detectors/closing-cliche.js +58 -0
  98. package/dist/detectors/closing-cliche.js.map +1 -0
  99. package/dist/detectors/closing-exhortation.d.ts +18 -0
  100. package/dist/detectors/closing-exhortation.d.ts.map +1 -0
  101. package/dist/detectors/closing-exhortation.js +55 -0
  102. package/dist/detectors/closing-exhortation.js.map +1 -0
  103. package/dist/detectors/cold-open.d.ts +25 -0
  104. package/dist/detectors/cold-open.d.ts.map +1 -0
  105. package/dist/detectors/cold-open.js +121 -0
  106. package/dist/detectors/cold-open.js.map +1 -0
  107. package/dist/detectors/comparative-context.d.ts +21 -0
  108. package/dist/detectors/comparative-context.d.ts.map +1 -0
  109. package/dist/detectors/comparative-context.js +57 -0
  110. package/dist/detectors/comparative-context.js.map +1 -0
  111. package/dist/detectors/concrete-evidence-density.d.ts +3 -0
  112. package/dist/detectors/concrete-evidence-density.d.ts.map +1 -0
  113. package/dist/detectors/concrete-evidence-density.js +75 -0
  114. package/dist/detectors/concrete-evidence-density.js.map +1 -0
  115. package/dist/detectors/concrete-evidence.d.ts +14 -0
  116. package/dist/detectors/concrete-evidence.d.ts.map +1 -1
  117. package/dist/detectors/concrete-evidence.js +24 -0
  118. package/dist/detectors/concrete-evidence.js.map +1 -1
  119. package/dist/detectors/contrast-frame.d.ts +5 -0
  120. package/dist/detectors/contrast-frame.d.ts.map +1 -1
  121. package/dist/detectors/contrast-frame.js +53 -6
  122. package/dist/detectors/contrast-frame.js.map +1 -1
  123. package/dist/detectors/coordinate-adjective.d.ts +2 -1
  124. package/dist/detectors/coordinate-adjective.d.ts.map +1 -1
  125. package/dist/detectors/coordinate-adjective.js +4 -2
  126. package/dist/detectors/coordinate-adjective.js.map +1 -1
  127. package/dist/detectors/duplicate-heading.d.ts +4 -2
  128. package/dist/detectors/duplicate-heading.d.ts.map +1 -1
  129. package/dist/detectors/duplicate-heading.js +35 -11
  130. package/dist/detectors/duplicate-heading.js.map +1 -1
  131. package/dist/detectors/email-frame-words.d.ts +10 -0
  132. package/dist/detectors/email-frame-words.d.ts.map +1 -0
  133. package/dist/detectors/email-frame-words.js +34 -0
  134. package/dist/detectors/email-frame-words.js.map +1 -0
  135. package/dist/detectors/email-letter.d.ts +3 -7
  136. package/dist/detectors/email-letter.d.ts.map +1 -1
  137. package/dist/detectors/email-letter.js +13 -21
  138. package/dist/detectors/email-letter.js.map +1 -1
  139. package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
  140. package/dist/detectors/fullwidth-alnum.js +20 -4
  141. package/dist/detectors/fullwidth-alnum.js.map +1 -1
  142. package/dist/detectors/gram-furniture.d.ts +18 -1
  143. package/dist/detectors/gram-furniture.d.ts.map +1 -1
  144. package/dist/detectors/gram-furniture.js +71 -0
  145. package/dist/detectors/gram-furniture.js.map +1 -1
  146. package/dist/detectors/gram-openers.d.ts +16 -0
  147. package/dist/detectors/gram-openers.d.ts.map +1 -1
  148. package/dist/detectors/gram-openers.js +52 -0
  149. package/dist/detectors/gram-openers.js.map +1 -1
  150. package/dist/detectors/gram-predicate.d.ts.map +1 -1
  151. package/dist/detectors/gram-predicate.js +40 -7
  152. package/dist/detectors/gram-predicate.js.map +1 -1
  153. package/dist/detectors/gram-repetition.d.ts +3 -0
  154. package/dist/detectors/gram-repetition.d.ts.map +1 -0
  155. package/dist/detectors/gram-repetition.js +158 -0
  156. package/dist/detectors/gram-repetition.js.map +1 -0
  157. package/dist/detectors/heading-level-skip.d.ts +6 -0
  158. package/dist/detectors/heading-level-skip.d.ts.map +1 -1
  159. package/dist/detectors/heading-level-skip.js +24 -1
  160. package/dist/detectors/heading-level-skip.js.map +1 -1
  161. package/dist/detectors/heading-numbering.js +2 -2
  162. package/dist/detectors/heading-numbering.js.map +1 -1
  163. package/dist/detectors/hyphen-copied-text.d.ts +3 -0
  164. package/dist/detectors/hyphen-copied-text.d.ts.map +1 -0
  165. package/dist/detectors/hyphen-copied-text.js +49 -0
  166. package/dist/detectors/hyphen-copied-text.js.map +1 -0
  167. package/dist/detectors/kanji-name-edge.d.ts +15 -0
  168. package/dist/detectors/kanji-name-edge.d.ts.map +1 -1
  169. package/dist/detectors/kanji-name-edge.js +30 -0
  170. package/dist/detectors/kanji-name-edge.js.map +1 -1
  171. package/dist/detectors/kanji-run-pieces.d.ts +7 -0
  172. package/dist/detectors/kanji-run-pieces.d.ts.map +1 -1
  173. package/dist/detectors/kanji-run-pieces.js +14 -4
  174. package/dist/detectors/kanji-run-pieces.js.map +1 -1
  175. package/dist/detectors/kutoten-consistency.d.ts.map +1 -1
  176. package/dist/detectors/kutoten-consistency.js +22 -4
  177. package/dist/detectors/kutoten-consistency.js.map +1 -1
  178. package/dist/detectors/lead-in-dash.d.ts +5 -0
  179. package/dist/detectors/lead-in-dash.d.ts.map +1 -1
  180. package/dist/detectors/lead-in-dash.js +9 -0
  181. package/dist/detectors/lead-in-dash.js.map +1 -1
  182. package/dist/detectors/letter-joined-name.d.ts +2 -0
  183. package/dist/detectors/letter-joined-name.d.ts.map +1 -1
  184. package/dist/detectors/letter-joined-name.js +8 -0
  185. package/dist/detectors/letter-joined-name.js.map +1 -1
  186. package/dist/detectors/lexicon.d.ts.map +1 -1
  187. package/dist/detectors/lexicon.js +11 -2
  188. package/dist/detectors/lexicon.js.map +1 -1
  189. package/dist/detectors/list-item.d.ts +14 -0
  190. package/dist/detectors/list-item.d.ts.map +1 -1
  191. package/dist/detectors/list-item.js +30 -1
  192. package/dist/detectors/list-item.js.map +1 -1
  193. package/dist/detectors/list-items.d.ts +1 -1
  194. package/dist/detectors/list-items.d.ts.map +1 -1
  195. package/dist/detectors/list-items.js +2 -0
  196. package/dist/detectors/list-items.js.map +1 -1
  197. package/dist/detectors/list-joint.d.ts +18 -0
  198. package/dist/detectors/list-joint.d.ts.map +1 -0
  199. package/dist/detectors/list-joint.js +42 -0
  200. package/dist/detectors/list-joint.js.map +1 -0
  201. package/dist/detectors/list-layout.d.ts +14 -0
  202. package/dist/detectors/list-layout.d.ts.map +1 -0
  203. package/dist/detectors/list-layout.js +29 -0
  204. package/dist/detectors/list-layout.js.map +1 -0
  205. package/dist/detectors/list-lead-in.d.ts +6 -1
  206. package/dist/detectors/list-lead-in.d.ts.map +1 -1
  207. package/dist/detectors/list-lead-in.js +42 -2
  208. package/dist/detectors/list-lead-in.js.map +1 -1
  209. package/dist/detectors/list-parallel.d.ts +6 -0
  210. package/dist/detectors/list-parallel.d.ts.map +1 -1
  211. package/dist/detectors/list-parallel.js +106 -13
  212. package/dist/detectors/list-parallel.js.map +1 -1
  213. package/dist/detectors/list-run.d.ts +13 -0
  214. package/dist/detectors/list-run.d.ts.map +1 -0
  215. package/dist/detectors/list-run.js +80 -0
  216. package/dist/detectors/list-run.js.map +1 -0
  217. package/dist/detectors/list-sentence.d.ts +11 -0
  218. package/dist/detectors/list-sentence.d.ts.map +1 -1
  219. package/dist/detectors/list-sentence.js +1 -0
  220. package/dist/detectors/list-sentence.js.map +1 -1
  221. package/dist/detectors/mark-shape.d.ts +2 -1
  222. package/dist/detectors/mark-shape.d.ts.map +1 -1
  223. package/dist/detectors/mark-shape.js +10 -6
  224. package/dist/detectors/mark-shape.js.map +1 -1
  225. package/dist/detectors/name-run.d.ts +2 -0
  226. package/dist/detectors/name-run.d.ts.map +1 -1
  227. package/dist/detectors/name-run.js +1 -1
  228. package/dist/detectors/name-run.js.map +1 -1
  229. package/dist/detectors/name-variant-two-things.d.ts +18 -0
  230. package/dist/detectors/name-variant-two-things.d.ts.map +1 -0
  231. package/dist/detectors/name-variant-two-things.js +84 -0
  232. package/dist/detectors/name-variant-two-things.js.map +1 -0
  233. package/dist/detectors/name-variant.d.ts.map +1 -1
  234. package/dist/detectors/name-variant.js +14 -15
  235. package/dist/detectors/name-variant.js.map +1 -1
  236. package/dist/detectors/organisation-run.d.ts +6 -0
  237. package/dist/detectors/organisation-run.d.ts.map +1 -1
  238. package/dist/detectors/organisation-run.js +26 -2
  239. package/dist/detectors/organisation-run.js.map +1 -1
  240. package/dist/detectors/orthographic-variant-open.d.ts +35 -0
  241. package/dist/detectors/orthographic-variant-open.d.ts.map +1 -0
  242. package/dist/detectors/orthographic-variant-open.js +79 -0
  243. package/dist/detectors/orthographic-variant-open.js.map +1 -0
  244. package/dist/detectors/orthographic-variant.d.ts.map +1 -1
  245. package/dist/detectors/orthographic-variant.js +55 -59
  246. package/dist/detectors/orthographic-variant.js.map +1 -1
  247. package/dist/detectors/over-general-claim.d.ts.map +1 -1
  248. package/dist/detectors/over-general-claim.js +82 -4
  249. package/dist/detectors/over-general-claim.js.map +1 -1
  250. package/dist/detectors/oxford-comma.d.ts.map +1 -1
  251. package/dist/detectors/oxford-comma.js +61 -27
  252. package/dist/detectors/oxford-comma.js.map +1 -1
  253. package/dist/detectors/particle-run-names.d.ts +8 -0
  254. package/dist/detectors/particle-run-names.d.ts.map +1 -0
  255. package/dist/detectors/particle-run-names.js +17 -0
  256. package/dist/detectors/particle-run-names.js.map +1 -0
  257. package/dist/detectors/proper-noun-density.d.ts +13 -0
  258. package/dist/detectors/proper-noun-density.d.ts.map +1 -0
  259. package/dist/detectors/proper-noun-density.js +97 -0
  260. package/dist/detectors/proper-noun-density.js.map +1 -0
  261. package/dist/detectors/quoted-excerpt.d.ts +13 -0
  262. package/dist/detectors/quoted-excerpt.d.ts.map +1 -0
  263. package/dist/detectors/quoted-excerpt.js +53 -0
  264. package/dist/detectors/quoted-excerpt.js.map +1 -0
  265. package/dist/detectors/reference-entry.d.ts +7 -0
  266. package/dist/detectors/reference-entry.d.ts.map +1 -0
  267. package/dist/detectors/reference-entry.js +35 -0
  268. package/dist/detectors/reference-entry.js.map +1 -0
  269. package/dist/detectors/register-neutral-shape.d.ts +5 -2
  270. package/dist/detectors/register-neutral-shape.d.ts.map +1 -1
  271. package/dist/detectors/register-neutral-shape.js +21 -4
  272. package/dist/detectors/register-neutral-shape.js.map +1 -1
  273. package/dist/detectors/register-set-apart.d.ts +24 -0
  274. package/dist/detectors/register-set-apart.d.ts.map +1 -0
  275. package/dist/detectors/register-set-apart.js +102 -0
  276. package/dist/detectors/register-set-apart.js.map +1 -0
  277. package/dist/detectors/register-voice.d.ts +14 -0
  278. package/dist/detectors/register-voice.d.ts.map +1 -0
  279. package/dist/detectors/register-voice.js +47 -0
  280. package/dist/detectors/register-voice.js.map +1 -0
  281. package/dist/detectors/register.d.ts +5 -0
  282. package/dist/detectors/register.d.ts.map +1 -1
  283. package/dist/detectors/register.js +13 -0
  284. package/dist/detectors/register.js.map +1 -1
  285. package/dist/detectors/registry/closing-cliche.d.ts +3 -0
  286. package/dist/detectors/registry/closing-cliche.d.ts.map +1 -0
  287. package/dist/detectors/registry/closing-cliche.js +3 -0
  288. package/dist/detectors/registry/closing-cliche.js.map +1 -0
  289. package/dist/detectors/registry/closing-exhortation.d.ts +3 -0
  290. package/dist/detectors/registry/closing-exhortation.d.ts.map +1 -0
  291. package/dist/detectors/registry/closing-exhortation.js +3 -0
  292. package/dist/detectors/registry/closing-exhortation.js.map +1 -0
  293. package/dist/detectors/registry/cold-open.d.ts +3 -0
  294. package/dist/detectors/registry/cold-open.d.ts.map +1 -0
  295. package/dist/detectors/registry/cold-open.js +3 -0
  296. package/dist/detectors/registry/cold-open.js.map +1 -0
  297. package/dist/detectors/registry/colon-lead-in.js +1 -1
  298. package/dist/detectors/registry/colon-lead-in.js.map +1 -1
  299. package/dist/detectors/registry/concrete-evidence.js +1 -1
  300. package/dist/detectors/registry/concrete-evidence.js.map +1 -1
  301. package/dist/detectors/registry/ngram-repetition.js +1 -1
  302. package/dist/detectors/registry/ngram-repetition.js.map +1 -1
  303. package/dist/detectors/registry/proper-noun-density.js +1 -1
  304. package/dist/detectors/registry/proper-noun-density.js.map +1 -1
  305. package/dist/detectors/registry/topic-predicate-distance.js +1 -1
  306. package/dist/detectors/registry/topic-predicate-distance.js.map +1 -1
  307. package/dist/detectors/registry/unprompted-denial.d.ts +3 -0
  308. package/dist/detectors/registry/unprompted-denial.d.ts.map +1 -0
  309. package/dist/detectors/registry/unprompted-denial.js +3 -0
  310. package/dist/detectors/registry/unprompted-denial.js.map +1 -0
  311. package/dist/detectors/sentence-ending.d.ts +6 -1
  312. package/dist/detectors/sentence-ending.d.ts.map +1 -1
  313. package/dist/detectors/sentence-ending.js +42 -9
  314. package/dist/detectors/sentence-ending.js.map +1 -1
  315. package/dist/detectors/sentence-length.d.ts.map +1 -1
  316. package/dist/detectors/sentence-length.js +25 -10
  317. package/dist/detectors/sentence-length.js.map +1 -1
  318. package/dist/detectors/sentence-load.d.ts +5 -3
  319. package/dist/detectors/sentence-load.d.ts.map +1 -1
  320. package/dist/detectors/sentence-load.js +3 -5
  321. package/dist/detectors/sentence-load.js.map +1 -1
  322. package/dist/detectors/sentence-parts.d.ts +9 -0
  323. package/dist/detectors/sentence-parts.d.ts.map +1 -0
  324. package/dist/detectors/sentence-parts.js +62 -0
  325. package/dist/detectors/sentence-parts.js.map +1 -0
  326. package/dist/detectors/sentence-title.d.ts +3 -0
  327. package/dist/detectors/sentence-title.d.ts.map +1 -1
  328. package/dist/detectors/sentence-title.js +10 -0
  329. package/dist/detectors/sentence-title.js.map +1 -1
  330. package/dist/detectors/signals.d.ts +0 -2
  331. package/dist/detectors/signals.d.ts.map +1 -1
  332. package/dist/detectors/signals.js +12 -163
  333. package/dist/detectors/signals.js.map +1 -1
  334. package/dist/detectors/structure-tree.d.ts.map +1 -1
  335. package/dist/detectors/structure-tree.js +1 -1
  336. package/dist/detectors/structure-tree.js.map +1 -1
  337. package/dist/detectors/structure.d.ts +9 -1
  338. package/dist/detectors/structure.d.ts.map +1 -1
  339. package/dist/detectors/structure.js +24 -11
  340. package/dist/detectors/structure.js.map +1 -1
  341. package/dist/detectors/superlative-clause.d.ts.map +1 -1
  342. package/dist/detectors/superlative-clause.js +19 -2
  343. package/dist/detectors/superlative-clause.js.map +1 -1
  344. package/dist/detectors/superlative-context.d.ts +35 -0
  345. package/dist/detectors/superlative-context.d.ts.map +1 -0
  346. package/dist/detectors/superlative-context.js +71 -0
  347. package/dist/detectors/superlative-context.js.map +1 -0
  348. package/dist/detectors/superlative-scope.d.ts +6 -2
  349. package/dist/detectors/superlative-scope.d.ts.map +1 -1
  350. package/dist/detectors/superlative-scope.js +20 -6
  351. package/dist/detectors/superlative-scope.js.map +1 -1
  352. package/dist/detectors/team.d.ts +0 -1
  353. package/dist/detectors/team.d.ts.map +1 -1
  354. package/dist/detectors/team.js +0 -46
  355. package/dist/detectors/team.js.map +1 -1
  356. package/dist/detectors/titled-code-citation.d.ts +12 -0
  357. package/dist/detectors/titled-code-citation.d.ts.map +1 -0
  358. package/dist/detectors/titled-code-citation.js +11 -0
  359. package/dist/detectors/titled-code-citation.js.map +1 -0
  360. package/dist/detectors/titled-run.d.ts +8 -1
  361. package/dist/detectors/titled-run.d.ts.map +1 -1
  362. package/dist/detectors/titled-run.js +14 -4
  363. package/dist/detectors/titled-run.js.map +1 -1
  364. package/dist/detectors/token-shape.d.ts.map +1 -1
  365. package/dist/detectors/token-shape.js +22 -11
  366. package/dist/detectors/token-shape.js.map +1 -1
  367. package/dist/detectors/topic-predicate-distance.d.ts +4 -0
  368. package/dist/detectors/topic-predicate-distance.d.ts.map +1 -0
  369. package/dist/detectors/topic-predicate-distance.js +22 -0
  370. package/dist/detectors/topic-predicate-distance.js.map +1 -0
  371. package/dist/detectors/unknown-word-context.d.ts +28 -0
  372. package/dist/detectors/unknown-word-context.d.ts.map +1 -0
  373. package/dist/detectors/unknown-word-context.js +89 -0
  374. package/dist/detectors/unknown-word-context.js.map +1 -0
  375. package/dist/detectors/unknown-word.d.ts +0 -5
  376. package/dist/detectors/unknown-word.d.ts.map +1 -1
  377. package/dist/detectors/unknown-word.js +16 -19
  378. package/dist/detectors/unknown-word.js.map +1 -1
  379. package/dist/detectors/unprompted-denial.d.ts +25 -0
  380. package/dist/detectors/unprompted-denial.d.ts.map +1 -0
  381. package/dist/detectors/unprompted-denial.js +100 -0
  382. package/dist/detectors/unprompted-denial.js.map +1 -0
  383. package/dist/document-sections.d.ts.map +1 -1
  384. package/dist/document-sections.js +3 -1
  385. package/dist/document-sections.js.map +1 -1
  386. package/dist/fix-plan/all-signs.d.ts +17 -0
  387. package/dist/fix-plan/all-signs.d.ts.map +1 -0
  388. package/dist/fix-plan/all-signs.js +26 -0
  389. package/dist/fix-plan/all-signs.js.map +1 -0
  390. package/dist/fix-plan/plan.d.ts +31 -0
  391. package/dist/fix-plan/plan.d.ts.map +1 -1
  392. package/dist/fix-plan/plan.js +23 -3
  393. package/dist/fix-plan/plan.js.map +1 -1
  394. package/dist/fix-plan/render.d.ts.map +1 -1
  395. package/dist/fix-plan/render.js +31 -2
  396. package/dist/fix-plan/render.js.map +1 -1
  397. package/dist/fix-plan/risen.d.ts +10 -0
  398. package/dist/fix-plan/risen.d.ts.map +1 -0
  399. package/dist/fix-plan/risen.js +7 -0
  400. package/dist/fix-plan/risen.js.map +1 -0
  401. package/dist/fix-plan/text.d.ts +15 -0
  402. package/dist/fix-plan/text.d.ts.map +1 -1
  403. package/dist/fix-plan/text.js +38 -2
  404. package/dist/fix-plan/text.js.map +1 -1
  405. package/dist/heading-numbering.d.ts +2 -1
  406. package/dist/heading-numbering.d.ts.map +1 -1
  407. package/dist/heading-numbering.js +40 -10
  408. package/dist/heading-numbering.js.map +1 -1
  409. package/dist/html/html-site-chrome.d.ts.map +1 -1
  410. package/dist/html/html-site-chrome.js +7 -2
  411. package/dist/html/html-site-chrome.js.map +1 -1
  412. package/dist/law-title.d.ts +7 -0
  413. package/dist/law-title.d.ts.map +1 -0
  414. package/dist/law-title.js +29 -0
  415. package/dist/law-title.js.map +1 -0
  416. package/dist/name-ending-run.d.ts +11 -0
  417. package/dist/name-ending-run.d.ts.map +1 -0
  418. package/dist/name-ending-run.js +37 -0
  419. package/dist/name-ending-run.js.map +1 -0
  420. package/dist/name-title-slip.d.ts +11 -0
  421. package/dist/name-title-slip.d.ts.map +1 -0
  422. package/dist/name-title-slip.js +51 -0
  423. package/dist/name-title-slip.js.map +1 -0
  424. package/dist/name-variant-shapes.d.ts +14 -0
  425. package/dist/name-variant-shapes.d.ts.map +1 -0
  426. package/dist/name-variant-shapes.js +43 -0
  427. package/dist/name-variant-shapes.js.map +1 -0
  428. package/dist/name-word-use.d.ts +5 -0
  429. package/dist/name-word-use.d.ts.map +1 -0
  430. package/dist/name-word-use.js +12 -0
  431. package/dist/name-word-use.js.map +1 -0
  432. package/dist/opening-passage.d.ts +8 -0
  433. package/dist/opening-passage.d.ts.map +1 -0
  434. package/dist/opening-passage.js +24 -0
  435. package/dist/opening-passage.js.map +1 -0
  436. package/dist/plugin.d.ts +2 -0
  437. package/dist/plugin.d.ts.map +1 -1
  438. package/dist/quote-gloss.d.ts +4 -0
  439. package/dist/quote-gloss.d.ts.map +1 -0
  440. package/dist/quote-gloss.js +7 -0
  441. package/dist/quote-gloss.js.map +1 -0
  442. package/dist/quoted-spelling.d.ts +17 -0
  443. package/dist/quoted-spelling.d.ts.map +1 -0
  444. package/dist/quoted-spelling.js +27 -0
  445. package/dist/quoted-spelling.js.map +1 -0
  446. package/dist/render/semantic.d.ts +1 -1
  447. package/dist/render/semantic.d.ts.map +1 -1
  448. package/dist/render/semantic.js +2 -1
  449. package/dist/render/semantic.js.map +1 -1
  450. package/dist/rule-of-three.d.ts +19 -0
  451. package/dist/rule-of-three.d.ts.map +1 -0
  452. package/dist/rule-of-three.js +33 -0
  453. package/dist/rule-of-three.js.map +1 -0
  454. package/dist/run-semantic.d.ts.map +1 -1
  455. package/dist/run-semantic.js +2 -2
  456. package/dist/run-semantic.js.map +1 -1
  457. package/dist/section-levels.d.ts +18 -0
  458. package/dist/section-levels.d.ts.map +1 -0
  459. package/dist/section-levels.js +80 -0
  460. package/dist/section-levels.js.map +1 -0
  461. package/dist/semantic.d.ts +2 -0
  462. package/dist/semantic.d.ts.map +1 -1
  463. package/dist/semantic.js +13 -0
  464. package/dist/semantic.js.map +1 -1
  465. package/dist/sentence-load.d.ts +2 -1
  466. package/dist/sentence-load.d.ts.map +1 -1
  467. package/dist/sentence-load.js +4 -2
  468. package/dist/sentence-load.js.map +1 -1
  469. package/dist/spelling.d.ts +11 -0
  470. package/dist/spelling.d.ts.map +1 -1
  471. package/dist/spelling.js +19 -5
  472. package/dist/spelling.js.map +1 -1
  473. package/dist/structure/cited-document-section.d.ts.map +1 -1
  474. package/dist/structure/cited-document-section.js +15 -1
  475. package/dist/structure/cited-document-section.js.map +1 -1
  476. package/dist/structure/issues.d.ts +1 -1
  477. package/dist/structure/issues.d.ts.map +1 -1
  478. package/dist/structure/issues.js +5 -1
  479. package/dist/structure/issues.js.map +1 -1
  480. package/dist/structure-shape/template-outline.d.ts +11 -0
  481. package/dist/structure-shape/template-outline.d.ts.map +1 -0
  482. package/dist/structure-shape/template-outline.js +25 -0
  483. package/dist/structure-shape/template-outline.js.map +1 -0
  484. package/dist/title-case-name.d.ts +12 -0
  485. package/dist/title-case-name.d.ts.map +1 -0
  486. package/dist/title-case-name.js +37 -0
  487. package/dist/title-case-name.js.map +1 -0
  488. package/dist/topic-clause.d.ts +6 -1
  489. package/dist/topic-clause.d.ts.map +1 -1
  490. package/dist/topic-clause.js +77 -3
  491. package/dist/topic-clause.js.map +1 -1
  492. package/dist/word-use.d.ts +12 -4
  493. package/dist/word-use.d.ts.map +1 -1
  494. package/dist/word-use.js +47 -5
  495. package/dist/word-use.js.map +1 -1
  496. package/package.json +4 -3
  497. package/rules/ai-generated-composite.yaml +11 -3
  498. package/rules/ai-structure.yaml +7 -6
  499. package/rules/ai-tell.yaml +4 -4
  500. package/rules/all-caps-shouting.yaml +2 -2
  501. package/rules/bold-emphasis.yaml +5 -4
  502. package/rules/closing-cliche.yaml +4 -5
  503. package/rules/closing-exhortation.yaml +74 -0
  504. package/rules/cold-open.yaml +95 -0
  505. package/rules/colon-lead-in.yaml +68 -10
  506. package/rules/comparative-without-baseline.yaml +2 -2
  507. package/rules/concrete-evidence-density.yaml +2 -2
  508. package/rules/contrast-framing.yaml +16 -13
  509. package/rules/dangling-reference.yaml +2 -2
  510. package/rules/duplicate-heading.yaml +5 -2
  511. package/rules/email-greeting-closing.yaml +2 -2
  512. package/rules/email-stock-courtesy.yaml +62 -0
  513. package/rules/fullwidth-alnum-consistency.yaml +2 -2
  514. package/rules/generic-opening.yaml +63 -0
  515. package/rules/heading-level-skip.yaml +2 -2
  516. package/rules/heading-numbering-mix.yaml +20 -20
  517. package/rules/hyphen-as-dash.yaml +2 -2
  518. package/rules/kutoten-consistency.yaml +4 -4
  519. package/rules/list-item-form-mix.yaml +2 -2
  520. package/rules/max-kanji-continuous.yaml +7 -3
  521. package/rules/max-sentence-length.yaml +4 -2
  522. package/rules/name-variant.yaml +5 -2
  523. package/rules/ngram-repetition.yaml +2 -2
  524. package/rules/no-doubled-joshi.yaml +2 -2
  525. package/rules/no-em-dash.yaml +2 -2
  526. package/rules/no-mixed-desumasu.yaml +16 -3
  527. package/rules/orthographic-variant.yaml +2 -2
  528. package/rules/over-general-claim.yaml +2 -2
  529. package/rules/oxford-comma-consistency.yaml +15 -3
  530. package/rules/proper-noun-density.yaml +14 -7
  531. package/rules/rule-of-three.yaml +3 -3
  532. package/rules/section-length-uniformity.yaml +2 -2
  533. package/rules/topic-predicate-distance.yaml +3 -2
  534. package/rules/undefined-acronym.yaml +8 -2
  535. package/rules/unknown-word.yaml +2 -2
  536. package/rules/unprompted-denial.yaml +88 -0
  537. package/rules/unqualified-superlative.yaml +8 -2
  538. package/skills/chaff/SKILL.md +38 -6
  539. package/src/acronym-expansion.ts +57 -0
  540. package/src/ai-score/human-shares.ts +53 -12
  541. package/src/ai-score/of-document.ts +5 -2
  542. package/src/body-section.ts +11 -2
  543. package/src/capitals-with-small.ts +16 -0
  544. package/src/checks.ts +32 -1
  545. package/src/cli-args.ts +1 -1
  546. package/src/cli-text.ts +4 -0
  547. package/src/commands/fix-plan.ts +72 -5
  548. package/src/commands/test.ts +18 -2
  549. package/src/detectors/acronym-context.ts +20 -2
  550. package/src/detectors/acronym-expansion.ts +26 -0
  551. package/src/detectors/acronym-gloss.ts +123 -0
  552. package/src/detectors/acronym-name.ts +22 -3
  553. package/src/detectors/acronym-series.ts +27 -0
  554. package/src/detectors/ai-phrasing.ts +18 -17
  555. package/src/detectors/ai-structure.ts +23 -6
  556. package/src/detectors/alnum-number.ts +8 -3
  557. package/src/detectors/bare-comparative.ts +41 -13
  558. package/src/detectors/bold-emphasis-form.ts +58 -0
  559. package/src/detectors/bold-emphasis.ts +16 -17
  560. package/src/detectors/caps-caption.ts +24 -2
  561. package/src/detectors/char-shape.ts +118 -29
  562. package/src/detectors/chat-log-line.ts +17 -0
  563. package/src/detectors/citation-string.ts +36 -0
  564. package/src/detectors/closing-cliche.ts +74 -0
  565. package/src/detectors/closing-exhortation.ts +74 -0
  566. package/src/detectors/cold-open.ts +145 -0
  567. package/src/detectors/comparative-context.ts +74 -0
  568. package/src/detectors/concrete-evidence-density.ts +99 -0
  569. package/src/detectors/concrete-evidence.ts +40 -0
  570. package/src/detectors/contrast-frame.ts +65 -7
  571. package/src/detectors/coordinate-adjective.ts +4 -2
  572. package/src/detectors/duplicate-heading.ts +44 -15
  573. package/src/detectors/email-frame-words.ts +39 -0
  574. package/src/detectors/email-letter.ts +15 -20
  575. package/src/detectors/fullwidth-alnum.ts +24 -4
  576. package/src/detectors/gram-furniture.ts +87 -1
  577. package/src/detectors/gram-openers.ts +71 -0
  578. package/src/detectors/gram-predicate.ts +49 -6
  579. package/src/detectors/gram-repetition.ts +199 -0
  580. package/src/detectors/heading-level-skip.ts +31 -1
  581. package/src/detectors/heading-numbering.ts +2 -2
  582. package/src/detectors/hyphen-copied-text.ts +65 -0
  583. package/src/detectors/kanji-name-edge.ts +31 -0
  584. package/src/detectors/kanji-run-pieces.ts +26 -0
  585. package/src/detectors/kutoten-consistency.ts +24 -4
  586. package/src/detectors/lead-in-dash.ts +11 -0
  587. package/src/detectors/letter-joined-name.ts +14 -0
  588. package/src/detectors/lexicon.ts +15 -2
  589. package/src/detectors/list-item.ts +37 -1
  590. package/src/detectors/list-items.ts +4 -1
  591. package/src/detectors/list-joint.ts +44 -0
  592. package/src/detectors/list-layout.ts +39 -0
  593. package/src/detectors/list-lead-in.ts +50 -3
  594. package/src/detectors/list-parallel.ts +119 -13
  595. package/src/detectors/list-run.ts +86 -0
  596. package/src/detectors/list-sentence.ts +11 -0
  597. package/src/detectors/mark-shape.ts +12 -7
  598. package/src/detectors/name-run.ts +2 -1
  599. package/src/detectors/name-variant-two-things.ts +136 -0
  600. package/src/detectors/name-variant.ts +14 -19
  601. package/src/detectors/organisation-run.ts +26 -2
  602. package/src/detectors/orthographic-variant-open.ts +119 -0
  603. package/src/detectors/orthographic-variant.ts +82 -82
  604. package/src/detectors/over-general-claim.ts +106 -5
  605. package/src/detectors/oxford-comma.ts +68 -28
  606. package/src/detectors/particle-run-names.ts +17 -0
  607. package/src/detectors/proper-noun-density.ts +109 -0
  608. package/src/detectors/quoted-excerpt.ts +68 -0
  609. package/src/detectors/reference-entry.ts +42 -0
  610. package/src/detectors/register-neutral-shape.ts +26 -6
  611. package/src/detectors/register-set-apart.ts +124 -0
  612. package/src/detectors/register-voice.ts +63 -0
  613. package/src/detectors/register.ts +15 -0
  614. package/src/detectors/registry/closing-cliche.ts +4 -0
  615. package/src/detectors/registry/closing-exhortation.ts +4 -0
  616. package/src/detectors/registry/cold-open.ts +4 -0
  617. package/src/detectors/registry/colon-lead-in.ts +1 -1
  618. package/src/detectors/registry/concrete-evidence.ts +1 -1
  619. package/src/detectors/registry/ngram-repetition.ts +1 -1
  620. package/src/detectors/registry/proper-noun-density.ts +1 -1
  621. package/src/detectors/registry/topic-predicate-distance.ts +1 -1
  622. package/src/detectors/registry/unprompted-denial.ts +4 -0
  623. package/src/detectors/sentence-ending.ts +60 -12
  624. package/src/detectors/sentence-length.ts +26 -9
  625. package/src/detectors/sentence-load.ts +3 -6
  626. package/src/detectors/sentence-parts.ts +70 -0
  627. package/src/detectors/sentence-title.ts +14 -0
  628. package/src/detectors/signals.ts +13 -198
  629. package/src/detectors/structure-tree.ts +3 -1
  630. package/src/detectors/structure.ts +25 -13
  631. package/src/detectors/superlative-clause.ts +21 -2
  632. package/src/detectors/superlative-context.ts +99 -0
  633. package/src/detectors/superlative-scope.ts +27 -9
  634. package/src/detectors/team.ts +1 -50
  635. package/src/detectors/titled-code-citation.ts +19 -0
  636. package/src/detectors/titled-run.ts +22 -5
  637. package/src/detectors/token-shape.ts +25 -13
  638. package/src/detectors/topic-predicate-distance.ts +25 -0
  639. package/src/detectors/unknown-word-context.ts +112 -0
  640. package/src/detectors/unknown-word.ts +18 -20
  641. package/src/detectors/unprompted-denial.ts +133 -0
  642. package/src/document-sections.ts +3 -1
  643. package/src/fix-plan/all-signs.ts +35 -0
  644. package/src/fix-plan/plan.ts +50 -3
  645. package/src/fix-plan/render.ts +41 -3
  646. package/src/fix-plan/risen.ts +13 -0
  647. package/src/fix-plan/text.ts +56 -2
  648. package/src/heading-numbering.ts +44 -10
  649. package/src/html/html-site-chrome.ts +9 -2
  650. package/src/law-title.ts +38 -0
  651. package/src/name-ending-run.ts +49 -0
  652. package/src/name-title-slip.ts +59 -0
  653. package/src/name-variant-shapes.ts +58 -0
  654. package/src/name-word-use.ts +17 -0
  655. package/src/opening-passage.ts +31 -0
  656. package/src/plugin.ts +2 -0
  657. package/src/quote-gloss.ts +11 -0
  658. package/src/quoted-spelling.ts +48 -0
  659. package/src/render/semantic.ts +2 -2
  660. package/src/rule-of-three.ts +50 -0
  661. package/src/run-semantic.ts +2 -2
  662. package/src/section-levels.ts +98 -0
  663. package/src/semantic.ts +14 -0
  664. package/src/sentence-load.ts +5 -3
  665. package/src/spelling.ts +37 -7
  666. package/src/structure/cited-document-section.ts +16 -1
  667. package/src/structure/issues.ts +10 -1
  668. package/src/structure-shape/template-outline.ts +34 -0
  669. package/src/title-case-name.ts +55 -0
  670. package/src/topic-clause.ts +96 -5
  671. package/src/word-use.ts +57 -6
  672. package/dist/legal-address.d.ts +0 -2
  673. package/dist/legal-address.d.ts.map +0 -1
  674. package/dist/legal-address.js +0 -16
  675. package/dist/legal-address.js.map +0 -1
@@ -1,13 +1,16 @@
1
1
  import { endingTokens, isClosed } from "../sentence-shape.ts";
2
2
  import { enumeratedRuns, enumeratorStarts, numberedStarts } from "./enumerated-runs.ts";
3
- import { continuesInto, groupOf, majorityOf, registerOf, slipsOf, type Register } from "./register.ts";
3
+ import { continuesThrough, groupOf, majorityOf, registerOf, slipsOf, type Register } from "./register.ts";
4
4
  import { isRunInLabel } from "./run-in-label.ts";
5
5
  import { noticeSentences } from "./notice-paragraph.ts";
6
6
  import { askerSentences } from "./asker-voice.ts";
7
7
  import { licenceNoticeSentences } from "./licence-notice.ts";
8
8
  import { chronologyRows } from "../chronology-rows.ts";
9
9
  import { isNeutralPlainShape } from "./register-neutral-shape.ts";
10
- import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span } from "../plugin.ts";
10
+ import { contactBlockSentences, fieldValueSentences, labelledQuoteSentences, referenceNoteSentences, tableCellSentences } from "./register-set-apart.ts";
11
+ import { endsInSetGreeting, isDeclaration, isExclamation, isTakenUp } from "./register-voice.ts";
12
+ import { entriesForGenre } from "../lexicon-genres.ts";
13
+ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
11
14
 
12
15
  /**
13
16
  * 文末の調子が混ざっているかを見る。日本語の「ですます / である」がこれ。
@@ -19,24 +22,62 @@ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span } f
19
22
  * 断り書きの段落(…ご了承ください。)も、本文とは別の声で書く決まり文句なので数えない(notice-paragraph.ts)。
20
23
  * 読み手の相談や質問を載せる節(【相談事例等】)の文は尋ねた人の言葉のままなので数えない(asker-voice.ts)。
21
24
  * 文書の最後に掲載先が付けた利用条件の断り書き(…ライセンスの下に提供されています。)も数えない(licence-notice.ts)。
25
+ * 札を付けて引いた言葉(例:…。Q: …?)、印を付けた札の行の下の記入欄の値(■ 調査目的\n…とする。)、
26
+ * 〒や電話の行のある問い合わせ先の段落も数えない(register-set-apart.ts)。
22
27
  */
23
28
  /**
24
29
  * quiet: 常体と読めるが、願い・問い・言いさしの形(register-neutral-shape.ts)の文。どちらの調子の文書にも現れるので指さない。
30
+ * 丁寧な形でしか言わない挨拶(お疲れ様でした。)、演説の決意の言い切り(二度と繰り返さない。)、
31
+ * 次の文が「そんな」「これだけ」で受ける場面の書き出し、「!」で終わる叫び(わかるかっ!)も quiet(register-voice.ts)。
32
+ * ※で始まる行の注記と、行に並べ直した表のセル(制限なし。)は、どちらの調子でも quiet(register-set-apart.ts)。
25
33
  * 数には入れる。数から外すと、常体を何度も使う文書(演説)で少数派が閾値を下回り、残りの常体の文が新たに指されてしまう。
26
34
  */
27
35
  type Entry = { readonly sentence: Sentence; readonly register: Register; readonly group: number | undefined; readonly quiet: boolean };
28
36
 
29
- /** polite は語彙表 polite-ending、neutral は neutral-ending、requests は neutral-request。 */
30
- type EndingWords = { readonly polite: readonly LexiconEntry[]; readonly neutral: readonly LexiconEntry[]; readonly requests: readonly LexiconEntry[] };
37
+ /** 文の調子と quiet を決める語彙表。polite は polite-ending、neutral は neutral-ending、requests は neutral-request、wishes は neutral-wish、
38
+ * greetings は set-polite-phrase、declaration は declaration-particle を文書の genre で絞ったもの、openers は takeup-opener。 */
39
+ type EndingWords = {
40
+ readonly polite: readonly LexiconEntry[];
41
+ readonly neutral: readonly LexiconEntry[];
42
+ readonly requests: readonly LexiconEntry[];
43
+ readonly wishes: readonly LexiconEntry[];
44
+ readonly greetings: readonly LexiconEntry[];
45
+ readonly declaration: readonly LexiconEntry[];
46
+ readonly openers: readonly LexiconEntry[];
47
+ };
31
48
 
32
49
  type Read = { readonly register: Register; readonly quiet: boolean };
33
50
 
34
- const registerOfSentence = (sentence: Sentence, words: EndingWords): Read | undefined => {
51
+ const endingWords = (doc: ProseDocument, polite: readonly LexiconEntry[], genre: string | undefined): EndingWords => ({
52
+ polite,
53
+ neutral: doc.lexicons["neutral-ending"] ?? [],
54
+ requests: doc.lexicons["neutral-request"] ?? [],
55
+ wishes: doc.lexicons["neutral-wish"] ?? [],
56
+ greetings: doc.lexicons["set-polite-phrase"] ?? [],
57
+ declaration: entriesForGenre(doc.lexicons["declaration-particle"] ?? [], genre),
58
+ openers: doc.lexicons["takeup-opener"] ?? [],
59
+ });
60
+
61
+ /** 調子を持つ文のうち、指さない形か。next は同じ文書の次の文、between はその間の文字列。 */
62
+ const isQuiet = (sentence: Sentence, ending: readonly Token[], register: Register, words: EndingWords, next: Sentence | undefined, between: string): boolean =>
63
+ register === "polite"
64
+ ? endsInSetGreeting(sentence, words.greetings)
65
+ : isNeutralPlainShape(sentence, ending, words.requests, words.wishes) ||
66
+ isDeclaration(sentence, ending, words.declaration) ||
67
+ isExclamation(sentence) ||
68
+ isTakenUp(next, between, words.openers);
69
+
70
+ const registerOfSentence = (doc: ProseDocument, index: number, words: EndingWords): Read | undefined => {
71
+ const sentence = doc.sentences[index];
72
+ if (sentence === undefined) return undefined;
35
73
  const ending = endingTokens(sentence);
36
74
  const tokens = sentence.tokens ?? [];
37
75
  const head = ending[0] === undefined ? -1 : tokens.indexOf(ending[0]);
38
76
  const register = registerOf(ending, head > 0 ? tokens.slice(0, head) : [], words.polite, words.neutral);
39
- return register === undefined ? undefined : { register, quiet: register === "plain" && isNeutralPlainShape(sentence, ending, words.requests) };
77
+ if (register === undefined) return undefined;
78
+ const next = doc.sentences[index + 1];
79
+ const between = next === undefined ? "" : doc.source.slice(sentence.span.end, next.span.start);
80
+ return { register, quiet: isQuiet(sentence, ending, register, words, next, between) };
40
81
  };
41
82
 
42
83
  /** 番号で始まる段落の並び。木を組むのは高いので、調子が一つだけの文書(混ざりようがない)では組まない。 */
@@ -51,24 +92,31 @@ const runsOf = (doc: ProseDocument, registers: readonly Register[]): Span[] => {
51
92
  };
52
93
 
53
94
  /** 調子を持つ文と、比べ合うまとまり(groupOf)。polite は語彙表 polite-ending。 */
54
- export const judgedSentences = (doc: ProseDocument, polite: readonly LexiconEntry[]): Entry[] => {
55
- const words: EndingWords = { polite, neutral: doc.lexicons["neutral-ending"] ?? [], requests: doc.lexicons["neutral-request"] ?? [] };
95
+ export const judgedSentences = (doc: ProseDocument, polite: readonly LexiconEntry[], genre?: string): Entry[] => {
96
+ const words = endingWords(doc, polite, genre);
56
97
  const lists = doc.lists.map((list) => list.span);
57
98
  const rows = chronologyRows(doc);
58
99
  const asked = askerSentences(doc.sections, doc.lexicons["asker-heading"] ?? []);
59
100
  const licence = licenceNoticeSentences(doc, doc.lexicons["licence-word"] ?? []);
101
+ const quoted = labelledQuoteSentences(doc.paragraphs, doc.source, doc.lexicons["quote-label"] ?? []);
102
+ const fields = fieldValueSentences(doc.sentences, doc.source);
103
+ const contact = contactBlockSentences(doc.sentences, doc.source, doc.lexicons["contact-line-opener"] ?? []);
104
+ const asides = new Set([...referenceNoteSentences(doc.sentences, doc.source), ...tableCellSentences(doc.sentences, doc.source)]);
60
105
  const all = doc.sentences.flatMap((sentence, index): { sentence: Sentence; register: Register; quiet: boolean }[] => {
61
106
  if (
62
107
  !isClosed(sentence) ||
63
108
  rows.has(sentence) ||
64
109
  asked.has(sentence) ||
65
110
  licence.has(sentence) ||
66
- continuesInto(sentence, doc.sentences[index + 1]) ||
111
+ quoted.has(sentence) ||
112
+ fields.has(sentence) ||
113
+ contact.has(sentence) ||
114
+ continuesThrough(doc.sentences, index) ||
67
115
  isRunInLabel(doc.source, sentence.span)
68
116
  )
69
117
  return [];
70
- const read = registerOfSentence(sentence, words);
71
- return read === undefined ? [] : [{ sentence, ...read }];
118
+ const read = registerOfSentence(doc, index, words);
119
+ return read === undefined ? [] : [{ sentence, register: read.register, quiet: read.quiet || asides.has(sentence) }];
72
120
  });
73
121
  const registers = new Map(all.map((entry) => [entry.sentence, entry.register]));
74
122
  const majority = majorityOf(all.map((entry) => ({ register: entry.register, group: undefined })));
@@ -82,7 +130,7 @@ export const judgedSentences = (doc: ProseDocument, polite: readonly LexiconEntr
82
130
  };
83
131
 
84
132
  export const sentenceEnding: Detector = (doc, options): Finding[] => {
85
- const judged = judgedSentences(doc, options.lexicon ?? []);
133
+ const judged = judgedSentences(doc, options.lexicon ?? [], options.genre);
86
134
  // 数えたのは文が属するまとまりの中なので、文言もそのまとまりを名指す(本文の中で / この箇条書きの中で)。
87
135
  const slips = slipsOf(judged, options.limit).filter(({ entry }) => !entry.quiet);
88
136
  return slips.map(({ entry: { sentence, group }, count }) => ({
@@ -1,10 +1,12 @@
1
1
  import { lengthOf, proseText } from "../measure.ts";
2
2
  import type { Detector, DetectorOptions, Finding, LengthUnit, Sentence } from "../plugin.ts";
3
3
  import { citationLead } from "./citation-sentence.ts";
4
+ import { isCitationString } from "./citation-string.ts";
4
5
  import { isNameList } from "./name-list-sentence.ts";
5
6
  import { pageMarkerPattern, pageMarkerSize } from "./page-marker.ts";
6
7
  import { quotedSentenceParts } from "./quoted-sentences.ts";
7
- import { isInListItem, isTitleLine, quotedTitleWords, termSeriesSaving } from "./sentence-title.ts";
8
+ import { colonQuotationParts, flattenedTableParts, isGrammarBlock, labelLineParts } from "./sentence-parts.ts";
9
+ import { isInListItem, isReferenceLine, isTitleLine, quotedTitleWords, remarkAfterTitle, termSeriesSaving } from "./sentence-title.ts";
8
10
 
9
11
  type Measure = { readonly size: number; readonly limit: number; readonly variant?: string };
10
12
 
@@ -22,7 +24,7 @@ type SentenceWords = {
22
24
  * Only where words are the unit: the shapes are read from capitals and spaces.
23
25
  */
24
26
  const unwrittenWords = (sentence: Sentence, text: string, listItems: SentenceWords["listItems"]): number =>
25
- termSeriesSaving(text) + (isInListItem(sentence.span, listItems) ? quotedTitleWords(text) : 0);
27
+ termSeriesSaving(text) + (isInListItem(sentence.span, listItems) || isReferenceLine(text) ? quotedTitleWords(text) : 0);
26
28
 
27
29
  const sizeOf = (text: string, unit: LengthUnit): number =>
28
30
  unit === "word" ? text.split(/\s+/u).filter((word) => word.length > 0).length : text.replace(/\s+/gu, "").length;
@@ -43,16 +45,31 @@ const measureOf = (sentence: Sentence, unit: LengthUnit, options: DetectorOption
43
45
  if (lead !== undefined) return { size: sizeOf(lead, unit), limit: options.limit };
44
46
  const embedded = sentence.embeddedLanguage;
45
47
  const limit = embedded === undefined ? undefined : options.embeddedLimits?.[embedded.id];
46
- if (embedded === undefined || limit === undefined) {
47
- const text = proseText(sentence);
48
- if (unit === "word" && isTitleLine(text)) return { size: 0, limit: options.limit };
49
- const unwritten = unit === "word" ? unwrittenWords(sentence, text, words.listItems) : 0;
50
- const size = lengthOf(sentence, unit) - pageMarkerSize(text, words.markers, unit) - unwritten;
51
- return { size: unit === "char" ? longestQuotedPart(text, size, words.markers) : size, limit: options.limit };
52
- }
48
+ if (embedded === undefined || limit === undefined) return { size: ownSize(sentence, unit, words), limit: options.limit };
53
49
  return { size: lengthOf(sentence, embedded.lengthUnit), limit, variant: `embedded-${embedded.id}` };
54
50
  };
55
51
 
52
+ /** Code or a citation string: nothing in it is the writer's sentence. A title line too, where words are the unit. */
53
+ const isUnwritten = (sentence: Sentence, text: string, unit: LengthUnit, words: SentenceWords): boolean =>
54
+ isGrammarBlock(sentence.text) || isCitationString(text, words.citationSignals) || (unit === "word" && isTitleLine(text));
55
+
56
+ /** The parts measured one by one when the splitter ran several things into one sentence (label lines, table cells, a quotation). */
57
+ const partsOf = (sentence: Sentence, text: string): readonly string[] | undefined =>
58
+ labelLineParts(sentence.text) ?? flattenedTableParts(text) ?? colonQuotationParts(text);
59
+
60
+ /** The length of a sentence in the document's language, without what the writer did not write as one. */
61
+ const ownSize = (sentence: Sentence, unit: LengthUnit, words: SentenceWords): number => {
62
+ const text = proseText(sentence);
63
+ if (isUnwritten(sentence, text, unit, words)) return 0;
64
+ const parts = partsOf(sentence, text);
65
+ if (parts !== undefined) return Math.max(0, ...parts.map((part) => sizeOf(part, unit) - pageMarkerSize(part, words.markers, unit)));
66
+ const remark = unit === "word" ? remarkAfterTitle(text) : undefined;
67
+ if (remark !== undefined) return sizeOf(remark, unit);
68
+ const unwritten = unit === "word" ? unwrittenWords(sentence, text, words.listItems) : 0;
69
+ const size = lengthOf(sentence, unit) - pageMarkerSize(text, words.markers, unit) - unwritten;
70
+ return unit === "char" ? longestQuotedPart(text, size, words.markers) : size;
71
+ };
72
+
56
73
  export const sentenceLength: Detector = (doc, options): Finding[] => {
57
74
  const words: SentenceWords = {
58
75
  markers: pageMarkerPattern((options.lexicon ?? []).map((entry) => entry.pattern)),
@@ -2,7 +2,7 @@ import type { Detector, Finding, Sentence, Token } from "../plugin.ts";
2
2
  import { proseText } from "../measure.ts";
3
3
  import { quotedSpans } from "../quoted-span.ts";
4
4
  import { literalCues, withoutLiteralQuotes } from "../literal-quote.ts";
5
- import { bracketDepth, clauseCount, topicDistance } from "../sentence-load.ts";
5
+ import { bracketDepth, clauseCount } from "../sentence-load.ts";
6
6
  import { withoutWordBrackets } from "../bracket-annotation.ts";
7
7
 
8
8
  const findingOf = (sentence: Sentence, count: number, limit: number): Finding => ({
@@ -15,7 +15,7 @@ const findingOf = (sentence: Sentence, count: number, limit: number): Finding =>
15
15
  });
16
16
 
17
17
  /** Each sentence whose measure is over the limit. A sentence the measure cannot read (undefined) is left alone. */
18
- const overLimit =
18
+ export const overLimit =
19
19
  (measure: (sentence: Sentence) => number | undefined): Detector =>
20
20
  (doc, options): Finding[] =>
21
21
  doc.sentences.flatMap((sentence) => {
@@ -31,7 +31,7 @@ const quotedMask = (text: string): Uint8Array => {
31
31
  };
32
32
 
33
33
  /** The sentence's tokens outside quotations in 「」『』: a quoted title or remark is one noun to the sentence, whatever it holds. */
34
- const ownTokens = (sentence: Sentence): Token[] => {
34
+ export const ownTokens = (sentence: Sentence): Token[] => {
35
35
  const mask = quotedMask(sentence.text);
36
36
  const inQuote = (token: Token): boolean => mask[token.span.start - sentence.span.start] === 1 && mask[token.span.end - 1 - sentence.span.start] === 1;
37
37
  return (sentence.tokens ?? []).filter((token) => !inQuote(token));
@@ -51,6 +51,3 @@ export const bracketNesting: Detector = (doc, options) => {
51
51
 
52
52
  /** Clauses chained in one sentence (調べて、まとめ、報告したが、返事がないので、…). Needs the language's tokens. */
53
53
  export const clauseChain: Detector = overLimit((sentence) => (sentence.tokens === undefined ? undefined : clauseCount(ownTokens(sentence))));
54
-
55
- /** The distance from the sentence's topic (〜は) to the end, where its predicate is. Needs the language's tokens. */
56
- export const topicPredicateDistance: Detector = overLimit((sentence) => (sentence.tokens === undefined ? undefined : topicDistance(ownTokens(sentence))));
@@ -0,0 +1,70 @@
1
+ // Text the sentence splitter hands over as one sentence although the writer did not write one: lines of labels and values
2
+ // (When: Friday / Where: …), a grammar written in a plain-text specification (body = signed / unsigned), a table whose cells
3
+ // a converter ran together (…設立1945年7月日染興業…, 39,0439,677…), and a quotation the writer introduces with a colon.
4
+ // Each is measured part by part, or not at all. Pure: the text in, the parts out.
5
+
6
+ const LINE_BREAK = /\n/u;
7
+ /** A sentence's end on a line: a stop, then any closing quotes or brackets. */
8
+ const LINE_ENDS_SENTENCE = /[.?!。?!][\s"'”’)\])」』]*$/u;
9
+ /** A label of a few words, a colon, then the value (When: Friday, 12:30 / 日時:10月1日). */
10
+ const LABEL_LINE = /^[^\s::][^::]{0,59}[::]\s*\S/u;
11
+ const MIN_LINES = 2;
12
+
13
+ const linesOf = (text: string): string[] =>
14
+ text
15
+ .split(LINE_BREAK)
16
+ .map((line) => line.trim())
17
+ .filter((line) => line !== "");
18
+
19
+ /** Two or more lines, each a label and its value, none closed by a stop: each line is measured as one. */
20
+ export const labelLineParts = (text: string): readonly string[] | undefined => {
21
+ const lines = linesOf(text);
22
+ if (lines.length < MIN_LINES) return undefined;
23
+ return lines.every((line) => LABEL_LINE.test(line) && !LINE_ENDS_SENTENCE.test(line)) ? lines : undefined;
24
+ };
25
+
26
+ /** A grammar rule (UTF8-char = UTF8-1 / UTF8-2): a name with no space in it, then = between spaces. */
27
+ const GRAMMAR_RULE = /^\p{L}[\p{L}\p{N}_-]*\s+=\s/u;
28
+ /** A grammar's comment line (; order of fields is not important). */
29
+ const GRAMMAR_COMMENT = /^;/u;
30
+
31
+ /** Most of its lines are grammar rules or a grammar's comments, at least one a rule: code, not a sentence. */
32
+ export const isGrammarBlock = (text: string): boolean => {
33
+ const lines = linesOf(text);
34
+ const rules = lines.filter((line) => GRAMMAR_RULE.test(line)).length;
35
+ const comments = lines.filter((line) => GRAMMAR_COMMENT.test(line)).length;
36
+ return rules > 0 && (rules + comments) * 2 > lines.length;
37
+ };
38
+
39
+ /**
40
+ * Cells of numbers run together: a comma group past three digits (39,0439,677), or decimals one after another
41
+ * (62.722.99.713.4). Four stops at least, so that a section number (3.5.3) or an address (192.168.1.1) is not one.
42
+ */
43
+ const GLUED_NUMBER = /\d[,,]\d{4}|\d(?:[..]\d+){4}/u;
44
+ /** A run of numbers, signs and empty-cell dashes (39,0439,6773,503…△0.6); it is cut out when it holds glued cells. */
45
+ const NUMBER_RUN = /[\d,,..△▲-−%%-]+/gu;
46
+ const CUT = "\n";
47
+ /** A date that opens a row, run into the cell before it and the cell after it (…設立1945年7月日染興業…). */
48
+ const GLUED_DATE =
49
+ /(?<=[\p{Script=Han}\p{Script=Katakana}\p{Script=Hiragana}ー])(?=[0-90-9]{4}年[0-90-9]{1,2}月[\p{Script=Han}\p{Script=Katakana}\p{L}])/gu;
50
+ /** Fewer glued dates than this are a sentence that names a date or two, not the rows of a chronology. */
51
+ const MIN_GLUED_DATES = 3;
52
+
53
+ const nonEmpty = (parts: readonly string[]): string[] => parts.map((part) => part.trim()).filter((part) => part !== "");
54
+
55
+ /** The cells of a table a converter flattened into one sentence, cut at the glued numbers or at each row's date. */
56
+ export const flattenedTableParts = (text: string): readonly string[] | undefined => {
57
+ if (GLUED_NUMBER.test(text)) return nonEmpty(text.replace(NUMBER_RUN, (run) => (GLUED_NUMBER.test(run) ? CUT : run)).split(CUT));
58
+ const rows = text.split(GLUED_DATE);
59
+ return rows.length > MIN_GLUED_DATES ? nonEmpty(rows) : undefined;
60
+ };
61
+
62
+ /** A quotation the writer opens after a colon (has observed: "The credibility of money …"), in straight or curly quotes. */
63
+ const COLON_QUOTATION = /[::]\s*["“]([^"“”]+)["”]/gu;
64
+
65
+ /** The quoted words after a colon and the writer's own words around them, measured apart: the quotation is not the writer's to shorten. */
66
+ export const colonQuotationParts = (text: string): readonly string[] | undefined => {
67
+ const quotes = [...text.matchAll(COLON_QUOTATION)].map((match) => match[1] ?? "");
68
+ if (quotes.length === 0) return undefined;
69
+ return nonEmpty([text.replace(COLON_QUOTATION, ":"), ...quotes]);
70
+ };
@@ -52,5 +52,19 @@ export const termSeriesSaving = (text: string): number =>
52
52
  .filter((terms) => terms.every((words) => words.length > 0 && words.length <= MAX_TERM_WORDS))
53
53
  .reduce((total, terms) => total + Math.max(0, terms.flat().length - 1), 0);
54
54
 
55
+ /** A title, then a remark in parentheses that closes the line (Joint Statement on … Providers (See also the Board's press release.)). */
56
+ const TITLE_AND_REMARK = /^([^()]+)\(([^()]+)\)$/u;
57
+
58
+ /** The remark after a title line, the only words of it the writer wrote as a sentence; undefined when the text is not one. */
59
+ export const remarkAfterTitle = (text: string): string | undefined => {
60
+ const parts = TITLE_AND_REMARK.exec(text.trim());
61
+ return parts !== null && isTitleLine(parts[1] ?? "") ? parts[2] : undefined;
62
+ };
63
+
64
+ /** A reference to another document: a short name, its quoted title, then its date (SR letter 21-8, "Interagency …" (April 9, 2021).). */
65
+ const REFERENCE_LINE = /^[^"“”]{0,40}["“][^"“”]+["”],?\s*\([^()]*\d{4}\)\.?$/u;
66
+
67
+ export const isReferenceLine = (text: string): boolean => REFERENCE_LINE.test(text.trim());
68
+
55
69
  /** Whether a span lies inside one of the item spans of the document's lists. */
56
70
  export const isInListItem = (span: Span, items: readonly Span[]): boolean => items.some((item) => item.start <= span.start && span.end <= item.end);
@@ -1,9 +1,7 @@
1
1
  import { proseText } from "../measure.ts";
2
2
  import { dateSpans, wordsOf } from "./structure.ts";
3
- import { compacted, linkedIn, placeAt } from "./gram-place.ts";
4
- import { charWindows, wordWindows } from "./gram-windows.ts";
5
- import { fixedEndingSpans, furnitureMask, isFurniture } from "./gram-furniture.ts";
6
3
  import { lexiconNotationOf, sourceNotAcronymSpans, unreportedAcronymSpans, type NotAcronymSpans } from "./acronym-context.ts";
4
+ import { titledCodeSpans } from "./titled-code-citation.ts";
7
5
  import { abbreviates, expansionAt, termEntryAcronyms, type DefinitionWords, type ExpandedAt } from "./acronym-expansion.ts";
8
6
  import { isExplained } from "./acronym-compound.ts";
9
7
  import { statedAcronyms } from "./acronym-definition.ts";
@@ -11,16 +9,11 @@ import { isBracketed, isInHeading, isNamePart } from "./acronym-lone.ts";
11
9
  import { linkedListTerms } from "./acronym-link.ts";
12
10
  import { caseVariantsIn, spelledOutAcronyms } from "./acronym-mention.ts";
13
11
  import { conjugatedForms } from "./conjugated-form.ts";
14
- import { evidenceSpans, hasNumeral, isClaim, isLabelOnly, startsWithin, type AdviceWords } from "./concrete-evidence.ts";
15
- import { letteredIndexEntries } from "./lettered-index.ts";
16
12
  import { knownByDocument } from "./acronym-known.ts";
17
- import { glossedAcronyms, headingsSpellingOut } from "./acronym-gloss.ts";
18
- import { hasPredicateIn } from "./gram-predicate.ts";
19
- import { gramPassagesOf } from "./gram-passages.ts";
20
- import { sectionOpeners } from "./gram-openers.ts";
21
- import { nameSpans, touchesAny } from "../team-names.ts";
22
- import { DASH, introducesList } from "./lead-in-dash.ts";
23
- import type { Detector, Finding, ProseDocument, Section, Sentence } from "../plugin.ts";
13
+ import { explainedInText, headingsSpellingOut } from "./acronym-gloss.ts";
14
+ import { nameSpans } from "../team-names.ts";
15
+ import { DASH, introducesList, opensLine } from "./lead-in-dash.ts";
16
+ import type { Detector, Finding, ProseDocument, Sentence } from "../plugin.ts";
24
17
 
25
18
  const PER = 1000;
26
19
 
@@ -65,121 +58,6 @@ export const emojiDensity: Detector = (doc, options): Finding[] => {
65
58
  ];
66
59
  };
67
60
 
68
- /**
69
- * 同じ言い回しの繰り返し。文字の並びで見るので、adapter の語の区切り(wordSplit)が要らない。英語の窓は空白で語の切れ目にそろえる。
70
- * spec §10 が n-gram を選んだのはこのためで、新しい言語でそのまま動く。
71
- */
72
- /**
73
- * 窓の幅は単位で分ける。同じ 8 文字でも、日本語では 4〜5 形態素だが英語では 1 語半にしかならない。
74
- * 英語の窓は語の切れ目にそろえ、18 文字に届くまで語を足す。文字で切ると " generat" のような語の断片が上位に来る。
75
- * 18 は、文字で切っていた頃の 20 文字の窓から前後の空白を除いた長さ(" juxtaposed to said ")。
76
- */
77
- const GRAM = { char: 8, word: 18 };
78
-
79
- const windowsOf = (text: string, unit: ProseDocument["lengthUnit"]): Span[] => (unit === "char" ? charWindows(text, GRAM.char) : wordWindows(text, GRAM.word));
80
-
81
- /**
82
- * 名前ではなく言い回しだけを数える。実文書で測ったら、上位は
83
- * 「AGENTS.m」「シンギュラリティ」のような固有名詞と識別子だった。名前は繰り返して当たり前。
84
- *
85
- * 言い回しは、その言語の「つなぎの материал」を含む。日本語ならひらがな、英語なら語の切れ目。
86
- * どちらを見るかは adapter が宣言する単位で決める。ひらがなを持たない char 単位の言語が
87
- * 来たら、この見分けは効かなくなる(そのときは adapter 側に判定を移す)。
88
- */
89
- /**
90
- * つなぎが 1 つでは足りない。「detectorは」は用語に助詞が 1 つ付いただけで、
91
- * 繰り返して当たり前の**用語**であって言い回しではない。
92
- * 実文書で測ると、本物の言い回しはひらがなを 7 つ前後含み、用語+助詞は 1〜2 だった。
93
- */
94
- const CONNECTIVE = { char: /[ぁ-ゖ].*[ぁ-ゖ].*[ぁ-ゖ]/u, word: /\S \S.*\S \S/u };
95
-
96
- const isPhrasing = (gram: string, unit: ProseDocument["lengthUnit"]): boolean => CONNECTIVE[unit].test(gram);
97
-
98
- /** 語句が最初に数えられた所。書かれたままの語句と、文と、文の中の範囲(sentence.text の位置)。 */
99
- type FirstSeen = { readonly gram: string; readonly sentence: Sentence; readonly place: Span };
100
-
101
- type Tally = { readonly counts: Map<string, number>; readonly first: Map<string, FirstSeen> };
102
-
103
- /** 英語は大文字と小文字を区別せずに数える。文頭の "Proposals submitted via" も文中の "proposals submitted via" も同じ言い回し。 */
104
- const keyOf = (gram: string, unit: ProseDocument["lengthUnit"]): string => (unit === "word" ? gram.toLowerCase() : gram);
105
-
106
- const namesOf = (doc: ProseDocument): readonly string[] =>
107
- doc.lengthUnit === "char" ? (doc.names ?? []).map((name) => name.replace(/\s+/gu, "")) : (doc.names ?? []);
108
-
109
- /** 語彙表 ngram-fixed-ending: 項目ごとに同じ形で結ぶ書式の結び(〜ものとすること。)。 */
110
- const fixedEndingsOf = (doc: ProseDocument): string[] => (doc.lexicons["ngram-fixed-ending"] ?? []).map((entry) => entry.pattern);
111
-
112
- /**
113
- * 文をまたいで数えない。文の終わりと次の文の始まりが繋がると、固有名詞が言い回しに見える。
114
- * 並べた名前にかかる語句も数えない。名前が繰り返されれば、その前後(「the …」)も一緒に繰り返されるのは当たり前。
115
- * 一覧の飾り(gram-furniture.ts)も数えない。項目ごとに繰り返すのはひな形で、書き手ではない。
116
- */
117
- const tallySentence = (doc: ProseDocument, sentence: Sentence, tally: Tally): void => {
118
- const source = compacted(sentence.text, doc.lengthUnit);
119
- const named = nameSpans(source.text, namesOf(doc));
120
- const mask = furnitureMask(source.text, linkedIn(doc, sentence, source));
121
- fixedEndingSpans(source.text, fixedEndingsOf(doc)).forEach((span) => mask.fill(true, span.start, span.end));
122
- windowsOf(source.text, doc.lengthUnit)
123
- .filter((window) => !touchesAny(named, window.start, window.end) && !isFurniture(source.text, mask, window))
124
- .forEach((window) => {
125
- const gram = source.text.slice(window.start, window.end);
126
- const key = keyOf(gram, doc.lengthUnit);
127
- tally.counts.set(key, (tally.counts.get(key) ?? 0) + 1);
128
- const place = placeAt(source, window);
129
- if (!tally.first.has(key) && place !== undefined) tally.first.set(key, { gram, sentence, place });
130
- });
131
- };
132
-
133
- const gramsOf = (doc: ProseDocument, sentences: readonly Sentence[]): Tally => {
134
- const tally: Tally = { counts: new Map(), first: new Map() };
135
- sentences.forEach((sentence) => tallySentence(doc, sentence, tally));
136
- return tally;
137
- };
138
-
139
- type Repeat = { readonly key: string; readonly count: number; readonly at: FirstSeen | undefined };
140
-
141
- /** 範囲(gram-passages.ts)ごとに数える。よくある質問の別々の答えは別の範囲。節の最初の文にだけ出るものは節のひな形(gram-openers.ts)。 */
142
- const repeatsOf = (doc: ProseDocument, limit: number, openers = sectionOpeners(doc.sections, doc.source)): Repeat[] =>
143
- gramPassagesOf(doc.sections).flatMap((sentences) => {
144
- const tally = gramsOf(doc, sentences);
145
- const opening = gramsOf(
146
- doc,
147
- sentences.filter((sentence) => openers.has(sentence)),
148
- ).counts;
149
- return [...tally.counts.entries()]
150
- .filter(([key, count]) => count > limit && isPhrasing(key, doc.lengthUnit) && (opening.get(key) ?? 0) < count)
151
- .map(([key, count]) => ({ key, count, at: tally.first.get(key) }));
152
- });
153
-
154
- /**
155
- * 語句が文の中で占める範囲に、述語になる動詞か助動詞があるか(gram-predicate.ts)。
156
- * 品詞が無ければ見分けられないので、これまでどおり言い回しとして数える。
157
- */
158
- const hasPredicate = (at: FirstSeen | undefined, unit: ProseDocument["lengthUnit"]): boolean => {
159
- if (at?.sentence.tokens === undefined) return true;
160
- const start = at.sentence.span.start;
161
- return hasPredicateIn(at.sentence.tokens, { start: start + at.place.start, end: start + at.place.end }, unit);
162
- };
163
-
164
- export const ngramRepetition: Detector = (doc, options): Finding[] => {
165
- if (wordsOf(doc) < MIN_DOCUMENT_LENGTH[doc.lengthUnit]) return [];
166
- const worst = repeatsOf(doc, options.limit)
167
- .toSorted((left, right) => right.count - left.count)
168
- .find(({ at }) => hasPredicate(at, doc.lengthUnit));
169
- if (worst === undefined) return [];
170
- const at = worst.at?.sentence;
171
- return [
172
- {
173
- rule: "ngram-repetition",
174
- severity: "info",
175
- line: 0,
176
- column: 0,
177
- quote: at?.text.trim() ?? worst.key,
178
- values: { word: worst.at?.gram ?? worst.key, count: worst.count, limit: options.limit, offset: at?.span.start ?? 0 },
179
- },
180
- ];
181
- };
182
-
183
61
  /**
184
62
  * 略語が初出で展開されているか。「CI」だけでは、読む人によって指すものが違う。
185
63
  * 展開は「略語の直前か直後の括弧」か「括弧の中の略語」で書かれる。
@@ -342,8 +220,9 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
342
220
  doc.sentences.map((sentence) => sentence.text),
343
221
  patternsOf(doc, "abbreviation-mention"),
344
222
  );
345
- // 略語のすぐ後ろのダッシュで挟んだ同格(the VIX—a measure of …—)も、略語の説明と読む。
346
- const entries = new Set([...termEntryAcronyms(doc.source), ...stated, ...linkedListTerms(doc.source), ...spelled, ...glossedAcronyms(body)]);
223
+ // 略語のすぐ後ろのダッシュで挟んだ同格(the VIX—a measure of …—)、同じ文の前に書いた名前(Small Business Administration … SBA)、
224
+ // 2 つ以上の番号で引く続き物の名前(BCP 78、BCP 14)も、略語の説明と読む。
225
+ const entries = new Set([...termEntryAcronyms(doc.source), ...stated, ...linkedListTerms(doc.source), ...spelled, ...explainedInText(body, doc.sentences)]);
347
226
  const headings = doc.sections.map((section) => section.heading);
348
227
  // 見出しが略語の名前を書き出していれば(## Federal Open Market Committee の下の FOMC)、説明済み。
349
228
  const spelledInHeading = headingsSpellingOut(headings);
@@ -360,10 +239,10 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
360
239
  explained.set(word, known);
361
240
  return known;
362
241
  };
363
- const counted = outsideSpans(
364
- acronymsOf(doc, notationOf(doc)),
365
- sourceNotAcronymSpans(doc.source, (id) => patternsOf(doc, id)),
366
- );
242
+ const counted = outsideSpans(acronymsOf(doc, notationOf(doc)), [
243
+ ...sourceNotAcronymSpans(doc.source, (id) => patternsOf(doc, id)),
244
+ ...titledCodeSpans(doc.source, patternsOf(doc, "citation-series")),
245
+ ]);
367
246
  const hits = outsideSpans(
368
247
  counted,
369
248
  unreportedAcronymSpans(doc.source, doc.sentences, doc.links, (id) => patternsOf(doc, id)),
@@ -384,76 +263,12 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
384
263
  return alone.map(([acronym, hit]) => acronymFinding(acronym, hit, alone.length, options.limit));
385
264
  };
386
265
 
387
- /**
388
- * 具体物の密度。数値・コード・リンク・引用が 1 つも無い節は、
389
- * 読み終えても何も持ち帰れない。**少ないほうを指摘する**ので、他の密度 rule と向きが逆。
390
- */
391
- const CONCRETE = /\d|`|https?:\/\//u;
392
-
393
- /**
394
- * 見出しのない導入部は、書き出しで呼ぶ。文書の言葉なので、message がどの言語でも混ざらない。
395
- * 決まった呼び名(「この節」)を置くと、英語の文書の message に日本語が入る。
396
- */
397
- const OPENING = { word: 4, char: 12 };
398
-
399
- const openingOf = (sentence: Sentence | undefined, unit: ProseDocument["lengthUnit"]): string => {
400
- const text = sentence === undefined ? "" : proseText(sentence);
401
- const pieces = unit === "word" ? text.split(" ") : Array.from(text);
402
- const joiner = unit === "word" ? " " : "";
403
- return pieces.length <= OPENING[unit] ? pieces.join(joiner) : `${pieces.slice(0, OPENING[unit]).join(joiner)}…`;
404
- };
405
-
406
- const hasNumeralIn = (section: Section): boolean => section.sentences.some((sentence) => hasNumeral(sentence.tokens ?? []));
407
-
408
- /** これより短い節は、具体物があるべきか判断できない。 */
409
- const MIN_SENTENCES = 3;
410
-
411
- const adviceWordsOf = (doc: ProseDocument): AdviceWords => ({
412
- openers: (doc.lexicons["advice-opener"] ?? []).map((entry) => entry.pattern),
413
- endings: (doc.lexicons["advice-ending"] ?? []).map((entry) => entry.pattern),
414
- });
415
-
416
- /** 文の半分以上が問いか指示の節(質問の一覧、手引き)は、数字で裏づける主張をしていない。番号だけの文(a.)は数えない。 */
417
- const mostlyClaims = (section: Section, language: string, advice: AdviceWords): boolean => {
418
- const said = section.sentences.filter((sentence) => !isLabelOnly(sentence));
419
- return said.filter((sentence) => isClaim(sentence, language, advice)).length * 2 > said.length;
420
- };
421
-
422
- export const concreteEvidence: Detector = (doc, options): Finding[] => {
423
- const entries = letteredIndexEntries(doc.sections);
424
- const advice = adviceWordsOf(doc);
425
- const sections = doc.sections.filter(
426
- (section) => section.sentences.length >= MIN_SENTENCES && !entries.has(section) && mostlyClaims(section, doc.language, advice),
427
- );
428
- const bare = sections.filter(
429
- (section) => !CONCRETE.test(doc.source.slice(section.span.start, section.span.end)) && !hasNumeralIn(section) && !startsWithin(section.span, doc.links),
430
- );
431
- // 構造の木は作るのに手間がかかる。指摘に届かない文書では作らない。
432
- const nodes = bare.length < options.limit ? [] : evidenceSpans(doc.structure);
433
- const empty = bare.filter((section) => !startsWithin(section.span, nodes));
434
- if (empty.length < options.limit) return [];
435
- return empty.map((section) => ({
436
- rule: "concrete-evidence-density",
437
- severity: "info",
438
- line: 0,
439
- column: 0,
440
- quote: section.heading.length > 0 ? section.heading : (section.sentences[0]?.text.trim() ?? ""),
441
- values: {
442
- word: section.heading.length > 0 ? section.heading : openingOf(section.sentences[0], doc.lengthUnit),
443
- count: empty.length,
444
- total: sections.length,
445
- limit: options.limit,
446
- offset: section.span.start,
447
- },
448
- }));
449
- };
450
-
451
266
  /**
452
267
  * ダッシュの多用。英語では正当な用法が多いが、2026 年時点で最も知られた生成文のシグナルでもある。
453
268
  * 日本語の組版ではそもそも扱いが難しい。どちらが正しいかは severity の言語別指定で分ける。spec §12.4。
454
269
  */
455
270
  export const dashDensity: Detector = (doc, options): Finding[] => {
456
- const hits = findIn(doc, DASH).filter((hit) => !introducesList(doc.source, hit.offset));
271
+ const hits = findIn(doc, DASH).filter((hit) => !introducesList(doc.source, hit.offset) && !opensLine(doc.source, hit.offset));
457
272
  const first = hits[0];
458
273
  const rate = density(doc, hits.length);
459
274
  if (wordsOf(doc) < MIN_DOCUMENT_LENGTH[doc.lengthUnit] || first === undefined || rate <= options.limit) return [];
@@ -53,7 +53,9 @@ const findingsOf =
53
53
  }));
54
54
 
55
55
  export const danglingReference: Detector = (doc, options) =>
56
- findingsOf("dangling-reference", (tree, source) => danglingReferences(tree, source, patternsOf(doc, "section-name-noun")))(doc, options);
56
+ findingsOf("dangling-reference", (tree, source) =>
57
+ danglingReferences(tree, source, patternsOf(doc, "section-name-noun"), patternsOf(doc, "reference-list-heading")),
58
+ )(doc, options);
57
59
  /** Markdown の HTML ブロックの中の条は木に入らない。そこを挟んだ抜けは、見えなかった番号かもしれない。 */
58
60
  const structureNumberingGap: Detector = (doc, options) =>
59
61
  findingsOf("numbering-gap", (tree, source) => numberingBreaks(tree, ...numberingReadings(doc, source)))(doc, options);