chaffjs 0.39.0 → 0.41.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 (434) hide show
  1. package/README.ja.md +3 -2
  2. package/README.md +2 -1
  3. package/dist/ai-score/human-shares.d.ts.map +1 -1
  4. package/dist/ai-score/human-shares.js +1 -0
  5. package/dist/ai-score/human-shares.js.map +1 -1
  6. package/dist/alternative-words.d.ts +6 -0
  7. package/dist/alternative-words.d.ts.map +1 -1
  8. package/dist/alternative-words.js +10 -0
  9. package/dist/alternative-words.js.map +1 -1
  10. package/dist/closing-code.d.ts +8 -0
  11. package/dist/closing-code.d.ts.map +1 -0
  12. package/dist/closing-code.js +18 -0
  13. package/dist/closing-code.js.map +1 -0
  14. package/dist/composite-signals.d.ts +6 -0
  15. package/dist/composite-signals.d.ts.map +1 -0
  16. package/dist/composite-signals.js +23 -0
  17. package/dist/composite-signals.js.map +1 -0
  18. package/dist/date-format.d.ts +19 -1
  19. package/dist/date-format.d.ts.map +1 -1
  20. package/dist/date-format.js +41 -5
  21. package/dist/date-format.js.map +1 -1
  22. package/dist/detectors/acronym-context.d.ts +5 -1
  23. package/dist/detectors/acronym-context.d.ts.map +1 -1
  24. package/dist/detectors/acronym-context.js +48 -2
  25. package/dist/detectors/acronym-context.js.map +1 -1
  26. package/dist/detectors/acronym-mention.d.ts +5 -0
  27. package/dist/detectors/acronym-mention.d.ts.map +1 -1
  28. package/dist/detectors/acronym-mention.js +16 -0
  29. package/dist/detectors/acronym-mention.js.map +1 -1
  30. package/dist/detectors/acronym-name.d.ts +5 -0
  31. package/dist/detectors/acronym-name.d.ts.map +1 -1
  32. package/dist/detectors/acronym-name.js +15 -0
  33. package/dist/detectors/acronym-name.js.map +1 -1
  34. package/dist/detectors/acronym-series.d.ts +5 -0
  35. package/dist/detectors/acronym-series.d.ts.map +1 -1
  36. package/dist/detectors/acronym-series.js +18 -3
  37. package/dist/detectors/acronym-series.js.map +1 -1
  38. package/dist/detectors/ai-phrasing.d.ts.map +1 -1
  39. package/dist/detectors/ai-phrasing.js +7 -1
  40. package/dist/detectors/ai-phrasing.js.map +1 -1
  41. package/dist/detectors/ai-structure.d.ts.map +1 -1
  42. package/dist/detectors/ai-structure.js +6 -2
  43. package/dist/detectors/ai-structure.js.map +1 -1
  44. package/dist/detectors/blank-runs.d.ts +12 -0
  45. package/dist/detectors/blank-runs.d.ts.map +1 -0
  46. package/dist/detectors/blank-runs.js +27 -0
  47. package/dist/detectors/blank-runs.js.map +1 -0
  48. package/dist/detectors/bold-label.d.ts +3 -1
  49. package/dist/detectors/bold-label.d.ts.map +1 -1
  50. package/dist/detectors/bold-label.js +16 -6
  51. package/dist/detectors/bold-label.js.map +1 -1
  52. package/dist/detectors/capitalised-term.d.ts.map +1 -1
  53. package/dist/detectors/capitalised-term.js +28 -9
  54. package/dist/detectors/capitalised-term.js.map +1 -1
  55. package/dist/detectors/citation-string.d.ts +6 -0
  56. package/dist/detectors/citation-string.d.ts.map +1 -1
  57. package/dist/detectors/citation-string.js +52 -0
  58. package/dist/detectors/citation-string.js.map +1 -1
  59. package/dist/detectors/contraction-emphasis.d.ts +3 -0
  60. package/dist/detectors/contraction-emphasis.d.ts.map +1 -0
  61. package/dist/detectors/contraction-emphasis.js +24 -0
  62. package/dist/detectors/contraction-emphasis.js.map +1 -0
  63. package/dist/detectors/contraction-mention.d.ts +12 -1
  64. package/dist/detectors/contraction-mention.d.ts.map +1 -1
  65. package/dist/detectors/contraction-mention.js +39 -6
  66. package/dist/detectors/contraction-mention.js.map +1 -1
  67. package/dist/detectors/contraction-mix.d.ts +3 -0
  68. package/dist/detectors/contraction-mix.d.ts.map +1 -0
  69. package/dist/detectors/contraction-mix.js +76 -0
  70. package/dist/detectors/contraction-mix.js.map +1 -0
  71. package/dist/detectors/contraction-set-apart.d.ts +14 -0
  72. package/dist/detectors/contraction-set-apart.d.ts.map +1 -0
  73. package/dist/detectors/contraction-set-apart.js +42 -0
  74. package/dist/detectors/contraction-set-apart.js.map +1 -0
  75. package/dist/detectors/date-format.d.ts.map +1 -1
  76. package/dist/detectors/date-format.js +13 -1
  77. package/dist/detectors/date-format.js.map +1 -1
  78. package/dist/detectors/densest-stretch.d.ts +11 -0
  79. package/dist/detectors/densest-stretch.d.ts.map +1 -0
  80. package/dist/detectors/densest-stretch.js +14 -0
  81. package/dist/detectors/densest-stretch.js.map +1 -0
  82. package/dist/detectors/doubled-word.d.ts.map +1 -1
  83. package/dist/detectors/doubled-word.js +8 -4
  84. package/dist/detectors/doubled-word.js.map +1 -1
  85. package/dist/detectors/duplicate-definition.d.ts +3 -0
  86. package/dist/detectors/duplicate-definition.d.ts.map +1 -0
  87. package/dist/detectors/duplicate-definition.js +16 -0
  88. package/dist/detectors/duplicate-definition.js.map +1 -0
  89. package/dist/detectors/final-period-captions.d.ts +15 -0
  90. package/dist/detectors/final-period-captions.d.ts.map +1 -0
  91. package/dist/detectors/final-period-captions.js +61 -0
  92. package/dist/detectors/final-period-captions.js.map +1 -0
  93. package/dist/detectors/fullwidth-alnum.d.ts +3 -0
  94. package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
  95. package/dist/detectors/fullwidth-alnum.js +11 -2
  96. package/dist/detectors/fullwidth-alnum.js.map +1 -1
  97. package/dist/detectors/gram-furniture.d.ts +8 -5
  98. package/dist/detectors/gram-furniture.d.ts.map +1 -1
  99. package/dist/detectors/gram-furniture.js +23 -13
  100. package/dist/detectors/gram-furniture.js.map +1 -1
  101. package/dist/detectors/gram-openers.d.ts +11 -0
  102. package/dist/detectors/gram-openers.d.ts.map +1 -1
  103. package/dist/detectors/gram-openers.js +42 -1
  104. package/dist/detectors/gram-openers.js.map +1 -1
  105. package/dist/detectors/gram-repetition.d.ts.map +1 -1
  106. package/dist/detectors/gram-repetition.js +18 -7
  107. package/dist/detectors/gram-repetition.js.map +1 -1
  108. package/dist/detectors/heading-sentences.d.ts +10 -0
  109. package/dist/detectors/heading-sentences.d.ts.map +1 -0
  110. package/dist/detectors/heading-sentences.js +32 -0
  111. package/dist/detectors/heading-sentences.js.map +1 -0
  112. package/dist/detectors/known-correction.d.ts.map +1 -1
  113. package/dist/detectors/known-correction.js +11 -9
  114. package/dist/detectors/known-correction.js.map +1 -1
  115. package/dist/detectors/lexicon.d.ts +2 -3
  116. package/dist/detectors/lexicon.d.ts.map +1 -1
  117. package/dist/detectors/lexicon.js +16 -56
  118. package/dist/detectors/lexicon.js.map +1 -1
  119. package/dist/detectors/list-lead-in.d.ts +1 -1
  120. package/dist/detectors/list-lead-in.d.ts.map +1 -1
  121. package/dist/detectors/list-lead-in.js +42 -11
  122. package/dist/detectors/list-lead-in.js.map +1 -1
  123. package/dist/detectors/list-run.d.ts.map +1 -1
  124. package/dist/detectors/list-run.js +16 -2
  125. package/dist/detectors/list-run.js.map +1 -1
  126. package/dist/detectors/missing-final-period.d.ts.map +1 -1
  127. package/dist/detectors/missing-final-period.js +3 -1
  128. package/dist/detectors/missing-final-period.js.map +1 -1
  129. package/dist/detectors/numbering-readings.d.ts +2 -2
  130. package/dist/detectors/numbering-readings.d.ts.map +1 -1
  131. package/dist/detectors/numbering-readings.js +7 -0
  132. package/dist/detectors/numbering-readings.js.map +1 -1
  133. package/dist/detectors/open-end-anaphor.d.ts +8 -0
  134. package/dist/detectors/open-end-anaphor.d.ts.map +1 -0
  135. package/dist/detectors/open-end-anaphor.js +22 -0
  136. package/dist/detectors/open-end-anaphor.js.map +1 -0
  137. package/dist/detectors/open-end-lead.d.ts +4 -0
  138. package/dist/detectors/open-end-lead.d.ts.map +1 -0
  139. package/dist/detectors/open-end-lead.js +34 -0
  140. package/dist/detectors/open-end-lead.js.map +1 -0
  141. package/dist/detectors/open-end-scope.d.ts.map +1 -1
  142. package/dist/detectors/open-end-scope.js +7 -1
  143. package/dist/detectors/open-end-scope.js.map +1 -1
  144. package/dist/detectors/ordinal-run-gaps.d.ts +1 -0
  145. package/dist/detectors/ordinal-run-gaps.d.ts.map +1 -1
  146. package/dist/detectors/ordinal-run-gaps.js +1 -1
  147. package/dist/detectors/ordinal-run-gaps.js.map +1 -1
  148. package/dist/detectors/orthographic-variant-open.d.ts +4 -2
  149. package/dist/detectors/orthographic-variant-open.d.ts.map +1 -1
  150. package/dist/detectors/orthographic-variant-open.js +5 -3
  151. package/dist/detectors/orthographic-variant-open.js.map +1 -1
  152. package/dist/detectors/orthography.d.ts.map +1 -1
  153. package/dist/detectors/orthography.js +14 -5
  154. package/dist/detectors/orthography.js.map +1 -1
  155. package/dist/detectors/oxford-comma.d.ts.map +1 -1
  156. package/dist/detectors/oxford-comma.js +17 -2
  157. package/dist/detectors/oxford-comma.js.map +1 -1
  158. package/dist/detectors/phrase-match.d.ts.map +1 -1
  159. package/dist/detectors/phrase-match.js +3 -2
  160. package/dist/detectors/phrase-match.js.map +1 -1
  161. package/dist/detectors/placeholder-text.d.ts.map +1 -1
  162. package/dist/detectors/placeholder-text.js +14 -2
  163. package/dist/detectors/placeholder-text.js.map +1 -1
  164. package/dist/detectors/quote-without-source.d.ts +6 -2
  165. package/dist/detectors/quote-without-source.d.ts.map +1 -1
  166. package/dist/detectors/quote-without-source.js +33 -8
  167. package/dist/detectors/quote-without-source.js.map +1 -1
  168. package/dist/detectors/quoted-pattern.d.ts +2 -0
  169. package/dist/detectors/quoted-pattern.d.ts.map +1 -0
  170. package/dist/detectors/quoted-pattern.js +13 -0
  171. package/dist/detectors/quoted-pattern.js.map +1 -0
  172. package/dist/detectors/reference-entry.d.ts +5 -0
  173. package/dist/detectors/reference-entry.d.ts.map +1 -1
  174. package/dist/detectors/reference-entry.js +6 -1
  175. package/dist/detectors/reference-entry.js.map +1 -1
  176. package/dist/detectors/register-separate-part.d.ts +7 -0
  177. package/dist/detectors/register-separate-part.d.ts.map +1 -0
  178. package/dist/detectors/register-separate-part.js +32 -0
  179. package/dist/detectors/register-separate-part.js.map +1 -0
  180. package/dist/detectors/registry/contraction-mix.js +1 -1
  181. package/dist/detectors/registry/contraction-mix.js.map +1 -1
  182. package/dist/detectors/registry/duplicate-definition.js +1 -1
  183. package/dist/detectors/registry/duplicate-definition.js.map +1 -1
  184. package/dist/detectors/relative-pronoun-mix.d.ts.map +1 -1
  185. package/dist/detectors/relative-pronoun-mix.js +7 -3
  186. package/dist/detectors/relative-pronoun-mix.js.map +1 -1
  187. package/dist/detectors/reproduced-text.d.ts +5 -0
  188. package/dist/detectors/reproduced-text.d.ts.map +1 -0
  189. package/dist/detectors/reproduced-text.js +19 -0
  190. package/dist/detectors/reproduced-text.js.map +1 -0
  191. package/dist/detectors/request-owner.d.ts +2 -1
  192. package/dist/detectors/request-owner.d.ts.map +1 -1
  193. package/dist/detectors/request-owner.js +31 -7
  194. package/dist/detectors/request-owner.js.map +1 -1
  195. package/dist/detectors/requirement-smell.d.ts.map +1 -1
  196. package/dist/detectors/requirement-smell.js +16 -5
  197. package/dist/detectors/requirement-smell.js.map +1 -1
  198. package/dist/detectors/sentence-counts.d.ts +2 -1
  199. package/dist/detectors/sentence-counts.d.ts.map +1 -1
  200. package/dist/detectors/sentence-counts.js +23 -7
  201. package/dist/detectors/sentence-counts.js.map +1 -1
  202. package/dist/detectors/sentence-ending.d.ts +1 -0
  203. package/dist/detectors/sentence-ending.d.ts.map +1 -1
  204. package/dist/detectors/sentence-ending.js +5 -2
  205. package/dist/detectors/sentence-ending.js.map +1 -1
  206. package/dist/detectors/sentence-length.d.ts.map +1 -1
  207. package/dist/detectors/sentence-length.js +13 -3
  208. package/dist/detectors/sentence-length.js.map +1 -1
  209. package/dist/detectors/sentence-parts.d.ts +7 -0
  210. package/dist/detectors/sentence-parts.d.ts.map +1 -1
  211. package/dist/detectors/sentence-parts.js +11 -1
  212. package/dist/detectors/sentence-parts.js.map +1 -1
  213. package/dist/detectors/signals.d.ts.map +1 -1
  214. package/dist/detectors/signals.js +31 -7
  215. package/dist/detectors/signals.js.map +1 -1
  216. package/dist/detectors/spelling-variety.d.ts.map +1 -1
  217. package/dist/detectors/spelling-variety.js +20 -2
  218. package/dist/detectors/spelling-variety.js.map +1 -1
  219. package/dist/detectors/structure-tree.d.ts +2 -1
  220. package/dist/detectors/structure-tree.d.ts.map +1 -1
  221. package/dist/detectors/structure-tree.js +2 -7
  222. package/dist/detectors/structure-tree.js.map +1 -1
  223. package/dist/detectors/structure.d.ts.map +1 -1
  224. package/dist/detectors/structure.js +19 -5
  225. package/dist/detectors/structure.js.map +1 -1
  226. package/dist/detectors/superlative-context.d.ts +2 -1
  227. package/dist/detectors/superlative-context.d.ts.map +1 -1
  228. package/dist/detectors/superlative-context.js +9 -2
  229. package/dist/detectors/superlative-context.js.map +1 -1
  230. package/dist/detectors/title-list.d.ts +7 -0
  231. package/dist/detectors/title-list.d.ts.map +1 -0
  232. package/dist/detectors/title-list.js +14 -0
  233. package/dist/detectors/title-list.js.map +1 -0
  234. package/dist/detectors/token-shape.d.ts.map +1 -1
  235. package/dist/detectors/token-shape.js +17 -7
  236. package/dist/detectors/token-shape.js.map +1 -1
  237. package/dist/detectors/undefined-term.d.ts +5 -0
  238. package/dist/detectors/undefined-term.d.ts.map +1 -1
  239. package/dist/detectors/undefined-term.js +22 -1
  240. package/dist/detectors/undefined-term.js.map +1 -1
  241. package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
  242. package/dist/detectors/unfilled-placeholder.js +15 -1
  243. package/dist/detectors/unfilled-placeholder.js.map +1 -1
  244. package/dist/detectors/unknown-word-context.d.ts +9 -0
  245. package/dist/detectors/unknown-word-context.d.ts.map +1 -1
  246. package/dist/detectors/unknown-word-context.js +15 -0
  247. package/dist/detectors/unknown-word-context.js.map +1 -1
  248. package/dist/detectors/unknown-word.d.ts.map +1 -1
  249. package/dist/detectors/unknown-word.js +12 -4
  250. package/dist/detectors/unknown-word.js.map +1 -1
  251. package/dist/latin-spacing-source.d.ts +12 -0
  252. package/dist/latin-spacing-source.d.ts.map +1 -0
  253. package/dist/latin-spacing-source.js +25 -0
  254. package/dist/latin-spacing-source.js.map +1 -0
  255. package/dist/name-separator.d.ts.map +1 -1
  256. package/dist/name-separator.js +4 -1
  257. package/dist/name-separator.js.map +1 -1
  258. package/dist/paragraph-length.d.ts +14 -0
  259. package/dist/paragraph-length.d.ts.map +1 -1
  260. package/dist/paragraph-length.js +25 -0
  261. package/dist/paragraph-length.js.map +1 -1
  262. package/dist/paragraph-runs.d.ts +2 -2
  263. package/dist/paragraph-runs.d.ts.map +1 -1
  264. package/dist/paragraph-runs.js +65 -14
  265. package/dist/paragraph-runs.js.map +1 -1
  266. package/dist/plugin.d.ts +2 -0
  267. package/dist/plugin.d.ts.map +1 -1
  268. package/dist/quote-echo.d.ts +6 -0
  269. package/dist/quote-echo.d.ts.map +1 -0
  270. package/dist/quote-echo.js +14 -0
  271. package/dist/quote-echo.js.map +1 -0
  272. package/dist/run.d.ts.map +1 -1
  273. package/dist/run.js +4 -2
  274. package/dist/run.js.map +1 -1
  275. package/dist/semantic.d.ts.map +1 -1
  276. package/dist/semantic.js +2 -2
  277. package/dist/semantic.js.map +1 -1
  278. package/dist/set-phrase-particles.d.ts +4 -0
  279. package/dist/set-phrase-particles.d.ts.map +1 -0
  280. package/dist/set-phrase-particles.js +26 -0
  281. package/dist/set-phrase-particles.js.map +1 -0
  282. package/dist/structure/alternative-clause.d.ts +7 -0
  283. package/dist/structure/alternative-clause.d.ts.map +1 -1
  284. package/dist/structure/alternative-clause.js +23 -8
  285. package/dist/structure/alternative-clause.js.map +1 -1
  286. package/dist/structure/cited-document-section.d.ts +2 -0
  287. package/dist/structure/cited-document-section.d.ts.map +1 -1
  288. package/dist/structure/cited-document-section.js +8 -0
  289. package/dist/structure/cited-document-section.js.map +1 -1
  290. package/dist/structure/issues.d.ts +3 -1
  291. package/dist/structure/issues.d.ts.map +1 -1
  292. package/dist/structure/issues.js +12 -8
  293. package/dist/structure/issues.js.map +1 -1
  294. package/dist/structure/numbering.d.ts +10 -1
  295. package/dist/structure/numbering.d.ts.map +1 -1
  296. package/dist/structure/numbering.js +41 -4
  297. package/dist/structure/numbering.js.map +1 -1
  298. package/dist/structure/unread-label.d.ts +13 -0
  299. package/dist/structure/unread-label.d.ts.map +1 -0
  300. package/dist/structure/unread-label.js +70 -0
  301. package/dist/structure/unread-label.js.map +1 -0
  302. package/dist/structure-shape/faq-sections.d.ts +7 -0
  303. package/dist/structure-shape/faq-sections.d.ts.map +1 -0
  304. package/dist/structure-shape/faq-sections.js +14 -0
  305. package/dist/structure-shape/faq-sections.js.map +1 -0
  306. package/dist/structure-shape/features.d.ts.map +1 -1
  307. package/dist/structure-shape/features.js +5 -3
  308. package/dist/structure-shape/features.js.map +1 -1
  309. package/dist/topic-clause.d.ts.map +1 -1
  310. package/dist/topic-clause.js +15 -2
  311. package/dist/topic-clause.js.map +1 -1
  312. package/package.json +3 -3
  313. package/rules/ai-generated-composite.yaml +3 -2
  314. package/rules/ai-structure.yaml +2 -2
  315. package/rules/ai-tell.yaml +8 -4
  316. package/rules/bold-label-list.yaml +6 -6
  317. package/rules/closing-cliche.yaml +2 -2
  318. package/rules/colon-lead-in.yaml +2 -2
  319. package/rules/contraction-consistency.yaml +4 -2
  320. package/rules/contrast-framing.yaml +3 -3
  321. package/rules/date-format-consistency.yaml +2 -2
  322. package/rules/duplicate-definition.yaml +2 -2
  323. package/rules/fullwidth-alnum-consistency.yaml +2 -2
  324. package/rules/honesty-marker.yaml +84 -0
  325. package/rules/latin-spacing.yaml +6 -4
  326. package/rules/max-paragraph-length.yaml +2 -2
  327. package/rules/max-sentence-length.yaml +4 -2
  328. package/rules/missing-final-period.yaml +2 -2
  329. package/rules/ngram-repetition.yaml +2 -2
  330. package/rules/no-doubled-joshi.yaml +2 -2
  331. package/rules/no-mixed-desumasu.yaml +2 -2
  332. package/rules/nominalization.yaml +1 -1
  333. package/rules/numbering-gap.yaml +2 -2
  334. package/rules/one-sentence-paragraph-run.yaml +2 -2
  335. package/rules/orthographic-variant.yaml +2 -2
  336. package/rules/oxford-comma-consistency.yaml +2 -2
  337. package/rules/quote-without-source.yaml +2 -2
  338. package/rules/request-without-deadline.yaml +2 -2
  339. package/rules/requirement-smell.yaml +2 -2
  340. package/rules/spelling-consistency.yaml +4 -4
  341. package/rules/teki-overuse.yaml +2 -2
  342. package/rules/topic-predicate-distance.yaml +2 -2
  343. package/rules/undefined-acronym.yaml +5 -2
  344. package/rules/undefined-term.yaml +2 -2
  345. package/rules/unfilled-placeholder.yaml +2 -2
  346. package/rules/unknown-word.yaml +2 -2
  347. package/rules/unqualified-superlative.yaml +1 -1
  348. package/skills/chaff/SKILL.md +2 -1
  349. package/src/ai-score/human-shares.ts +1 -0
  350. package/src/alternative-words.ts +15 -0
  351. package/src/closing-code.ts +21 -0
  352. package/src/composite-signals.ts +27 -0
  353. package/src/date-format.ts +54 -7
  354. package/src/detectors/acronym-context.ts +61 -2
  355. package/src/detectors/acronym-mention.ts +17 -0
  356. package/src/detectors/acronym-name.ts +18 -0
  357. package/src/detectors/acronym-series.ts +22 -3
  358. package/src/detectors/ai-phrasing.ts +7 -1
  359. package/src/detectors/ai-structure.ts +6 -2
  360. package/src/detectors/blank-runs.ts +30 -0
  361. package/src/detectors/bold-label.ts +22 -6
  362. package/src/detectors/capitalised-term.ts +36 -9
  363. package/src/detectors/citation-string.ts +57 -0
  364. package/src/detectors/contraction-emphasis.ts +46 -0
  365. package/src/detectors/contraction-mention.ts +52 -6
  366. package/src/detectors/contraction-mix.ts +104 -0
  367. package/src/detectors/contraction-set-apart.ts +52 -0
  368. package/src/detectors/date-format.ts +18 -2
  369. package/src/detectors/densest-stretch.ts +21 -0
  370. package/src/detectors/doubled-word.ts +10 -10
  371. package/src/detectors/duplicate-definition.ts +21 -0
  372. package/src/detectors/final-period-captions.ts +78 -0
  373. package/src/detectors/fullwidth-alnum.ts +19 -3
  374. package/src/detectors/gram-furniture.ts +27 -13
  375. package/src/detectors/gram-openers.ts +54 -1
  376. package/src/detectors/gram-repetition.ts +21 -7
  377. package/src/detectors/heading-sentences.ts +36 -0
  378. package/src/detectors/known-correction.ts +15 -8
  379. package/src/detectors/lexicon.ts +18 -62
  380. package/src/detectors/list-lead-in.ts +60 -11
  381. package/src/detectors/list-run.ts +16 -2
  382. package/src/detectors/missing-final-period.ts +9 -1
  383. package/src/detectors/numbering-readings.ts +10 -2
  384. package/src/detectors/open-end-anaphor.ts +31 -0
  385. package/src/detectors/open-end-lead.ts +46 -0
  386. package/src/detectors/open-end-scope.ts +8 -1
  387. package/src/detectors/ordinal-run-gaps.ts +1 -1
  388. package/src/detectors/orthographic-variant-open.ts +8 -3
  389. package/src/detectors/orthography.ts +20 -7
  390. package/src/detectors/oxford-comma.ts +17 -2
  391. package/src/detectors/phrase-match.ts +3 -2
  392. package/src/detectors/placeholder-text.ts +21 -4
  393. package/src/detectors/quote-without-source.ts +52 -10
  394. package/src/detectors/quoted-pattern.ts +14 -0
  395. package/src/detectors/reference-entry.ts +8 -1
  396. package/src/detectors/register-separate-part.ts +42 -0
  397. package/src/detectors/registry/contraction-mix.ts +1 -1
  398. package/src/detectors/registry/duplicate-definition.ts +1 -1
  399. package/src/detectors/relative-pronoun-mix.ts +5 -3
  400. package/src/detectors/reproduced-text.ts +33 -0
  401. package/src/detectors/request-owner.ts +31 -8
  402. package/src/detectors/requirement-smell.ts +21 -5
  403. package/src/detectors/sentence-counts.ts +27 -7
  404. package/src/detectors/sentence-ending.ts +6 -2
  405. package/src/detectors/sentence-length.ts +18 -3
  406. package/src/detectors/sentence-parts.ts +19 -1
  407. package/src/detectors/signals.ts +35 -7
  408. package/src/detectors/spelling-variety.ts +26 -2
  409. package/src/detectors/structure-tree.ts +2 -8
  410. package/src/detectors/structure.ts +22 -6
  411. package/src/detectors/superlative-context.ts +10 -2
  412. package/src/detectors/title-list.ts +21 -0
  413. package/src/detectors/token-shape.ts +35 -21
  414. package/src/detectors/undefined-term.ts +26 -1
  415. package/src/detectors/unfilled-placeholder.ts +20 -2
  416. package/src/detectors/unknown-word-context.ts +23 -0
  417. package/src/detectors/unknown-word.ts +23 -4
  418. package/src/latin-spacing-source.ts +33 -0
  419. package/src/name-separator.ts +4 -1
  420. package/src/paragraph-length.ts +31 -0
  421. package/src/paragraph-runs.ts +71 -13
  422. package/src/plugin.ts +2 -0
  423. package/src/quote-echo.ts +18 -0
  424. package/src/run.ts +4 -2
  425. package/src/semantic.ts +2 -3
  426. package/src/set-phrase-particles.ts +32 -0
  427. package/src/structure/alternative-clause.ts +32 -7
  428. package/src/structure/cited-document-section.ts +8 -0
  429. package/src/structure/issues.ts +19 -9
  430. package/src/structure/numbering.ts +50 -3
  431. package/src/structure/unread-label.ts +74 -0
  432. package/src/structure-shape/faq-sections.ts +24 -0
  433. package/src/structure-shape/features.ts +5 -3
  434. package/src/topic-clause.ts +16 -2
