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
@@ -0,0 +1,36 @@
1
+ import type { ProseDocument, Section, Sentence, Token } from "../plugin.ts";
2
+
3
+ const shifted = (tokens: readonly Token[], by: number): Token[] =>
4
+ tokens.map((token) => ({ ...token, span: { start: token.span.start + by, end: token.span.end + by } }));
5
+
6
+ /** Where the heading's text starts in the source: from the heading's line, which ends where its section starts. */
7
+ const textStartOf = (source: string, section: Section, headingStarts: ReadonlyMap<number, number>): number | undefined => {
8
+ const from = headingStarts.get(section.span.start);
9
+ if (from === undefined) return undefined;
10
+ const at = source.indexOf(section.heading, from);
11
+ return at < 0 || at >= section.span.start ? undefined : at;
12
+ };
13
+
14
+ const headingSentence = (source: string, section: Section, headingStarts: ReadonlyMap<number, number>): Sentence[] => {
15
+ if (section.depth === 0 || section.heading === "") return [];
16
+ const start = textStartOf(source, section, headingStarts);
17
+ if (start === undefined) return [];
18
+ const span = { start, end: start + section.heading.length };
19
+ return [
20
+ section.headingTokens === undefined ? { span, text: section.heading } : { span, text: section.heading, tokens: shifted(section.headingTokens, start) },
21
+ ];
22
+ };
23
+
24
+ /**
25
+ * Each heading read as one sentence, placed where its text stands in the source, with its words. For a rule that reads
26
+ * the words a writer chose in titles as well as in body sentences. A heading whose text cannot be found in its line
27
+ * (inline markup in it) is left out rather than placed wrong.
28
+ */
29
+ export const headingSentences = (doc: ProseDocument): Sentence[] => {
30
+ const headingStarts = new Map((doc.markup?.headings ?? []).map((heading) => [heading.end, heading.start]));
31
+ return doc.sections.flatMap((section) => headingSentence(doc.source, section, headingStarts));
32
+ };
33
+
34
+ /** Body sentences and headings together, in the order they stand in the source. */
35
+ export const sentencesWithHeadings = (doc: ProseDocument): Sentence[] =>
36
+ [...doc.sentences, ...headingSentences(doc)].toSorted((left, right) => left.span.start - right.span.start);
@@ -45,16 +45,23 @@ const tokenHits = (sentence: Sentence, pair: Pair, source: string): Hit[] => {
45
45
  };
46
46
 
47
47
  /** 字の並びで当たった所のうち、両端が文の語の切れ目にあるもの。語彙表の語を解析器が文の中と違う切り方にした(「ますす」)ときの拾い直し。 */