@@ -56,6 +56,7 @@ import { namesDivision, qualifiesPrevious } from "./list-comma-aside.ts";
56
56
  import { inExcerpt } from "./quoted-excerpt.ts";
57
57
  import { listContinues, walker, type Walk } from "./list-run.ts";
58
58
  import { joinsUnfinished, repeatsConjunction } from "./list-joint.ts";
59
+ import { insideSentenceCaseTitle } from "./title-list.ts";
59
60
 
60
61
  const EMPTY: TokenRange = { start: 0, end: 0 };
61
62
 
@@ -121,6 +122,19 @@ const afterClosedList = (view: View): View => {
121
122
  return isItem(scope, rest) ? { ...after(view, closing), pre: rest } : withoutLead(after(view, closing));
122
123
  };
123
124
 
125
+ /**
126
+ * 動詞で終わる最初の項目のすぐ後ろの、前置詞で始まる項目は、動詞と目的語のあいだに読点で挟んだ句(if it received, at its most
127
+ * recent examination, a rating of "1" or "2" and it satisfies)。動詞も句も並びの項目ではなく、並びがあるなら句の後ろの目的語から。
128
+ * 句の後ろも前置詞で始まれば、前置詞の句の並び(collected, in batches, in files, and in tables)なので外さない。
129
+ */
130
+ const afterVerbAside = (view: View): View => {
131
+ const { scope } = view.list;
132
+ const [verb, aside] = [firstOf(view), secondOf(view)];
133
+ if (verb === undefined || aside === undefined || lastContent(scope, verb.item)?.pos !== "VERB" || openingOf(scope, aside.item)?.pos !== "ADP") return view;
134
+ const object = firstOf(after(view, aside));
135
+ return object !== undefined && opensAsNoun(scope, object.item) ? after(view, aside) : view;
136
+ };
137
+
124
138
  /**
125
139
  * 項目として立つ切れ端か。副詞だけ(does not の not)や、目的語を後ろに残した前置詞で終わるもの(or impose conditions upon,
126
140
  * certain transmittals / directly related to, and necessary for, the licensing)は、読点の後ろへ続く句の頭で、項目ではない。
@@ -345,7 +359,7 @@ const listAt = (list: ItemList, at: number, walk: Walk): boolean | undefined =>
345
359
  const { scope } = list;
346
360
  if (closesExampleAside(wholeList(list), at)) return undefined;
347
361
  const afterItem = itemAfter(scope, at);
348
- const opened = afterClosedList(withoutLead(afterClauseTurn(withoutCoordinateAdjective(wholeList(list)), afterItem)));
362
+ const opened = afterClosedList(withoutLead(afterVerbAside(afterClauseTurn(withoutCoordinateAdjective(wholeList(list)), afterItem))));
349
363
  const items = fromParticiplePhrase(fromExample(opened, afterItem), afterItem);
350
364
  if (listContinues(scope, afterItem, walk) || isAppositive(scope, at, items, afterItem) || insideLastItem(scope, at, items, afterItem)) return undefined;
351
365
  if (namesDivision(items) || qualifiesPrevious(items)) return undefined;
@@ -368,12 +382,13 @@ export const listVerdicts = (tokens: readonly Token[], words: ListWords, source:
368
382
  const readItems = listReader(sentence);
369
383
  const breaks = dashBreaks(tokens, source);
370
384
  const excerpt = inExcerpt(tokens, source, words.elision ?? []);
385
+ const inTitle = insideSentenceCaseTitle(tokens);
371
386
  const walk = walker();
372
387
  return tokens.flatMap((token, at) => {
373
388
  if (!isJudgedConjunction(token, at)) return [];
374
389
  // 郵便番号で終わる住所のあとの and / or は、住所の行を区切る読点のあと。並びの読点ではない。
375
390
  // 最後の読点のあとに前後を空けたダッシュがあれば(Washington, DC – The …)、読点はダッシュの前で閉じた日付行や見出しのもの。
376
- const notList = sentence.inCitedTitle(at) || excerpt(at) || followsPostcode(source, token.span.start) || breaks[at] === true;
391
+ const notList = sentence.inCitedTitle(at) || inTitle(at) || excerpt(at) || followsPostcode(source, token.span.start) || breaks[at] === true;
377
392
  return [notList ? undefined : listAt(readItems(at), at, walk)];
378
393
  });
379
394
  };
@@ -2,6 +2,7 @@ import type { Detector, DetectorOptions, Finding, Lexicon, LexiconEntry, ProseDo
2
2
  import { entryEnds, entryIn } from "./lexicon-match.ts";
3
3
  import { mentionCuesOf, onlyMentioned } from "./mentioned-phrase.ts";
4
4
  import { closingSentences } from "../closing-paragraph.ts";
5
+ import { quotedPattern } from "./quoted-pattern.ts";
5
6
 
6
7
  /** 冒頭は先頭 2 段落ぶん。「どの記事にも当てはまる書き出し」は冒頭にあるときだけ問題。 */
7
8
  const OPENING_SENTENCES = 4;
@@ -24,7 +25,7 @@ type IsUsed = (sentence: Sentence, entry: LexiconEntry) => boolean;
24
25
  const hitsIn = (sentences: readonly Sentence[], lexicon: Lexicon, isUsed: IsUsed = () => true): Hit[] =>
25
26
  sentences.flatMap((sentence) => {
26
27
  const matched = lexicon.find((entry) => entryIn(sentence, entry) && isUsed(sentence, entry));
27
- return matched === undefined ? [] : [{ sentence, matched: matched.pattern }];
28
+ return matched === undefined ? [] : [{ sentence, matched: quotedPattern(matched.pattern) }];
28
29
  });
29
30
 
30
31
  const findingsOf = (hits: readonly Hit[], limit: number, count = hits.length): Finding[] =>
@@ -74,7 +75,7 @@ const usesIn = (sentence: Sentence, lexicon: Lexicon): Uses | undefined => {
74
75
  const found = lexicon.map((entry) => ({ entry, ends: entryEnds(sentence, entry) })).filter(({ ends }) => ends.length > 0);
75
76
  const first = found.toSorted((a, b) => Math.min(...a.ends) - Math.min(...b.ends))[0];
76
77
  if (first === undefined) return undefined;
77
- return { sentence, matched: first.entry.pattern, count: new Set(found.flatMap(({ ends }) => ends)).size };
78
+ return { sentence, matched: quotedPattern(first.entry.pattern), count: new Set(found.flatMap(({ ends }) => ends)).size };
78
79
  };