48
- const alignedTextHits = (sentence: Sentence, pair: Pair): Hit[] => {
48
+ const alignedTextHits = (sentence: Sentence, pair: Pair, edges: WordEdges): Hit[] =>
49
+ textHits(sentence, pair).filter((hit) => edges.starts.has(hit.offset) && edges.ends.has(hit.offset + pair.wrong.length));
50
+
51
+ /** 文の語の始まりと終わり。組ごとに作り直すと、組の数と文の長さの積になる。 */
52
+ type WordEdges = { readonly starts: ReadonlySet<number>; readonly ends: ReadonlySet<number> };
53
+
54
+ const edgesOf = (sentence: Sentence): WordEdges => {
49
55
  const tokens = sentence.tokens ?? [];
50
- const starts = new Set(tokens.map((token) => token.span.start));
51
- const ends = new Set(tokens.map((token) => token.span.end));
52
- return textHits(sentence, pair).filter((hit) => starts.has(hit.offset) && ends.has(hit.offset + pair.wrong.length));
56
+ return { starts: new Set(tokens.map((token) => token.span.start)), ends: new Set(tokens.map((token) => token.span.end)) };
53
57
  };
54
58
 
55
- const hitsIn = (sentence: Sentence, pair: Pair, source: string): Hit[] => {
56
- if (sentence.tokens === undefined || (pair.entry.tokens?.length ?? 0) === 0) return textHits(sentence, pair);
57
- return [...tokenHits(sentence, pair, source), ...alignedTextHits(sentence, pair)];
59
+ const hitsIn = (sentence: Sentence, pairs: readonly Pair[], source: string): Hit[] => {
60
+ const edges = edgesOf(sentence);
61
+ return pairs.flatMap((pair) => {
62
+ if (sentence.tokens === undefined || (pair.entry.tokens?.length ?? 0) === 0) return textHits(sentence, pair);
63
+ return [...tokenHits(sentence, pair, source), ...alignedTextHits(sentence, pair, edges)];
64
+ });
58
65
  };
59
66
 
60
67
  /** チームが names に並べた名前の中の字(「黒ひげ危機一発」の「危機一発」)は、その字のまま正しい。 */
@@ -75,7 +82,7 @@ const firstAtEachOffset = (hits: readonly Hit[]): Hit[] => hits.filter((hit, at)
75
82
  */
76
83
  export const knownCorrection: Detector = (doc, options): Finding[] => {
77
84
  const pairs = pairsOf(options.lexicon ?? []);
78
- const hits = doc.sentences.flatMap((sentence) => pairs.flatMap((pair) => hitsIn(sentence, pair, doc.source)));
85
+ const hits = doc.sentences.flatMap((sentence) => hitsIn(sentence, pairs, doc.source));
79
86
  return firstAtEachOffset(hits.toSorted((left, right) => left.offset - right.offset))
80
87
  .filter((hit) => !isInTeamName(doc, hit))
81
88
  .map((hit) => ({
@@ -1,10 +1,9 @@
1
1
  import { joinWords } from "./word-list.ts";
2
- import { pairMinority } from "./contraction-minority.ts";
3
- import { withoutMentions } from "./contraction-mention.ts";
4
- import { straightApostrophes } from "../orthography.ts";
2
+ import { densestStretch } from "./densest-stretch.ts";
5
3
  import { wordsOf } from "./structure.ts";
6
4
  import type { Detector, Finding, Lexicon, LexiconEntry, ProseDocument, Sentence, Span, Token } from "../plugin.ts";
7
5
  import { entryIn, entryOpens, entryRanges, type TokenRange } from "./lexicon-match.ts";
6
+ import { headingSentences, sentencesWithHeadings } from "./heading-sentences.ts";
8
7
  import { scoped, scopeMarkersOf, type ScopeMarkers } from "./superlative-scope.ts";
9
8
  import { makesWord, namesQuantity } from "./superlative-name.ts";
10
9
  import { namesAmount } from "./superlative-amount.ts";
@@ -257,14 +256,26 @@ const writtenIn = (sentence: Sentence, entry: LexiconEntry): boolean =>
257
256
  : entryRanges(sentence, entry).some((range) => !quotedRange(sentence, range));
258
257
 
259
258
  /**
260
- * AI 生成の signal。1 つでは何も言えないので、重みを足し合わせて文書の点にする。
261
- * 単独で断じない。§20.2 の複合シグナルの入口で、これだけで「AI が書いた」とは言わない。
259
+ * How many sentences one pile-up may span. Generated articles fit inside it whole; a long text (a listing of many authors'
260
+ * abstracts, a novel) gathers one phrase here and one there, and only a stretch of it is scored.
261
+ */
262
+ const AI_TELL_STRETCH = 100;
263
+
264
+ /**
265
+ * AI 生成の signal。1 つでは何も言えないので、重みを足し合わせて点にする。見出しも読む(「〜をわかりやすく解説」のような題)。
266
+ * 点は AI_TELL_STRETCH 文の中で最も重なった所のもの。単独で断じない。§20.2 の複合シグナルの入口で、これだけで「AI が書いた」とは言わない。
262
267
  */
263
268
  export const aiTell: Detector = (doc, options): Finding[] => {
264
269
  const entries = [...new Map((options.lexicon ?? []).map((entry) => [entry.pattern.toLowerCase(), entry])).values()];
265
- const found = entries.filter((entry) => doc.sentences.some((sentence) => writtenIn(sentence, entry)));
270
+ const sentences = sentencesWithHeadings(doc);
271
+ const headings = new Set(headingSentences(doc).map((heading) => heading.span.start));
272
+ const counts = (sentence: Sentence, entry: LexiconEntry): boolean =>
273
+ (entry.heading_only !== true || headings.has(sentence.span.start)) && writtenIn(sentence, entry);
274
+ const hitsPerSentence = sentences.map((sentence) => entries.filter((entry) => counts(sentence, entry)));
275
+ const stretch = densestStretch(hitsPerSentence, AI_TELL_STRETCH, (entry) => entry.weight ?? 1);
276
+ const found = entries.filter((entry) => stretch?.keys.has(entry) === true);
266
277
  const score = Math.round(found.reduce((sum, entry) => sum + (entry.weight ?? 1), 0) * 10);
267
- const first = doc.sentences.find((sentence) => found.some((entry) => writtenIn(sentence, entry)));
278
+ const first = stretch === undefined ? undefined : sentences[stretch.first];
268
279
  if (first === undefined || score <= options.limit) return [];
269
280
  return [
270
281
  {
@@ -286,58 +297,3 @@ export const aiTell: Detector = (doc, options): Finding[] => {
286
297
  },
287
298
  ];
288
299
  };
289
-
290
- /**
291
- * 同じことを言う 2 つの書きかたが、1 つの文書で混ざっているか。
292
- *
293
- * **どちらが正しいかは決めない。** 短縮形を使うかどうかは文体の選択で、
294
- * 立場を取ると方針の違う書き手に rule ごと無視される。spec §12.3。
295
- *
296
- * 語彙表は対を持つ(`pattern` と `instead_of`)。比べるのは対の中だけで、別の語どうしは比べない。
297
- * GOV.UK の文体は「you're」を使い否定は「do not」と書く。語ごとに決めた書きかたで、混在ではない。
298
- * 否定と代名詞+動詞の族にもまとめない。「don't」と「does not」を書き分ける文書もある。
299
- */
300
- /**
301
- * 語の境界で照合する。部分一致だと「it isn't」が「it is」を含んでしまい、
302
- * 短縮形を使っている文が「使っていない」側に数えられる。
303
- */
304
- const wordUses = (text: string, word: string): number => [...text.matchAll(new RegExp(`\\b${word.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}\\b`, "gu"))].length;
305
-
306
- const containsWord = (text: string, word: string): boolean => wordUses(text, word) > 0;
307
-
308
- /**
309
- * アポストロフィの形(don’t と don't)は短縮形かどうかを変えない。違うのは印刷の形で、文体ではない。
310
- * 折り返した行(「do」で改行して「not」)も、空白 1 つと同じに読む。
311
- */
312
- const comparableText = (sentence: Sentence): string => withoutMentions(straightApostrophes(sentence.text)).replace(/\s+/gu, " ").toLowerCase();
313
-
314
- type MixedPair = { readonly minority: string; readonly majority: string; readonly count: number };
315
-
316
- const mixedPair = (body: string, short: string, long: string): MixedPair | undefined => {
317
- const uses = { short: wordUses(body, short), long: wordUses(body, long) };
318
- const side = pairMinority(uses);
319
- if (side === undefined) return undefined;
320
- return side === "short" ? { minority: short, majority: long, count: uses.short } : { minority: long, majority: short, count: uses.long };
321
- };
322
-
323
- export const contractionMix: Detector = (doc, options): Finding[] => {
324
- // 文は改行でつなぐ。空白でつなぐと、箇条書きの「What we do」と次の項目「not every…」が「do not」と数えられる。
325
- const body = doc.sentences.map(comparableText).join("\n");
326
- const mixed = (options.lexicon ?? []).flatMap((entry) => {
327
- const pair = entry.instead_of === undefined ? undefined : mixedPair(body, entry.pattern.toLowerCase(), entry.instead_of.toLowerCase());
328
- return pair === undefined || pair.count > options.limit ? [] : [pair];
329
- });
330
- const hits = doc.sentences.flatMap((sentence) => {
331
- const text = comparableText(sentence);
332
- const pair = mixed.find((candidate) => containsWord(text, candidate.minority));
333
- return pair === undefined ? [] : [{ sentence, pair }];
334
- });
335
- return hits.map(({ sentence, pair }) => ({
336
- rule: "contraction-consistency",
337
- severity: "info",
338
- line: 0,
339
- column: 0,
340
- quote: sentence.text.trim(),
341
- values: { matched: pair.minority, majority: pair.majority, count: pair.count, limit: options.limit, offset: sentence.span.start },
342
- }));
343
- };
@@ -1,6 +1,7 @@
1
1
  import type { BulletList, Detector, DetectorOptions, Finding, ProseDocument, Sentence, Span } from "../plugin.ts";
2
2
  import { densityFindings } from "./ai-phrasing.ts";
3
3
  import { endsWithColon } from "./lead-in.ts";
4
+ import { isMarkdownPath } from "../structure/markdown-path.ts";
4
5
 
5
6
  /** Between a lead-in and its list: only blank space. A thematic break (`***`) separates them; bold marks sit inside the sentence. */
6
7
  const ONLY_BLANKS = /^\s*$/u;
@@ -37,20 +38,48 @@ const labelWords = (text: string): string => {
37
38
  /** A noun with no kana inflection (参考, 注意点): a name, not a sentence (以下の通りです) and not a lone symbol (⚠️). */
38
39
  const NOUN_LABEL = /^(?=.*\p{L})[^\p{Script=Hiragana}]+$/u;
39
40
 
40
- /** An English label is a name of a word or three (See also, Pros); past that it is a sentence (Here's what you need). */
41
+ /** A label of a word or three is a name (See also, Pros) whatever its parts of speech. */
41
42
  const MAX_LABEL_WORDS = 3;
42
43
 
43
- const isNounLabel = (words: string): boolean => NOUN_LABEL.test(words) && words.split(/\s+/u).length <= MAX_LABEL_WORDS;
44
+ /** A verb or a pronoun makes a clause: Here's what you need is a sentence, Community changes, past quarter a name. */
45
+ const CLAUSE_POS: ReadonlySet<string> = new Set(["VERB", "AUX", "PRON", "SCONJ"]);
46
+ const NAME_POS: ReadonlySet<string> = new Set(["NOUN", "PROPN"]);
47
+
48
+ /** A verb right after a preposition is a gerund inside the phrase (Guidelines for addressing …), not the verb of a clause. */
49
+ const makesClause = (pos: string, before: string | undefined): boolean => CLAUSE_POS.has(pos) && !(pos === "VERB" && before === "ADP");
50
+
51
+ /** A noun phrase of any length, read from the adapter's parts of speech. Without them, only the short label counts. */
52
+ const isNounPhrase = (sentence: Sentence): boolean => {
53
+ const tokens = sentence.tokens ?? [];
54
+ return tokens.some((token) => NAME_POS.has(token.pos)) && !tokens.some((token, index) => makesClause(token.pos, tokens[index - 1]?.pos));
55
+ };
56
+
57
+ const isNounLabel = (words: string, sentence: Sentence): boolean =>
58
+ NOUN_LABEL.test(words) && (words.split(/\s+/u).length <= MAX_LABEL_WORDS || isNounPhrase(sentence));
59
+
60
+ /** A template keeps at least this many words fixed around its entry's name; fewer, and two different labels only look alike. */
61
+ const MIN_FIXED_WORDS = 3;
62
+
63
+ /** One label of a template that carries its entry's name: the same words but one (Guidelines for addressing High-sev / Low-sev issues). */
64
+ const sameButOneWord = (left: string, right: string): boolean => {
65
+ const leftWords = left.split(/\s+/u);
66
+ const rightWords = right.split(/\s+/u);
67
+ const differing = leftWords.filter((word, index) => word !== rightWords[index]).length;
68
+ return leftWords.length === rightWords.length && differing === 1 && leftWords.length - differing >= MIN_FIXED_WORDS;
69
+ };
70
+
71
+ const sameTemplate = (left: string, right: string): boolean => left === right || sameButOneWord(left, right);
44
72
 
45
73
  /**
46
- * A field of an entry's template: the same noun label before the list of each entry (**参考:** before each entry's link).
74
+ * A field of an entry's template: the same noun label before the list of each entry (**参考:** before each entry's link),
75
+ * or the same label with the entry's name in it (Guidelines for addressing High-sev issues: in each severity's section).
47
76
  * It names the field the way a table's column does; it does not lead into anything.
48
77
  */
49
78
  const fieldLabels = (leadIns: readonly Sentence[]): ReadonlySet<string> => {
50
- const counts = leadIns
51
- .map((sentence) => labelWords(sentence.text))
52
- .reduce((tally, words) => tally.set(words, (tally.get(words) ?? 0) + 1), new Map<string, number>());
53
- return new Set([...counts].filter(([words, count]) => count > 1 && isNounLabel(words)).map(([words]) => words));
79
+ const labels = leadIns.map((sentence) => ({ words: labelWords(sentence.text), sentence }));
80
+ const isField = ({ words, sentence }: (typeof labels)[number], index: number): boolean =>
81
+ labels.some((other, otherIndex) => otherIndex !== index && sameTemplate(words, other.words)) && isNounLabel(words, sentence);
82
+ return new Set(labels.filter(isField).map(({ words }) => words));
54
83
  };
55
84
 
56
85
  /** A line that is only a bold label (**Pros:**, **参考**:), and the label inside the bold marks. */
@@ -64,20 +93,40 @@ const lineAround = (source: string, sentence: Sentence): string => {
64
93
  /** A bold noun label on a line of its own names the list under it, as a heading does (**Pros:** then **Cons:**). */
65
94
  const isBoldNounLabel = (sentence: Sentence, source: string): boolean => {
66
95
  const label = BOLD_LINE.exec(lineAround(source, sentence).trim())?.groups?.["label"];
67
- return label !== undefined && isNounLabel(labelWords(label));
96
+ return label !== undefined && isNounLabel(labelWords(label), sentence);
68
97
  };
69
98
 
99
+ /** Plain text cannot write bold, so there a noun label alone on its line is the heading of its list (Releases:, New Features:). */
100
+ const isPlainNounLabel = (sentence: Sentence, source: string): boolean =>
101
+ lineAround(source, sentence).trim() === sentence.text.trim() && isNounLabel(labelWords(sentence.text), sentence);
102
+
103
+ /** An item's list marker and any emphasis before its first word (- **, 1. ). */
104
+ const ITEM_HEAD = /^\s*(?:[-*+]|\d+[.)])\s+(?:\*\*|__|\*|_)?/u;
105
+
106
+ const opensWithCode = (source: string, item: Span): boolean => source.slice(item.start, item.end).replace(ITEM_HEAD, "").startsWith("`");
107
+
108
+ /** A list whose every item opens with a code span names values, options or members (`omit`: never send …): a parts list, which can stay. */
109
+ const isValueList = (list: BulletList, source: string): boolean => list.itemSpans.length > 1 && list.itemSpans.every((item) => opensWithCode(source, item));
110
+
70
111
  /**
71
112
  * Prose sentences ending in a colon that hand the reader straight to a list (「以下の通りです:」, "Here's what you need:").
72
113
  * An item of a list is not prose: 「例: `code`」 ends in a colon once its code is masked, and it leads nowhere.
73
114
  */
74
- export const colonLeadIns = (sentences: readonly Sentence[], lists: readonly BulletList[], listSpans: readonly Span[], source: string): Sentence[] => {
115
+ export const colonLeadIns = (
116
+ sentences: readonly Sentence[],
117
+ lists: readonly BulletList[],
118
+ listSpans: readonly Span[],
119
+ source: string,
120
+ markdown = true,
121
+ ): Sentence[] => {
75
122
  const leadIns = lists.flatMap((list) => {
123
+ if (isValueList(list, source)) return [];
76
124
  const before = sentenceRightBefore(sentences, list, source);
77
125
  return before !== undefined && endsWithColon(before.text) && !insideAny(listSpans, before.span.start) ? [before] : [];
78
126
  });
79
127
  const fields = fieldLabels(leadIns);
80
- return leadIns.filter((sentence) => !fields.has(labelWords(sentence.text)) && !isBoldNounLabel(sentence, source));
128
+ const namesItsList = (sentence: Sentence): boolean => (markdown ? isBoldNounLabel(sentence, source) : isPlainNounLabel(sentence, source));
129
+ return leadIns.filter((sentence) => !fields.has(labelWords(sentence.text)) && !namesItsList(sentence));
81
130
  };
82
131
 
83
132
  /** Lead-ins in one or two sections are a how-to's procedure or a pair of lists; the rule's why is section after section. */
@@ -101,7 +150,7 @@ const sectionsHolding = (doc: ProseDocument, leadIns: readonly Sentence[]): numb
101
150
  */
102
151
  export const colonLeadIn: Detector = (doc, options): Finding[] => {
103
152
  const inDocumentLanguage = doc.sentences.filter((sentence) => sentence.embeddedLanguage === undefined);
104
- const leadIns = colonLeadIns(inDocumentLanguage, doc.lists, doc.listSpans, doc.source);
153
+ const leadIns = colonLeadIns(inDocumentLanguage, doc.lists, doc.listSpans, doc.source, isMarkdownPath(doc.path));
105
154
  if (sectionsHolding(doc, leadIns) < minSections(options)) return [];
106
155
  const hits = leadIns.map((sentence) => ({ sentence, matched: sentence.text.trim() }));
107
156
  return densityFindings(doc, hits, options.limit);
@@ -1,6 +1,6 @@
1
1
  // Whether a list goes on past an and / or. Then that and / or is inside an item, not the list's last joint, and it casts no
2
2
  // vote on the serial comma. Pure.
3
- import { hasAdposition, hasVerb, isClause, itemAfter, leadShape } from "./list-item.ts";
3
+ import { hasAdposition, hasVerb, isClause, itemAfter, leadShape, openingOf } from "./list-item.ts";
4
4
  import { isListConjunction, type ItemScope } from "./list-sentence.ts";
5
5
  import type { TokenRange } from "./token-column.ts";
6
6
 
@@ -30,13 +30,27 @@ const wordsOf = (scope: ItemScope, item: TokenRange): string =>
30
30
  /** 並びの残りを言う語だけの項目(and so forth / or the like)。 */
31
31
  const endsOpenList = (scope: ItemScope, item: TokenRange): boolean => scope.sentence.words.openListEnd?.has(wordsOf(scope, item)) ?? false;
32
32
 
33
+ /**
34
+ * and / or の項目が、並びの前で使った前置詞をもう一度置いてから、shape の項目を続けるか(filled at the West Station, Indian Cove,
35
+ * Black Rock and Cottonwood campgrounds, and at Park Headquarters)。前置詞を言い直しただけで、同じ並びの最後の項目。
36
+ * 動詞を連れれば節の頭(and at night we slept)。
37
+ */
38
+ const repeatsPreposition = (scope: ItemScope, item: TokenRange, shape: string): boolean => {
39
+ const opening = openingOf(scope, item);
40
+ if (opening?.pos !== "ADP" || hasVerb(scope, item)) return false;
41
+ const at = scope.sentence.tokens.indexOf(opening);
42
+ const surface = opening.surface.toLowerCase();
43
+ const usedBefore = scope.sentence.tokens.slice(0, at).some((token) => token.pos === "ADP" && token.surface.toLowerCase() === surface);
44
+ return usedBefore && leadShape(scope, { start: at + 1, end: item.end }) === shape;
45
+ };
46
+
33
47
  /**
34
48
  * 読点のあとに、頭の形が shape の and / or の項目か、並びの残りを言う語(and so forth)が来るか。and / or が来なければ undefined。
35
49
  */
36
50
  const conjunctionAfter = (scope: ItemScope, end: number, shape: string): boolean | undefined => {
37
51
  if (!isListConjunction(scope.sentence.tokens[end + 1])) return undefined;
38
52
  const following = itemAfter(scope, end + 1);
39
- return leadShape(scope, following) === shape || endsOpenList(scope, following);
53
+ return leadShape(scope, following) === shape || endsOpenList(scope, following) || repeatsPreposition(scope, following, shape);
40
54
  };
41
55
 
42
56
  const QUOTE_MARKS: ReadonlySet<string> = new Set(['"', "“", "”", "'", "‘", "’"]);
@@ -1,5 +1,6 @@
1
1
  import type { Detector, Finding, LexiconEntry, Paragraph, ProseDocument, Token } from "../plugin.ts";
2
2
  import { formMinority } from "./form-minority.ts";
3
+ import { captionParagraphs, slotParagraphs } from "./final-period-captions.ts";
3
4
 
4
5
  // A paragraph whose last sentence stops without its closing mark, in a document whose other paragraphs end with one. It
5
6
  // takes no side: a document that ends none of its paragraphs with the mark (slides, labels) is not reported. The marks
@@ -102,7 +103,14 @@ const marksOf = (lexicon: readonly LexiconEntry[]): PeriodMarks => ({
102
103
  export const missingFinalPeriod: Detector = (doc: ProseDocument, options): Finding[] => {
103
104
  const text = doc.prose ?? doc.source;
104
105
  const marks = marksOf(doc.lexicons["final-period"] ?? []);
105
- const ends = doc.paragraphs.flatMap((paragraph, index) => paragraphEnd(text, paragraph, marks, doc.paragraphs[index + 1], doc.paragraphs[index - 1]) ?? []);
106
+ const captions = captionParagraphs(
107
+ text,
108
+ doc.sections,
109
+ slotParagraphs(text, doc.paragraphs, (line) => isClosed(line, marks.ends)),
110
+ );
111
+ const ends = doc.paragraphs.flatMap((paragraph, index) =>
112
+ captions.has(index) ? [] : (paragraphEnd(text, paragraph, marks, doc.paragraphs[index + 1], doc.paragraphs[index - 1]) ?? []),
113
+ );
106
114
  const minority = formMinority(ends, options.limit);
107
115
  if (minority === undefined || minority.usual.form !== "closed") return [];
108
116
  return minority.odd.map((end) => ({
@@ -1,10 +1,17 @@
1
1
  import type { ProseDocument, Span, StructureNode } from "../plugin.ts";
2
2
  import { alternativeReader, placeholderStarts } from "../structure/alternative-clause.ts";
3
3
  import { htmlTextBlocks } from "../structure/html-text-blocks.ts";
4
- import type { ClauseReadings } from "../structure/numbering.ts";
4
+ import type { ClauseReadings, SkipReadings } from "../structure/numbering.ts";
5
+ import { markerTest } from "./ordinal-run-gaps.ts";
5
6
  import { sideStepReader } from "../structure/side-step.ts";
6
7
  import { patternsOf } from "./net-amount-mismatch.ts";
7
8
 
9
+ /** A heading that says what is under it is only some (partial-listing-marker: 抜粋, excerpt). */
10
+ const partialHeadingTest = (markers: readonly string[]): ((heading: string) => boolean) => {
11
+ const tests = markers.filter((marker) => marker !== "").map(markerTest);
12
+ return (heading) => tests.some((names) => names(heading));
13
+ };
14
+
8
15
  /**
9
16
  * What numberingBreaks reads besides the tree, from the document and its word lists: the text the tree leaves out (an
10
17
  * HTML block's, in Markdown), the steps labelled with a word, the alternative and blank-numbered clauses.
@@ -12,11 +19,12 @@ import { patternsOf } from "./net-amount-mismatch.ts";
12
19
  export const numberingReadings = (
13
20
  doc: ProseDocument,
14
21
  source: string,
15
- ): [unread: Span[], isSideStep: (node: StructureNode) => boolean, clauses: ClauseReadings] => [
22
+ ): [unread: Span[], isSideStep: (node: StructureNode) => boolean, clauses: ClauseReadings, skips: SkipReadings] => [
16
23
  doc.markup?.markdown === true ? htmlTextBlocks(source) : [],
17
24
  sideStepReader(patternsOf(doc, "side-step-label")),
18
25
  {
19
26
  isAlternative: alternativeReader(source, patternsOf(doc, "alternative-clause-label")),
20
27
  restarts: placeholderStarts(source, patternsOf(doc, "placeholder-division")),
21
28
  },
29
+ { source, isPartialHeading: partialHeadingTest(patternsOf(doc, "partial-listing-marker")) },
22
30
  ];
@@ -0,0 +1,31 @@
1
+ import type { LexiconEntry, Token } from "../plugin.ts";
2
+ import { entryEndsAt, type TokenRange } from "./lexicon-match.ts";
3
+
4
+ // An open list that a word pointing back opens (当該改良、改善等 "the said improvements, etc."): it names a list the text
5
+ // gave before, so whatever it leaves open was left open there, and is reported there if anywhere. The pointing words come
6
+ // from the language's requirement-open-end lexicon, in the group below. Pure.
7
+
8
+ const ANAPHOR = "list-anaphor";
9
+ const NAME_POS: ReadonlySet<string> = new Set(["NOUN", "PROPN"]);
10
+ /** The marks that join the items of a list (改良、改善等, 信用・ブランド等). */
11
+ const ITEM_JOINS: ReadonlySet<string> = new Set(["、", ",", "・"]);
12
+
13
+ export const anaphorWordsOf = (entries: readonly LexiconEntry[]): readonly LexiconEntry[] => entries.filter((entry) => entry.group === ANAPHOR);
14
+
15
+ /** Whether an entry is a pointing word rather than an open-end word. */
16
+ export const isAnaphorCue = (entry: LexiconEntry): boolean => entry.group === ANAPHOR;
17
+
18
+ const inList = (token: Token | undefined): boolean => token !== undefined && (NAME_POS.has(token.pos) || ITEM_JOINS.has(token.surface));
19
+
20
+ /** Where the list that ends right before index starts: the nouns and the marks between them, walking back. */
21
+ const listStart = (tokens: readonly Token[], index: number): number => (index > 0 && inList(tokens[index - 1]) ? listStart(tokens, index - 1) : index);
22
+
23
+ /** The first word of the list, past any joining mark the walk took in at its head. */
24
+ const firstWord = (tokens: readonly Token[], index: number, end: number): number =>
25
+ index < end && ITEM_JOINS.has(tokens[index]?.surface ?? "") ? firstWord(tokens, index + 1, end) : index;
26
+
27
+ /** Whether the list the open word at range closes opens with a word that points back to one given before (当該). */
28
+ export const refersBack = (tokens: readonly Token[], range: TokenRange, words: readonly LexiconEntry[]): boolean => {
29
+ const first = firstWord(tokens, listStart(tokens, range.start), range.start);
30
+ return words.some((entry) => entryEndsAt(tokens, entry, first + (entry.tokens?.length ?? 0)));
31
+ };
@@ -0,0 +1,46 @@
1
+ import type { BulletList, LexiconEntry, Sentence, Span } from "../plugin.ts";
2
+ import { entryCloses } from "./lexicon-match.ts";
3
+
4
+ // The items of a list under a sentence that forbids or permits them (次の行為をしてはならない。 1. 知的財産権等を侵害すること):
5
+ // each item names a forbidden or permitted act, and a list in it is left open on purpose, as it would be in the sentence
6
+ // itself. Pure: the sentences, the lists and the language's prohibition and permission words come in.
7
+
8
+ /** Between a lead and its list: only blank space. */
9
+ const ONLY_SPACE = /^\s*$/u;
10
+
11
+ /** The run of items, written with line marks (①, ・) rather than as a list, that the item at index starts. */
12
+ const itemRun = (sentences: readonly Sentence[], index: number): Span | undefined => {
13
+ const first = sentences[index];
14
+ if (first?.listItem !== true || sentences[index - 1]?.listItem === true) return undefined;
15
+ const after = sentences.slice(index).findIndex((sentence) => sentence.listItem !== true);
16
+ const last = sentences[after === -1 ? sentences.length - 1 : index + after - 1] ?? first;
17
+ return { start: first.span.start, end: last.span.end };
18
+ };
19
+
20
+ /** Where each list stands: the lists, and the runs of items written with line marks. */
21
+ const listsIn = (sentences: readonly Sentence[], lists: readonly BulletList[]): Span[] => [
22
+ ...lists.map((list) => list.span),
23
+ ...sentences.flatMap((_sentence, index) => itemRun(sentences, index) ?? []),
24
+ ];
25
+
26
+ /** The last sentence that ends before the list, when only blank space stands between them. */
27
+ const leadOf = (source: string, sentences: readonly Sentence[], list: Span): Sentence | undefined => {
28
+ const lead = sentences.findLast((sentence) => sentence.span.end <= list.start);
29
+ return lead !== undefined && ONLY_SPACE.test(source.slice(lead.span.end, list.start)) ? lead : undefined;
30
+ };
31
+
32
+ /** The sentences, by index, in a list led by a sentence ending in a prohibition or a permission (…してはならない。). */
33
+ export const itemsOpenOnPurpose = (
34
+ source: string,
35
+ sentences: readonly Sentence[],
36
+ lists: readonly BulletList[],
37
+ onPurpose: readonly LexiconEntry[],
38
+ ): ReadonlySet<number> => {
39
+ const led = listsIn(sentences, lists).filter((list) => {
40
+ const lead = leadOf(source, sentences, list);
41
+ return lead !== undefined && onPurpose.some((entry) => entryCloses(lead, entry));
42
+ });
43
+ return new Set(
44
+ sentences.flatMap((sentence, index) => (led.some((list) => list.start <= sentence.span.start && sentence.span.start < list.end) ? [index] : [])),
45
+ );
46
+ };
@@ -41,8 +41,15 @@ export const scopeWordsOf = (entries: readonly LexiconEntry[]): ScopeWords => ({
41
41
  /** Whether an entry is one of the scope cues rather than an open-end word. */
42
42
  export const isScopeCue = (entry: LexiconEntry): boolean => SCOPE_GROUPS.has(entry.group ?? "");
43
43
 
44
+ /** Only marks from here to the end of the sentence. */
45
+ const closesSentence = (tokens: readonly Token[], index: number): boolean => tokens.slice(index).every((token) => token.pos === PUNCT);
46
+
47
+ /** A cue with position after counts only where it closes the sentence (使用しないこと。, not 不備がないことを確認する). */
44
48
  const startsAt = (tokens: readonly Token[], entries: readonly LexiconEntry[], index: number): boolean =>
45
- entries.some((entry) => entryEndsAt(tokens, entry, index + (entry.tokens?.length ?? 0)));
49
+ entries.some((entry) => {
50
+ const end = index + (entry.tokens?.length ?? 0);
51
+ return entryEndsAt(tokens, entry, end) && (entry.position !== "after" || closesSentence(tokens, end));
52
+ });
46
53
 
47
54
  /** A comma right after a predicate closes the clause the list stands in (消去し、). */
48
55
  const closesClause = (tokens: readonly Token[], index: number): boolean => tokens[index]?.pos === PUNCT && PREDICATE_POS.has(tokens[index - 1]?.pos ?? "");
@@ -68,7 +68,7 @@ const lineBlocks = (doc: ProseDocument, text: string, frames: readonly OrdinalFr
68
68
  const LINES_ABOVE = 3;
69
69
  const LATIN_WORD = /^[A-Za-z][A-Za-z ]*$/u;
70
70
 
71
- const markerTest = (marker: string): ((text: string) => boolean) => {
71
+ export const markerTest = (marker: string): ((text: string) => boolean) => {
72
72
  if (!LATIN_WORD.test(marker)) return (text) => text.includes(marker);
73
73
  const word = new RegExp(String.raw`(?<![A-Za-z])${marker}(?![A-Za-z])`, "iu");
74
74
  return (text) => word.test(text);
@@ -18,6 +18,7 @@ import { citationLead } from "./citation-sentence.ts";
18
18
  import { acronymExpansionSpans } from "../acronym-expansion.ts";
19
19
  import { nameEndingRuns, namesWrittenOneWay } from "../name-ending-run.ts";
20
20
  import { entriesForGenre } from "../lexicon-genres.ts";
21
+ import { echoesQuotation, quotationsIn } from "../quote-echo.ts";
21
22
 
22
23
  export type IsOpen = (start: number, end: number) => boolean;
23
24
 
@@ -56,6 +57,8 @@ export type Names = {
56
57
  readonly nameEndings: readonly string[];
57
58
  /** The facilities' and organisations' names the document writes one way only (こども動物園). */
58
59
  readonly oneWayNames: ReadonlySet<string>;
60
+ /** What the document quotes, every quotation's inside: a phrase the writer repeats from one keeps its spelling. */
61
+ readonly quotations: readonly string[];
59
62
  };
60
63
 
61
64
  export const namesOf = (doc: ProseDocument, genre: string | undefined): Names => ({
@@ -70,6 +73,7 @@ export const namesOf = (doc: ProseDocument, genre: string | undefined): Names =>
70
73
  oneWayNames: namesWrittenOneWay(
71
74
  [...doc.sentences, ...(doc.tableCells?.() ?? [])].flatMap(({ tokens }) => nameEndingRuns(tokens ?? [], patternsOf(doc, NAME_ENDING, genre))),
72
75
  ),
76
+ quotations: doc.sentences.flatMap(({ text }) => quotationsIn(text, quotedSpans(text, QUOTATION_MARKS))),
73
77
  });
74
78
 
75
79
  /** Spans placed in the source, placed in a sentence's text instead. */
@@ -99,8 +103,8 @@ const ownSpellingSpans = (sentence: Sentence, names: Names): Span[] => [
99
103
  /**
100
104
  * Whether a stretch of the sentence is outside a quotation, the team's names, a company's name (関東珪曹硝子㈱), a reading in
101
105
  * brackets (HTTP(えいちてぃーてぃーぴー)), a label opening the sentence ((答)), a spelling mentioned ((曇)とも書く), a
102
- * contact's name beside its phone number and what keeps a spelling of its own: a reading is not a spelling at all, a label is a
103
- * fixed short form, a mention is the subject, and the rest keep their own spelling.
106
+ * contact's name beside its phone number, what keeps a spelling of its own and a phrase repeated from a quotation: a reading is
107
+ * not a spelling at all, a label is a fixed short form, a mention is the subject, and the rest keep their own spelling.
104
108
  */
105
109
  export const isOpenIn = (sentence: Sentence, names: Names): IsOpen => {
106
110
  const closed = [
@@ -115,5 +119,6 @@ export const isOpenIn = (sentence: Sentence, names: Names): IsOpen => {
115
119
  ...ownSpellingSpans(sentence, names),
116
120
  ];
117
121
  const named = nameSpans(sentence.text, names.team);
118
- return (start, end) => !isWithinAny(closed, { start, end }) && !touchesAny(named, start, end);
122
+ return (start, end) =>
123
+ !isWithinAny(closed, { start, end }) && !touchesAny(named, start, end) && !echoesQuotation(sentence.text, { start, end }, names.quotations);
119
124
  };
@@ -3,13 +3,14 @@ import { conjugatedStartsOutside } from "./conjugated-entry.ts";
3
3
  import { calendarRuns, calendarUnitsOf, type CalendarUnits } from "../calendar-number.ts";
4
4
  import { escapeRegExp, latinBoundaries, occurrencesOutside, type Boundary, type SpacingKind } from "../orthography.ts";
5
5
  import { minorityReport, withoutSideOnTie } from "../spacing-minority.ts";
6
- import { isWithinAny, quotedSpans } from "../quoted-span.ts";
6
+ import { isWithinAny, QUOTATION_MARKS, quotedSpans } from "../quoted-span.ts";
7
7
  import { digitRunAround, endsWithDivisionLabel, isNumberName, sequenceLabelStarts, type NameContext } from "../number-name.ts";
8
8
  import { isSpacedLocationPart, type FloorWords } from "../location-part.ts";
9
9
  import { isFieldSeparator, isNameSeparator, type OrganizationWords } from "../name-separator.ts";
10
10
  import { addressSpans, clockTimeSpans, identifierSpans, isInsideSpan } from "../spacing-code.ts";
11
11
  import { followsHandle, isBoundSuffix, isJoinerSpace } from "../latin-word-boundary.ts";
12
12
  import { licenceNoticeSentences } from "./licence-notice.ts";
13
+ import { followsCaptionLabel, isCitedEntryLine, isNumberTableBoundary, lineAt } from "../latin-spacing-source.ts";
13
14
 
14
15
  /** 書いた形の出現に、動詞の活用した形(行う → 行います)を足したもの。同じ位置は一度だけ。 */
15
16
  const avoidedStarts = (sentence: Sentence, entry: LexiconEntry, use: string): number[] => {
@@ -59,6 +60,8 @@ type NumberContext = NameContext & {
59
60
  readonly organizations: OrganizationWords;
60
61
  /** 日本語の句をつなぐ英語の語(or、vs.)と、英字の語に付ける接尾の語(版、化)。 */
61
62
  readonly latinWords: { readonly joiners: ReadonlySet<string>; readonly boundSuffixes: ReadonlySet<string> };
63
+ /** 図表の札(表、図)。行の頭にこれだけを書いた後ろの空白は、札と題の区切り。 */
64
+ readonly captionLabels: ReadonlySet<string>;
62
65
  };
63
66
 
64
67
  /** 文頭の項目の番号の後ろと見る境目の位置の上限。番号は短く文の頭にあるので、これより後ろの境目は番号の後ろではない。長い文で文頭からの切り出しを繰り返さない。 */
@@ -107,7 +110,10 @@ type SentenceCodes = {
107
110
  */
108
111
  /** 項目の番号・識別子・チャンネルや宛先の名前(#pj_oss-team)の端の境目。どれも名前や番号を閉じる空白で、空け方の好みではない。 */
109
112
  const closesName = (sentence: Sentence, boundary: Boundary, context: NumberContext, codes: SentenceCodes): boolean =>
110
- followsItemNumber(sentence.text, boundary, context.itemNumbers) || besideSpan(codes.identifiers, boundary) || followsHandle(sentence.text, boundary);
113
+ followsItemNumber(sentence.text, boundary, context.itemNumbers) ||
114
+ followsCaptionLabel(sentence.text, boundary, context.captionLabels) ||
115
+ besideSpan(codes.identifiers, boundary) ||
116
+ followsHandle(sentence.text, boundary);
111
117
 
112
118
  const isCounted = (sentence: Sentence, boundary: Boundary, context: NumberContext, codes: SentenceCodes): boolean => {
113
119
  if (closesName(sentence, boundary, context, codes)) return false;
@@ -194,22 +200,29 @@ export const latinSpacing: Detector = (doc, options): Finding[] => {
194
200
  floors: { units: patternsOf(doc, "floor-unit"), levels: patternsOf(doc, "floor-level") },
195
201
  organizations: { units: patternsOf(doc, "organization-unit"), forms: patternList(doc, "company-form") },
196
202
  latinWords: { joiners: patternsOf(doc, "latin-joiner"), boundSuffixes: patternsOf(doc, "latin-bound-suffix") },
203
+ captionLabels: patternsOf(doc, "figure-label"),
197
204
  };
198
205
  // 文書の最後の利用条件の断り書き(クリエイティブ・コモンズ 表示 4.0 国際)は、掲載先の書き方で書き手の空け方ではない。
199
206
  const licence = licenceNoticeSentences(doc, doc.lexicons["licence-word"] ?? []);
200
207
  const located: Located[] = doc.sentences.flatMap((sentence) => {
201
208
  if (licence.has(sentence)) return [];
202
- const quoted = quotedSpans(sentence.text);
209
+ // 「」『』のほか、“”で引いた題名(“パブリック・ドメイン・マーク 1.0 全世界コモンズ証”)も元の書き方。
210
+ const quoted = quotedSpans(sentence.text, QUOTATION_MARKS);
203
211
  const codes = {
204
212
  calendar: calendarStarts(sentence, context.calendar),
205
213
  clockTimes: clockTimeSpans(sentence.text),
206
214
  addresses: addressSpans(sentence.text),
207
215
  identifiers: identifierSpans(sentence.text),
208
216
  };
209
- return latinBoundaries(sentence.text, doc.source.slice(sentence.span.start, sentence.span.end))
210
- .filter((boundary) => !isQuoted(quoted, boundary) && !isInsideLink(doc.links, sentence.span.start + boundary.offset))
211
- .filter((boundary) => isCounted(sentence, boundary, context, codes))
212
- .map((boundary) => ({ sentence, ...boundary }));
217
+ return (
218
+ latinBoundaries(sentence.text, doc.source.slice(sentence.span.start, sentence.span.end))
219
+ .filter((boundary) => !isQuoted(quoted, boundary) && !isInsideLink(doc.links, sentence.span.start + boundary.offset))
220
+ .filter((boundary) => !isCitedEntryLine(lineAt(doc.source, sentence.span.start + boundary.offset)))
221
+ // 変換で一続きになった数の表の、升の区切りの空白。
222
+ .filter((boundary) => !isNumberTableBoundary(sentence.text, boundary))
223
+ .filter((boundary) => isCounted(sentence, boundary, context, codes))
224
+ .map((boundary) => ({ sentence, ...boundary }))
225
+ );
213
226
  });
214
227
  return KINDS.flatMap((kind) =>
215
228
  findingsOf(