79
80
 
80
81
  /**
@@ -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[] => {
@@ -6,7 +6,7 @@
6
6
  import { QUOTATION_MARKS, quotedSpans } from "../quoted-span.ts";
7
7
  import { readMarkdown } from "../markdown-read.ts";
8
8
  import { blockQuotations, type BlockQuotation } from "./block-quotation.ts";
9
- import type { Detector, Finding, LexiconEntry, ProseDocument } from "../plugin.ts";
9
+ import type { Detector, Finding, LexiconEntry, Paragraph, ProseDocument } from "../plugin.ts";
10
10
 
11
11
  export type QuoteText = { readonly start: number; readonly text: string };
12
12
 
@@ -56,8 +56,11 @@ const cueStarts = (text: string, cue: string): number[] => {
56
56
 
57
57
  type Quoted = { readonly start: number; readonly end: number };
58
58
 
59
- /** The word lists the rule reads: quote-attribution, and quote-advice (「…」と述べる方が: a wording suggested, not quoted). */
60
- export type QuoteWords = { readonly cues: readonly LexiconEntry[]; readonly advice?: readonly LexiconEntry[] };
59
+ /**
60
+ * The word lists the rule reads: quote-attribution, quote-advice (「…」と述べる方が: a wording suggested, not quoted), and
61
+ * quote-not-attribution (an example made up by the writer, words received, words written on a thing).
62
+ */
63
+ export type QuoteWords = { readonly cues: readonly LexiconEntry[]; readonly advice?: readonly LexiconEntry[]; readonly not?: readonly LexiconEntry[] };
61
64
 
62
65
  const patternsIn = (entries: readonly LexiconEntry[], group: string): string[] =>
63
66
  entries.filter((entry) => entry.group === group && entry.pattern !== "").map((entry) => entry.pattern);
@@ -72,12 +75,27 @@ const isAdvice = (text: string, quoted: Quoted, advice: readonly LexiconEntry[])
72
75
  return patternsIn(advice, "say").some((say) => text.startsWith(say, after) && tails.some((tail) => text.startsWith(tail, after + say.length)));
73
76
  };
74
77
 
78
+ /** A word of the group stands in the text (an English one as a whole word, ignoring case). */
79
+ const standsIn = (text: string, entries: readonly LexiconEntry[], group: string): boolean =>
80
+ patternsIn(entries, group).some((word) => cueStarts(text, word).length > 0);
81
+
82
+ /** Words received rather than quoted, right after the closing mark: 「…」と言われて、送れない. */
83
+ const isReceived = (text: string, quoted: Quoted, not: readonly LexiconEntry[]): boolean =>
84
+ patternsIn(not, "received").some((tail) => text.startsWith(tail, quoted.end + 1));
85
+
86
+ /** The cue's subject is a thing, by the word right before it: a sign that said "…". */
87
+ const THING_GAP = /^\s+$/u;
88
+ const saidByThing = (text: string, at: number, not: readonly LexiconEntry[]): boolean =>
89
+ patternsIn(not, "thing").some((word) => cueStarts(text.slice(0, at), word).some((start) => THING_GAP.test(text.slice(start + word.length, at))));
90
+
75
91
  /** A cue just before the quotation's opening mark, or just after its closing mark. position says which side it may stand on. */
76
92
  /** Advice after the quotation silences only the cue after it: 山田氏によれば「…」と言う方が適切だ still gives the words to someone. */
77
- const isAttributed = (text: string, quoted: Quoted, { cues, advice = [] }: QuoteWords): boolean => {
78
- const advised = isAdvice(text, quoted, advice);
93
+ const isAttributed = (text: string, quoted: Quoted, { cues, advice = [], not = [] }: QuoteWords): boolean => {
94
+ if (standsIn(text.slice(0, quoted.start), not, "example")) return false;
95
+ const advised = isAdvice(text, quoted, advice) || isReceived(text, quoted, not);
79
96
  return cues.some((cue) =>
80
97
  cueStarts(text, cue.pattern).some((at) => {
98
+ if (saidByThing(text, at, not)) return false;
81
99
  const before = cue.position !== "after" && at + cue.pattern.length <= quoted.start - 1 && at + cue.pattern.length >= quoted.start - 1 - CUE_REACH_BEFORE;
82
100
  const after = !advised && cue.position !== "before" && at >= quoted.end + 1 && at <= quoted.end + 1 + CUE_REACH_AFTER;
83
101
  return before || after;
@@ -85,17 +103,27 @@ const isAttributed = (text: string, quoted: Quoted, { cues, advice = [] }: Quote
85
103
  );
86
104
  };
87
105
 
106
+ /** A Latin-script quotation with no space in it is one word, a term or a value ("core_claim_false"), not someone's words. */
107
+ const isOneWord = (quote: string): boolean => LATIN.test(quote) && !/\s/u.test(quote);
108
+
109
+ const isWords = (quote: string): boolean => [...quote].length >= MIN_QUOTE_CHARS && !isOneWord(quote);
110
+
88
111
  const quotesIn = (sentence: QuoteText, words: QuoteWords): UnsourcedQuote[] => {
89
112
  return quotedSpans(sentence.text, QUOTATION_MARKS)
90
- .filter((span) => [...sentence.text.slice(span.start, span.end).trim()].length >= MIN_QUOTE_CHARS && isAttributed(sentence.text, span, words))
113
+ .filter((span) => isWords(sentence.text.slice(span.start, span.end).trim()) && isAttributed(sentence.text, span, words))
91
114
  .map((span) => ({ offset: sentence.start + span.start, quote: sentence.text.slice(span.start, span.end).trim() }));
92
115
  };
93
116
 
94
117
  /** Each quotation given to someone, in a paragraph that names no source. cues: the word list quote-attribution. */
95
- export const unsourcedQuotes = (paragraphs: readonly QuoteParagraph[], cues: readonly LexiconEntry[], advice: readonly LexiconEntry[] = []): UnsourcedQuote[] =>
118
+ export const unsourcedQuotes = (
119
+ paragraphs: readonly QuoteParagraph[],
120
+ cues: readonly LexiconEntry[],
121
+ advice: readonly LexiconEntry[] = [],
122
+ not: readonly LexiconEntry[] = [],
123
+ ): UnsourcedQuote[] =>
96
124
  paragraphs
97
125
  .filter((paragraph) => !namesSource(paragraph.source))
98
- .flatMap((paragraph) => paragraph.sentences.flatMap((sentence) => quotesIn(sentence, { cues, advice })));
126
+ .flatMap((paragraph) => paragraph.sentences.flatMap((sentence) => quotesIn(sentence, { cues, advice, not })));
99
127
 
100
128
  /** Each block quotation given to someone by a dash line (— Name) with no source in it or on that line. */
101
129
  export const unsourcedBlockQuotes = (quotations: readonly BlockQuotation[]): UnsourcedQuote[] =>
@@ -112,14 +140,28 @@ const blockQuotesOf = (doc: ProseDocument): UnsourcedQuote[] => {
112
140
  return unsourcedBlockQuotes(blockQuotations(readMarkdown(doc.source).root, doc.source));
113
141
  };
114
142
 
143
+ /**
144
+ * The lines written together with a paragraph, with no blank line between: a note's quotation and the reference on the line
145
+ * above it are one block, and a source named there is named for the quotation.
146
+ */
147
+ const blockAround = (doc: ProseDocument, index: number): string => {
148
+ const joined = (left: Paragraph | undefined, right: Paragraph | undefined): boolean =>
149
+ left !== undefined && right !== undefined && !doc.source.slice(left.span.end, right.span.start).includes("\n\n");
150
+ const first = doc.paragraphs.slice(0, index + 1).findLastIndex((paragraph, at) => !joined(doc.paragraphs[at - 1], paragraph));
151
+ const after = doc.paragraphs.slice(index).findIndex((paragraph, offset) => !joined(paragraph, doc.paragraphs[index + offset + 1]));
152
+ const last = doc.paragraphs[index + after] ?? doc.paragraphs[index];
153
+ return doc.source.slice(doc.paragraphs[first]?.span.start ?? 0, last?.span.end ?? 0);
154
+ };
155
+
115
156
  const paragraphQuotesOf = (doc: ProseDocument): UnsourcedQuote[] =>
116
157
  unsourcedQuotes(
117
- doc.paragraphs.map((paragraph) => ({
118
- source: doc.source.slice(paragraph.span.start, paragraph.span.end),
158
+ doc.paragraphs.map((paragraph, index) => ({
159
+ source: blockAround(doc, index),
119
160
  sentences: paragraph.sentences.map((sentence) => ({ start: sentence.span.start, text: sentence.text })),
120
161
  })),
121
162
  doc.lexicons["quote-attribution"] ?? [],
122
163
  doc.lexicons["quote-advice"] ?? [],
164
+ doc.lexicons["quote-not-attribution"] ?? [],
123
165
  );
124
166
 
125
167
  /** Every quotation in the document given to someone with no source, in document order: what the rule and `cite --scaffold` list. */
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A comma or question mark at the edge of a lexicon pattern (、正直 / honestly,) only says where the phrase stands
3
+ * in the sentence; the message quotes the phrase without it. A period is kept: it may end an abbreviation (etc.).
4
+ */
5
+ const EDGE_MARKS: ReadonlySet<string> = new Set([" ", "、", ",", ",", "?", "?"]);
6
+
7
+ const isEdgeMark = (char: string): boolean => EDGE_MARKS.has(char);
8
+
9
+ export const quotedPattern = (pattern: string): string => {
10
+ const chars = [...pattern];
11
+ const start = chars.findIndex((char) => !isEdgeMark(char));
12
+ const end = chars.findLastIndex((char) => !isEdgeMark(char));
13
+ return start === -1 ? pattern : chars.slice(start, end + 1).join("");
14
+ };
@@ -8,7 +8,7 @@
8
8
  type Span = { readonly start: number; readonly end: number };
9
9
 
10
10
  /** A label in square brackets opening a line, then a wide gap: two spaces or a tab. A link definition ([x]: url) has a colon. */
11
- const ENTRY_START = /^(?<indent>[ \t]*)\[[A-Za-z0-9][\w.:+-]*\](?: {2,}|\t)\S/u;
11
+ const ENTRY_START = /^(?<indent>[ \t]*)\[(?<label>[A-Za-z0-9][\w.:+-]*)\](?: {2,}|\t)\S/u;
12
12
 
13
13
  type Line = { readonly text: string; readonly start: number };
14
14
 
@@ -40,3 +40,10 @@ export const referenceEntrySpans = (source: string): Span[] => {
40
40
  return [{ start: line.start, end: last.start + last.text.length }];
41
41
  });
42
42
  };
43
+
44
+ /**
45
+ * The labels of the entries ([UNIX] The Open Group, "The Single UNIX Specification"). The entry says what the label names,
46
+ * so the label written in prose (a UNIX timestamp) is explained by it.
47
+ */
48
+ export const referenceEntryLabels = (source: string): ReadonlySet<string> =>
49
+ new Set(linesOf(source).flatMap((line) => ENTRY_START.exec(line.text)?.groups?.["label"] ?? []));
@@ -0,0 +1,42 @@
1
+ import type { Section, Sentence } from "../plugin.ts";
2
+
3
+ // A document that holds two texts under two top-level headings (a directive, then the agency's page about it) may write each in
4
+ // its own register. A part whose sentences all share the register the rest of the document does not use is a text of its own,
5
+ // not a slip in the other. Pure.
6
+
7
+ /** The depth of a top-level heading: a part of the document starts at each one. */
8
+ const PART_DEPTH = 1;
9
+
10
+ /** One sentence alone in the other register may still be a slip; a part is read as its own text from two on. */
11
+ const MIN_SENTENCES = 2;
12
+
13
+ /** The sentences of each part opened by a top-level heading, in order, when the document has two such parts or more. */
14
+ const partsOf = (sections: readonly Section[]): Sentence[][] => {
15
+ const parts = sections.reduce<Sentence[][]>((found, section) => {
16
+ if (section.depth === PART_DEPTH) return [...found, [...section.sentences]];
17
+ const last = found.at(-1);
18
+ if (section.depth > PART_DEPTH && last !== undefined) last.push(...section.sentences);
19
+ return found;
20
+ }, []);
21
+ return parts.length >= 2 ? parts : [];
22
+ };
23
+
24
+ /**
25
+ * The sentences of every top-level part whose counted sentences (registerOf gives a register) are MIN_SENTENCES or more and all
26
+ * in one register other than majority, the register of the document as a whole.
27
+ */
28
+ export const separatePartSentences = <R>(
29
+ sections: readonly Section[],
30
+ registerOf: (sentence: Sentence) => R | undefined,
31
+ majority: R | undefined,
32
+ ): Set<Sentence> =>
33
+ new Set(
34
+ partsOf(sections).flatMap((sentences) => {
35
+ const registers = sentences.flatMap((sentence) => {
36
+ const register = registerOf(sentence);
37
+ return register === undefined ? [] : [register];
38
+ });
39
+ const own = registers.length >= MIN_SENTENCES && registers.every((register) => register === registers[0] && register !== majority);
40
+ return own ? sentences : [];
41
+ }),
42
+ );
@@ -1,4 +1,4 @@
1
1
  import type { Detector } from "../../plugin.ts";
2
- import { contractionMix } from "../lexicon.ts";
2
+ import { contractionMix } from "../contraction-mix.ts";
3
3
 
4
4
  export const detector: Detector = contractionMix;
@@ -1,4 +1,4 @@
1
1
  import type { Detector } from "../../plugin.ts";
2
- import { duplicateDefinition } from "../structure-tree.ts";
2
+ import { duplicateDefinition } from "../duplicate-definition.ts";
3
3
 
4
4
  export const detector: Detector = duplicateDefinition;
@@ -39,16 +39,18 @@ const opensRelative = (noun: Token | undefined, verb: Token | undefined, next: T
39
39
 
40
40
  /** which / that の後ろの、副詞を飛ばした最初の語(the file which usually stores の stores)。 */
41
41
  const verbAfter = (tokens: readonly Token[], at: number): number => {
42
- const found = tokens.findIndex((token, index) => index > at && token.pos !== "ADV");
43
- return found === -1 ? tokens.length : found;
42
+ let next = at + 1;
43
+ while (tokens[next]?.pos === "ADV") next += 1;
44
+ return next;
44
45
  };
45
46
 
46
47
  /** 語彙表の組(which / that)で、tokens の中の限定の関係節の頭。 */
47
48
  export const relativeUses = (tokens: readonly Token[], kinds: Lexicon): RelativeUse[] =>
48
49
  tokens.flatMap((word, at) => {
49
50
  const entry = kinds.find((candidate) => candidate.pattern.toLowerCase() === word.surface.toLowerCase());
51
+ if (entry?.group === undefined) return [];
50
52
  const verb = verbAfter(tokens, at);
51
- if (entry?.group === undefined || !opensRelative(tokens[at - 1], tokens[verb], tokens[verb + 1])) return [];
53
+ if (!opensRelative(tokens[at - 1], tokens[verb], tokens[verb + 1])) return [];
52
54
  return [{ word, kind: entry.group }];
53
55
  });
54
56
 
@@ -0,0 +1,33 @@
1
+ import type { Paragraph, Span, StructureNode } from "../plugin.ts";
2
+ import { articlesInCitedDocuments } from "../structure/cited-document-section.ts";
3
+
4
+ // Text the writer reproduces from another document, word for word: the articles of a statute copied under a heading that
5
+ // names it (### …に関する法律 / 第7条 …), and a paragraph after a lead-in that says it is reproduced (The entire receipt
6
+ // reads as follows:). Its sentences are the source's, not the writer's to shorten. Pure.
7
+
8
+ /** A lead-in closes its paragraph with a colon. */
9
+ const ENDS_WITH_COLON = /[::]\s*$/u;
10
+
11
+ const isVerbatimLead = (text: string, leads: readonly string[]): boolean =>
12
+ ENDS_WITH_COLON.test(text) && leads.some((lead) => text.toLowerCase().includes(lead.toLowerCase()));
13
+
14
+ /** The paragraphs right after a lead-in that says the next text is reproduced (reads as follows:, 次のように規定している:). */
15
+ const afterVerbatimLeads = (paragraphs: readonly Paragraph[], source: string, leads: readonly string[]): Span[] =>
16
+ paragraphs.flatMap((paragraph, at) => {
17
+ const next = paragraphs[at + 1];
18
+ return next !== undefined && isVerbatimLead(source.slice(paragraph.span.start, paragraph.span.end), leads) ? [next.span] : [];
19
+ });
20
+
21
+ /** The spans of reproduced text: copied articles of a cited statute, and the paragraph after a verbatim lead-in. */
22
+ export const reproducedSpans = (
23
+ structure: StructureNode | undefined,
24
+ paragraphs: readonly Paragraph[],
25
+ source: string,
26
+ leads: readonly string[],
27
+ ): readonly Span[] => [
28
+ ...(structure === undefined ? [] : articlesInCitedDocuments(structure).map((article) => article.span)),
29
+ ...afterVerbatimLeads(paragraphs, source, leads),
30
+ ];
31
+
32
+ export const isReproduced = (span: Span, reproduced: readonly Span[]): boolean =>
33
+ reproduced.some((outer) => outer.start <= span.start && span.end <= outer.end);
@@ -20,6 +20,7 @@ export const REQUEST_LEXICONS = {
20
20
  contact: "request-contact",
21
21
  prohibition: "request-prohibition",
22
22
  deadlineSection: "request-deadline-section",
23
+ noDeadlineTitle: "request-no-deadline-title",
23
24
  } as const;
24
25
 
25
26
  type Words = Readonly<Record<keyof typeof REQUEST_LEXICONS, readonly string[]>>;
@@ -42,6 +43,7 @@ const wordsOf = (doc: ProseDocument): Words => ({
42
43
  contact: patternsOf(doc.lexicons[REQUEST_LEXICONS.contact]),
43
44
  prohibition: patternsOf(doc.lexicons[REQUEST_LEXICONS.prohibition]),
44
45
  deadlineSection: patternsOf(doc.lexicons[REQUEST_LEXICONS.deadlineSection]),
46
+ noDeadlineTitle: patternsOf(doc.lexicons[REQUEST_LEXICONS.noDeadlineTitle]),
45
47
  });
46
48
 
47
49
  /** How far apart, in characters, the action word and the request ending may be: the action must be what is requested. */
@@ -228,26 +230,47 @@ const statesDeadline = (source: string, sentence: Sentence, words: Words, dates:
228
230
  };
229
231
 
230
232
  /**
231
- * Where a section headed only by a deadline-section word (a notice's "DATES:", "2. Deadline") states a date with a
232
- * deadline word: the document gives its deadline once there, for the requests that follow it. Undefined without one.
233
+ * The section headed only by a deadline-section word (a notice's "DATES:", "2. Deadline") that states a date with a
234
+ * deadline word: the document gives its deadline once there. -1 without one.
233
235
  */
234
- const documentDeadlineAt = (source: string, sections: readonly Section[], words: Words, dates: readonly Span[]): number | undefined =>
235
- sections.find(
236
+ const documentDeadlineSection = (source: string, sections: readonly Section[], words: Words, dates: readonly Span[]): number =>
237
+ sections.findIndex(
236
238
  (section) =>
237
239
  words.deadlineSection.includes(withoutHeadingEnd(comparableWords(section.unlabeledHeading ?? section.heading)).trim()) &&
238
240
  section.sentences.some((sentence) => statesDeadline(source, sentence, words, dates)),
239
- )?.span.start;
241
+ );
242
+
243
+ /**
244
+ * Whether the deadline section at index covers the offset: everything after it, and a section before it at its own level
245
+ * under the same heading (a proposal's 結論 asks, its 判断の期限 says by when). Text before the sections, or under another
246
+ * heading, is not covered.
247
+ */
248
+ const coveredByDeadline = (sections: readonly Section[], deadline: number, offset: number): boolean => {
249
+ const section = sections[deadline];
250
+ if (section === undefined) return false;
251
+ if (offset > section.span.start) return true;
252
+ const own = sections.findLastIndex((candidate) => candidate.span.start <= offset);
253
+ const between = sections.slice(own + 1, deadline);
254
+ return own >= 0 && sections[own]?.depth === section.depth && section.depth > 0 && between.every((other) => other.depth >= section.depth);
255
+ };
256
+
257
+ /** A document whose title names a kind that asks without a deadline by its nature (a 諮問 asks a council to deliberate). */
258
+ const asksWithoutDeadline = (sections: readonly Section[], words: Words): boolean => {
259
+ const title = sections.find((section) => section.depth > 0)?.heading;
260
+ return title !== undefined && containsAny(title, words.noDeadlineTitle);
261
+ };
240
262
 
241
263
  /**
242
264
  * The request sentences with neither a deadline nor a person in them, in the sentence after (same paragraph or item), in a
243
- * heading above, or in a deadline section before them.
265
+ * heading above, or in a deadline section that covers them; none in a document that asks without a deadline by its kind.
244
266
  */
245
267
  export const ownerlessRequests = (doc: ProseDocument): Sentence[] => {
246
268
  const words = wordsOf(doc);
247
269
  const dates = dateSpans(doc.structure);
248
- const deadlineAt = documentDeadlineAt(doc.source, doc.sections, words, dates) ?? Number.POSITIVE_INFINITY;
270
+ if (asksWithoutDeadline(doc.sections, words)) return [];
271
+ const deadline = documentDeadlineSection(doc.source, doc.sections, words, dates);
249
272
  return doc.sentences.filter((sentence, index) => {
250
- if (sentence.span.start > deadlineAt) return false;
273
+ if (coveredByDeadline(doc.sections, deadline, sentence.span.start)) return false;
251
274
  if (!isRequest(proseText(sentence), words) || saysWhenOrWho(sentence, words, dates, true)) return false;
252
275
  if (notesContactLine(doc.source, doc.sentences[index - 1], sentence, words)) return false;
253
276
  const next = doc.sentences[index + 1];
@@ -5,6 +5,8 @@ import { classWordsOf, isClassCue, namesClassAfter } from "./open-end-class.ts";
5
5
  import { glossesCondition } from "./open-end-condition.ts";
6
6
  import { openEndAt, openEndNames, type OpenEndNames } from "./open-end-names.ts";
7
7
  import { asksAfter, questionWordsOf } from "./open-end-question.ts";
8
+ import { anaphorWordsOf, isAnaphorCue, refersBack } from "./open-end-anaphor.ts";
9
+ import { itemsOpenOnPurpose } from "./open-end-lead.ts";
8
10
  import { isScopeCue, openOnPurpose, scopeWordsOf } from "./open-end-scope.ts";
9
11
  import { statesConcrete } from "./vague-deadline.ts";
10
12
 
@@ -70,12 +72,12 @@ const boundedInTime = (doc: ProseDocument, sentence: Sentence, entry: LexiconEnt
70
72
  * lexicon also holds the cues of a class named after the list and of what holds it, which are no smell.
71
73
  */
72
74
  const smellWords = (doc: ProseDocument, lexicon: string, genre: string | undefined): LexiconEntry[] =>
73
- entriesForGenre(doc.lexicons[lexicon] ?? [], genre).filter((entry) => !isClassCue(entry) && !isScopeCue(entry));
75
+ entriesForGenre(doc.lexicons[lexicon] ?? [], genre).filter((entry) => !isClassCue(entry) && !isScopeCue(entry) && !isAnaphorCue(entry));
74
76
 
75
77
  /**
76
78
  * Where the word stands as a smell. An open-end word inside a name the document gives (業務執行取締役等), giving examples
77
- * of a class named right after it (印刷等、二次的に利用), or ending a list a condition, a permission or a prohibition holds
78
- * (転載等をしてはならない), is none; without tokens none of these can be told apart.
79
+ * of a class named right after it (印刷等、二次的に利用), ending a list a condition, a permission or a prohibition holds
80
+ * (転載等をしてはならない), or ending a list a pointing word opens (当該改良、改善等), is none; without tokens none of these can be told apart.
79
81
  */
80
82
  const smellAt = (doc: ProseDocument, sentence: Sentence, entry: LexiconEntry, lexicon: string, names: () => OpenEndNames): number | undefined => {
81
83
  if (!entryIn(sentence, entry) || boundedInTime(doc, sentence, entry, lexicon)) return undefined;
@@ -83,7 +85,14 @@ const smellAt = (doc: ProseDocument, sentence: Sentence, entry: LexiconEntry, le
83
85
  if (lexicon !== OPEN_END || !tokenized) return offsetOf(sentence, entry);
84
86
  const classWords = classWordsOf(doc.lexicons[OPEN_END] ?? []);
85
87
  const scopeWords = scopeWordsOf(doc.lexicons[OPEN_END] ?? []);
86
- return openEndAt(doc, sentence, entry, names(), (tokens, range) => namesClassAfter(tokens, range, classWords) || openOnPurpose(tokens, range, scopeWords));
88
+ const anaphors = anaphorWordsOf(doc.lexicons[OPEN_END] ?? []);
89
+ return openEndAt(
90
+ doc,
91
+ sentence,
92
+ entry,
93
+ names(),
94
+ (tokens, range) => namesClassAfter(tokens, range, classWords) || openOnPurpose(tokens, range, scopeWords) || refersBack(tokens, range, anaphors),
95
+ );
87
96
  };
88
97
 
89
98
  /** An open list right before a question the reader answers (…措置など、どのような措置を求めるのか): its items are example answers. */
@@ -118,5 +127,12 @@ export const requirementSmell: Detector = (doc, options): Finding[] => {
118
127
  // Read once, and only when a requirement has an open-end word to tell apart from a name.
119
128
  const cache: { names?: OpenEndNames } = {};
120
129
  const names = (): OpenEndNames => (cache.names ??= openEndNames(doc, smellWords(doc, OPEN_END, options.genre), statements));
121
- return doc.sentences.filter((sentence) => isRequirement(sentence, markers, notMarkers)).flatMap((sentence) => smellsIn(doc, sentence, options.genre, names));
130
+ const onPurpose = scopeWordsOf(doc.lexicons[OPEN_END] ?? []).onPurpose;
131
+ const openItems = itemsOpenOnPurpose(doc.source, doc.sentences, doc.lists, onPurpose);
132
+ return doc.sentences.flatMap((sentence, index) => {
133
+ if (!isRequirement(sentence, markers, notMarkers)) return [];
134
+ const findings = smellsIn(doc, sentence, options.genre, names);
135
+ // An item under a lead that forbids or permits it: its list is open on purpose, like the lead's own.
136
+ return openItems.has(index) ? findings.filter((finding) => finding.variant !== "open-end") : findings;
137
+ });
122
138
  };
@@ -2,7 +2,7 @@ import type { Detector, DetectorOptions, Finding, Lexicon, ProseDocument, Senten
2
2
  import { escapeRegExp } from "../orthography.ts";
3
3
  import { isWithinAny, quotedIn } from "../quoted-span.ts";
4
4
  import { entryOpens } from "./lexicon-match.ts";
5
- import { laterAlternatives } from "../alternative-words.ts";
5
+ import { laterAlternatives, laterJoined } from "../alternative-words.ts";
6
6
  import { isContrastiveGa } from "./adversative-ga.ts";
7
7
 
8
8
  type TokenTest = (token: Token, at: number, tokens: readonly Token[]) => boolean;
@@ -45,25 +45,45 @@ const sentencesOver = (doc: ProseDocument, limit: number, test: TokenTest, fixed
45
45
  return counted.length > limit ? [findingOf(sentence, counted, limit)] : [];
46
46
  });
47
47
 
48
+ /** The counted words that only repeat the point of the one before: a later option of a choice, a later half of a joined pair. */
49
+ const laterOfOnePoint = (tokens: readonly Token[], counted: readonly number[]): ReadonlySet<number> =>
50
+ new Set([...laterAlternatives(tokens, counted), ...laterJoined(tokens, counted)]);
51
+
52
+ /** A mark that opens an item with a circled number (③): an item of a list written inside the sentence. */
53
+ const CIRCLED_ITEM = /^[①-⒇❶-❿]/u;
54
+
55
+ /** The counted tokens of the sentence's largest part, the sentence cut before each circled item mark (①Credit:…、②…). */
56
+ const largestItem = (sentence: Sentence, counted: readonly Token[]): readonly Token[] => {
57
+ const marks = (sentence.tokens ?? []).filter((token) => CIRCLED_ITEM.test(token.surface)).map((token) => token.span.start);
58
+ const itemOf = (token: Token): number => marks.filter((start) => start <= token.span.start).length;
59
+ const items = counted.reduce((byItem, token) => byItem.set(itemOf(token), [...(byItem.get(itemOf(token)) ?? []), token]), new Map<number, Token[]>());
60
+ return [...items.values()].reduce<readonly Token[]>((largest, item) => (item.length > largest.length ? item : largest), []);
61
+ };
62
+
48
63
  /**
49
64
  * A sentence holding more than limit tokens written as one of the lexicon's words (the suffix 的). The options of one choice
50
- * (連続的か断続的か、一時的) count once: they name one point, the kinds a thing may be.
65
+ * (連続的か断続的か、一時的) and a joined pair (信仰的主観的) count once: each names one point. A list written inside the sentence
66
+ * (①…、②…) is counted item by item, as each item is a point of its own.
51
67
  */
52
68
  export const sentenceWordCount: Detector = (doc, options): Finding[] => {
53
69
  const words = wordsOf(options.lexicon);
54
- const alternatives = new WeakMap<readonly Token[], ReadonlySet<number>>();
70
+ const onePoint = new WeakMap<readonly Token[], ReadonlySet<number>>();
55
71
  const laterOf = (tokens: readonly Token[]): ReadonlySet<number> => {
56
- const known = alternatives.get(tokens);
72
+ const known = onePoint.get(tokens);
57
73
  if (known !== undefined) return known;
58
- const found = laterAlternatives(
74
+ const found = laterOfOnePoint(
59
75
  tokens,
60
76
  tokens.flatMap((token, at) => (words.has(token.surface) ? [at] : [])),
61
77
  );
62
- alternatives.set(tokens, found);
78
+ onePoint.set(tokens, found);
63
79
  return found;
64
80
  };
65
81
  const isCounted: TokenTest = (token, at, tokens) => words.has(token.surface) && !laterOf(tokens).has(at);
66
- return sentencesOver(doc, options.limit, isCounted, doc.lexicons[FIXED_TERM_LEXICON] ?? []);
82
+ const fixedTerms = doc.lexicons[FIXED_TERM_LEXICON] ?? [];
83
+ return doc.sentences.flatMap((sentence) => {
84
+ const counted = largestItem(sentence, countedTokens(sentence, isCounted, fixedTerms));
85
+ return counted.length > options.limit ? [findingOf(sentence, counted, options.limit)] : [];
86
+ });
67
87
  };
68
88
 
69
89
  const NOMINAL: ReadonlySet<string> = new Set(["NOUN", "PROPN", "NUM"]);
@@ -3,6 +3,7 @@ import { enumeratedRuns, enumeratorStarts, numberedStarts } from "./enumerated-r
3
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
+ import { separatePartSentences } from "./register-separate-part.ts";
6
7
  import { askerSentences } from "./asker-voice.ts";
7
8
  import { licenceNoticeSentences } from "./licence-notice.ts";
8
9
  import { chronologyRows } from "../chronology-rows.ts";
@@ -24,6 +25,7 @@ import type { Detector, Finding, LexiconEntry, ProseDocument, Sentence, Span, To
24
25
  * 文書の最後に掲載先が付けた利用条件の断り書き(…ライセンスの下に提供されています。)も数えない(licence-notice.ts)。
25
26
  * 札を付けて引いた言葉(例:…。Q: …?)、印を付けた札の行の下の記入欄の値(■ 調査目的\n…とする。)、
26
27
  * 〒や電話の行のある問い合わせ先の段落も数えない(register-set-apart.ts)。
28
+ * 一番上の見出しで分けた部分のうち、2 文以上がみな文書の多いほうと違う同じ調子のものは、別の文書として数えない(register-separate-part.ts)。
27
29
  */
28
30
  /**
29
31
  * quiet: 常体と読めるが、願い・問い・言いさしの形(register-neutral-shape.ts)の文。どちらの調子の文書にも現れるので指さない。
@@ -120,8 +122,10 @@ export const judgedSentences = (doc: ProseDocument, polite: readonly LexiconEntr
120
122
  });
121
123
  const registers = new Map(all.map((entry) => [entry.sentence, entry.register]));
122
124
  const majority = majorityOf(all.map((entry) => ({ register: entry.register, group: undefined })));
123
- const notices = noticeSentences(doc.paragraphs, doc.lexicons["notice-phrase"] ?? [], (sentence) => registers.get(sentence), majority);
124
- const found = all.filter((entry) => !notices.has(entry.sentence));
125
+ const registerAt = (sentence: Sentence): Register | undefined => registers.get(sentence);
126
+ const notices = noticeSentences(doc.paragraphs, doc.lexicons["notice-phrase"] ?? [], registerAt, majority);
127
+ const parts = separatePartSentences(doc.sections, registerAt, majority);
128
+ const found = all.filter((entry) => !notices.has(entry.sentence) && !parts.has(entry.sentence));
125
129
  const runs = runsOf(
126
130
  doc,
127
131
  found.map((entry) => entry.register),