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
@@ -1,10 +1,11 @@
1
1
  import { lengthOf, proseText } from "../measure.ts";
2
2
  import type { Detector, DetectorOptions, Finding, LengthUnit, Sentence } from "../plugin.ts";
3
3
  import { citationLead } from "./citation-sentence.ts";
4
- import { isCitationString } from "./citation-string.ts";
4
+ import { isCitationString, wordsAroundCitation } from "./citation-string.ts";
5
5
  import { isNameList } from "./name-list-sentence.ts";
6
6
  import { pageMarkerPattern, pageMarkerSize } from "./page-marker.ts";
7
7
  import { quotedSentenceParts } from "./quoted-sentences.ts";
8
+ import { isReproduced, reproducedSpans } from "./reproduced-text.ts";
8
9
  import { colonQuotationParts, flattenedTableParts, isGrammarBlock, labelLineParts } from "./sentence-parts.ts";
9
10
  import { isInListItem, isReferenceLine, isTitleLine, quotedTitleWords, remarkAfterTitle, termSeriesSaving } from "./sentence-title.ts";
10
11
 
@@ -61,6 +62,8 @@ const partsOf = (sentence: Sentence, text: string): readonly string[] | undefine
61
62
  const ownSize = (sentence: Sentence, unit: LengthUnit, words: SentenceWords): number => {
62
63
  const text = proseText(sentence);
63
64
  if (isUnwritten(sentence, text, unit, words)) return 0;
65
+ const aroundCitation = unit === "word" ? wordsAroundCitation(text, words.citationSignals) : undefined;
66
+ if (aroundCitation !== undefined) return sizeOf(aroundCitation, unit);
64
67
  const parts = partsOf(sentence, text);
65
68
  if (parts !== undefined) return Math.max(0, ...parts.map((part) => sizeOf(part, unit) - pageMarkerSize(part, words.markers, unit)));
66
69
  const remark = unit === "word" ? remarkAfterTitle(text) : undefined;
@@ -76,9 +79,21 @@ export const sentenceLength: Detector = (doc, options): Finding[] => {
76
79
  citationSignals: (doc.lexicons["citation-signal"] ?? []).map((entry) => entry.pattern),
77
80
  listItems: doc.lists.flatMap((list) => list.itemSpans),
78
81
  };
79
- return doc.sentences
82
+ const long = doc.sentences
80
83
  .map((sentence) => ({ sentence, measure: measureOf(sentence, doc.lengthUnit, options, words) }))
81
- .filter(({ sentence, measure }) => measure.size > measure.limit && !isNameList(proseText(sentence)))
84
+ .filter(({ sentence, measure }) => measure.size > measure.limit && !isNameList(proseText(sentence)));
85
+ // 他の文書から引き写した文(法律の条、「reads as follows:」の後の段落)は書き手の文ではない。探すのに文書の木を組むので、長い文があるときだけ。
86
+ const reproduced =
87
+ long.length === 0
88
+ ? []
89
+ : reproducedSpans(
90
+ doc.structure,
91
+ doc.paragraphs,
92
+ doc.source,
93
+ (doc.lexicons["verbatim-lead"] ?? []).map((entry) => entry.pattern),
94
+ );
95
+ return long
96
+ .filter(({ sentence }) => !isReproduced(sentence.span, reproduced))
82
97
  .map(({ sentence, measure }) => ({
83
98
  rule: "max-sentence-length",
84
99
  severity: "warning",
@@ -3,6 +3,8 @@
3
3
  // a converter ran together (…設立1945年7月日染興業…, 39,0439,677…), and a quotation the writer introduces with a colon.
4
4
  // Each is measured part by part, or not at all. Pure: the text in, the parts out.
5
5
 
6
+ import type { Span } from "../plugin.ts";
7
+
6
8
  const LINE_BREAK = /\n/u;
7
9
  /** A sentence's end on a line: a stop, then any closing quotes or brackets. */
8
10
  const LINE_ENDS_SENTENCE = /[.?!。?!][\s"'”’)\])」』]*$/u;
@@ -52,9 +54,16 @@ const MIN_GLUED_DATES = 3;
52
54
 
53
55
  const nonEmpty = (parts: readonly string[]): string[] => parts.map((part) => part.trim()).filter((part) => part !== "");
54
56
 
57
+ /** Whether the text holds cells of numbers a converter ran together (39,0439,677). */
58
+ export const hasGluedNumbers = (text: string): boolean => GLUED_NUMBER.test(text);
59
+
60
+ /** Where the text holds numbers of several cells run together (8,45795.7 for 8,457 and 95.7): no digit in them can be read as one number. */
61
+ export const gluedNumberSpans = (text: string): Span[] =>
62
+ [...text.matchAll(NUMBER_RUN)].filter((run) => GLUED_NUMBER.test(run[0])).map((run) => ({ start: run.index, end: run.index + run[0].length }));
63
+
55
64
  /** The cells of a table a converter flattened into one sentence, cut at the glued numbers or at each row's date. */
56
65
  export const flattenedTableParts = (text: string): readonly string[] | undefined => {
57
- if (GLUED_NUMBER.test(text)) return nonEmpty(text.replace(NUMBER_RUN, (run) => (GLUED_NUMBER.test(run) ? CUT : run)).split(CUT));
66
+ if (hasGluedNumbers(text)) return nonEmpty(text.replace(NUMBER_RUN, (run) => (GLUED_NUMBER.test(run) ? CUT : run)).split(CUT));
58
67
  const rows = text.split(GLUED_DATE);
59
68
  return rows.length > MIN_GLUED_DATES ? nonEmpty(rows) : undefined;
60
69
  };
@@ -68,3 +77,12 @@ export const colonQuotationParts = (text: string): readonly string[] | undefined
68
77
  if (quotes.length === 0) return undefined;
69
78
  return nonEmpty([text.replace(COLON_QUOTATION, ":"), ...quotes]);
70
79
  };
80
+
81
+ /** A header cell closed by its unit in brackets (所有割合(%), 従業員数(人), 資本金(百万円)). */
82
+ const UNIT_HEADER = /[((](?:%|%|人|名|株|件|台|社|円|千円|百万円)[))]/gu;
83
+ /** Fewer unit headers than this are a sentence that names a unit or two, not a table's header row. */
84
+ const MIN_UNIT_HEADERS = 3;
85
+
86
+ /** Whether a sentence is a table a converter flattened: glued numbers, rows opened by dates, or a header row of cells closed by units. */
87
+ export const isFlattenedTable = (text: string): boolean =>
88
+ flattenedTableParts(text) !== undefined || (text.match(UNIT_HEADER)?.length ?? 0) >= MIN_UNIT_HEADERS;
@@ -7,7 +7,10 @@ import { isExplained } from "./acronym-compound.ts";
7
7
  import { statedAcronyms } from "./acronym-definition.ts";
8
8
  import { isBracketed, isInHeading, isNamePart } from "./acronym-lone.ts";
9
9
  import { linkedListTerms } from "./acronym-link.ts";
10
- import { caseVariantsIn, spelledOutAcronyms } from "./acronym-mention.ts";
10
+ import { headingSeries } from "./acronym-series.ts";
11
+ import { citationSpans } from "./acronym-name.ts";
12
+ import { referenceEntryLabels } from "./reference-entry.ts";
13
+ import { caseVariantsIn, spelledOutAcronyms, writtenAsWordIn } from "./acronym-mention.ts";
11
14
  import { conjugatedForms } from "./conjugated-form.ts";
12
15
  import { knownByDocument } from "./acronym-known.ts";
13
16
  import { explainedInText, headingsSpellingOut } from "./acronym-gloss.ts";
@@ -25,6 +28,11 @@ export const MIN_DOCUMENT_LENGTH = { word: 200, char: 500 };
25
28
 
26
29
  const bodyOf = (doc: ProseDocument): string => doc.sentences.map(proseText).join(" ");
27
30
 
31
+ /** 全角の英数字を半角に(ICO(Initial Coin Offering)の ICO を ICO と読む)。1 文字ずつ置き換えるので位置は変わらない。 */
32
+ const FULL_WIDTH_ALNUM = /[A-Za-z0-9]/gu;
33
+ const FULL_WIDTH_OFFSET = 0xfee0;
34
+ const halfWidth = (text: string): string => text.replaceAll(FULL_WIDTH_ALNUM, (character) => String.fromCharCode(character.charCodeAt(0) - FULL_WIDTH_OFFSET));
35
+
28
36
  type Hit = { readonly sentence: Sentence; readonly offset: number };
29
37
 
30
38
  const findIn = (doc: ProseDocument, pattern: RegExp): Hit[] =>
@@ -175,6 +183,13 @@ const expandsInHeading = (heading: string, acronym: string, expandedAt: Expanded
175
183
 
176
184
  const patternsOf = (doc: ProseDocument, id: string): string[] => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
177
185
 
186
+ /**
187
+ * 法令集の名前(CFR)を、この文書が引用の形(12 CFR 1005.20)で書いているなら、引用の外(the List of CFR Sections Affected)でも
188
+ * 読み手の知る名前と読む。引用の形で書いていない文書の CFR は略語のまま数える。
189
+ */
190
+ const citedSeriesOf = (doc: ProseDocument, body: string): string[] =>
191
+ patternsOf(doc, "citation-series").filter((series) => citationSpans(body, [series]).length > 0 || titledCodeSpans(body, [series]).length > 0);
192
+
178
193
  const notationOf = (doc: ProseDocument): NotAcronymSpans => lexiconNotationOf((id) => patternsOf(doc, id));
179
194
 
180
195
  /** 定義の語。定義の動詞は、語彙表の形(という)と、この文書で活用して書かれた形(といいます)の両方で照らす。 */
@@ -203,14 +218,15 @@ const isNamePartAt = (acronym: string, hit: Hit): boolean => {
203
218
  * 書き手が展開する文書では、展開の抜けは抜けとして読める。名前の一部の略語(SRI International)は、そのときも指さない。
204
219
  */
205
220
  export const undefinedAcronym: Detector = (doc, options): Finding[] => {
206
- const body = bodyOf(doc);
207
- // HTTP のメソッド名(GET)は略語ではなく、税の名前(VAT、GST)は読み手が名前として知るので、通じる略語と同じく展開を求めない。
221
+ const body = halfWidth(bodyOf(doc));
222
+ // HTTP のメソッド名(GET)と SQL のキーワード(VIEW)は略語ではなく、税の名前(VAT、GST)は読み手が名前として知るので、通じる略語と同じく展開を求めない。
208
223
  // 並べた名前(JAXA)も、繋いだ略語(JAXA-ISAS)の片割れとして説明済みに数える。
209
224
  // 文書が自分で知らせた語(select を書いた文書の SELECT、リンクで引いた講演の場 [Jane Roe, FOSDEM 2024](…))も同じ。
210
225
  const common = new Set([
211
226
  ...(options.lexicon ?? []).map((entry) => entry.pattern),
212
- ...knownByDocument(doc.source, doc.links).concat(patternsOf(doc, "http-method"), patternsOf(doc, "tax-code")),
227
+ ...knownByDocument(doc.source, doc.links).concat(patternsOf(doc, "http-method"), patternsOf(doc, "sql-keyword"), patternsOf(doc, "tax-code")),
213
228
  ...(doc.names ?? []),
229
+ ...citedSeriesOf(doc, body),
214
230
  ]);
215
231
  const expandedAt = expansionAt(definitionWordsOf(doc));
216
232
  const stated = statedAcronyms(doc.source, { statements: patternsOf(doc, "definition-statement"), markers: patternsOf(doc, "definition-marker") });
@@ -222,8 +238,17 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
222
238
  );
223
239
  // 略語のすぐ後ろのダッシュで挟んだ同格(the VIX—a measure of …—)、同じ文の前に書いた名前(Small Business Administration … SBA)、
224
240
  // 2 つ以上の番号で引く続き物の名前(BCP 78、BCP 14)も、略語の説明と読む。
225
- const entries = new Set([...termEntryAcronyms(doc.source), ...stated, ...linkedListTerms(doc.source), ...spelled, ...explainedInText(body, doc.sentences)]);
226
- const headings = doc.sections.map((section) => section.heading);
241
+ // 文献一覧の見出し語([UNIX] The Open Group, "The Single UNIX Specification")と、見出しに番号で立てた書簡の続き物(### SR 26-8: …)も。
242
+ const headings = doc.sections.map((section) => halfWidth(section.heading));
243
+ const entries = new Set([
244
+ ...termEntryAcronyms(doc.source),
245
+ ...stated,
246
+ ...linkedListTerms(doc.source),
247
+ ...spelled,
248
+ ...explainedInText(body, doc.sentences),
249
+ ...referenceEntryLabels(doc.source),
250
+ ...headingSeries(headings),
251
+ ]);
227
252
  // 見出しが略語の名前を書き出していれば(## Federal Open Market Committee の下の FOMC)、説明済み。
228
253
  const spelledInHeading = headingsSpellingOut(headings);
229
254
  const explainedAsWritten = (word: string): boolean =>
@@ -233,9 +258,12 @@ export const undefinedAcronym: Detector = (doc, options): Finding[] => {
233
258
  isExpanded(body, word, expandedAt) ||
234
259
  headings.some((heading) => expandsInHeading(heading, word, expandedAt));
235
260
  // 大文字の違うだけの書き方(TCoP と TCOP)は同じ略語と読む。どちらかで説明してあれば説明済み。
261
+ // 文の中で頭だけ大文字の語に書いた名前(a hotel / Airbnb)を大文字で書いた AIRBNB は、語を大きく書いただけで略語ではない。
262
+ const wholeText = [body, ...headings].join("\n");
236
263
  const explained = new Map<string, boolean>();
237
264
  const explainedAlone = (word: string): boolean => {
238
- const known = explained.get(word) ?? (explainedAsWritten(word) || caseVariantsIn([body, ...headings].join("\n"), word).some(explainedAsWritten));
265
+ const known =
266
+ explained.get(word) ?? (explainedAsWritten(word) || writtenAsWordIn(wholeText, word) || caseVariantsIn(wholeText, word).some(explainedAsWritten));
239
267
  explained.set(word, known);
240
268
  return known;
241
269
  };
@@ -1,6 +1,7 @@
1
1
  import type { Detector, Finding, Lexicon, ProseDocument, Sentence, Span } from "../plugin.ts";
2
2
  import { minorityWithin } from "../orthography.ts";
3
3
  import { QUOTATION_MARKS, isWithinAny, quotedSpans } from "../quoted-span.ts";
4
+ import { referenceListSpans } from "../reference-lists.ts";
4
5
 
5
6
  /**
6
7
  * 綴りの組の語彙表の名前の頭。組(spelling-variant、spelling-ize)ごとに比べる。組を分けるのは、両方の書き方が一つの
@@ -36,6 +37,15 @@ const CAPITAL = /^\p{Lu}/u;
36
37
  /** 大文字で始まる次の語。文の頭でも、大文字の語が続けば名前(Labor Day、Centre Court)。 */
37
38
  const CAPITALISED_NEXT = /^[ \t]+\p{Lu}/u;
38
39
 
40
+ /** 斜線でつないだ組(analyse/analyze)。両方の綴りを並べて名指ししているので、書き手の綴りではない。 */
41
+ const SLASH = "/";
42
+
43
+ const pairedBySlash = (text: string, at: number, word: string, other: string): boolean => {
44
+ const before = text.slice(Math.max(0, at - other.length - SLASH.length), at).toLowerCase();
45
+ const after = text.slice(at + word.length, at + word.length + SLASH.length + other.length).toLowerCase();
46
+ return before === `${other.toLowerCase()}${SLASH}` || after === `${SLASH}${other.toLowerCase()}`;
47
+ };
48
+
39
49
  export type SpelledWord = { readonly written: string; readonly offset: number; readonly spelling: Spelling };
40
50
 
41
51
  /**
@@ -50,7 +60,10 @@ export const spelledWordsIn = (sentence: Sentence, spellings: ReadonlyMap<string
50
60
  const named = CAPITAL.test(match[0]) && (match.index !== first || CAPITALISED_NEXT.test(sentence.text.slice(match.index + match[0].length)));
51
61
  const inQuote =
52
62
  isWithinAny(quoted, { start: match.index, end: match.index + match[0].length }) || OPENING_QUOTE.test(sentence.text.charAt(match.index - 1));
53
- return spelling === undefined || named || inQuote ? [] : [{ written: match[0], offset: sentence.span.start + match.index, spelling }];
63
+ if (spelling === undefined || named || inQuote) return [];
64
+ return pairedBySlash(sentence.text, match.index, match[0], spelling.other)
65
+ ? []
66
+ : [{ written: match[0], offset: sentence.span.start + match.index, spelling }];
54
67
  });
55
68
  };
56
69
 
@@ -65,13 +78,24 @@ const findingOf = ({ sentence, word }: Located, count: number, of: number): Find
65
78
  values: { matched: word.written, other: word.spelling.other, count, of, offset: word.offset },
66
79
  });
67
80
 
81
+ const REFERENCE_LIST_HEADING = "reference-list-heading";
82
+
83
+ /** 文献一覧の外の文。文献一覧の題や出版者の名前は、引いた文献の綴りのまま書く。 */
84
+ const outsideReferenceLists = (doc: ProseDocument): Sentence[] => {
85
+ const lists = referenceListSpans(
86
+ doc.source,
87
+ (doc.lexicons[REFERENCE_LIST_HEADING] ?? []).map((entry) => entry.pattern),
88
+ );
89
+ return doc.sentences.filter((sentence) => !lists.some((list) => list.start <= sentence.span.start && sentence.span.start < list.end));
90
+ };
91
+
68
92
  /**
69
93
  * イギリスとアメリカの綴り(colour と color、centre と center)が一つの文書で混ざっているか。組ごとに、文書の中で少ないほうを
70
94
  * 指摘する。どちらが正しいかは決めない。少ないほうが組の limit パーセントを超えるなら、使い分けと見て言わない。
71
95
  */
72
96
  export const spellingVariety: Detector = (doc, options): Finding[] => {
73
97
  const spellings = spellingsOf(doc.lexicons);
74
- const located: Located[] = doc.sentences.flatMap((sentence) => spelledWordsIn(sentence, spellings).map((word) => ({ sentence, word })));
98
+ const located: Located[] = outsideReferenceLists(doc).flatMap((sentence) => spelledWordsIn(sentence, spellings).map((word) => ({ sentence, word })));
75
99
  const families = [...new Set(located.map(({ word }) => word.spelling.family))];
76
100
  return families.flatMap((family) => {
77
101
  const ofFamily = located.filter(({ word }) => word.spelling.family === family);
@@ -1,7 +1,6 @@
1
1
  import type { Detector, Finding, ProseDocument, StructureNode } from "../plugin.ts";
2
- import { danglingReferences, duplicateDefinitions, inDocumentOrder, type StructureIssue } from "../structure/issues.ts";
2
+ import { danglingReferences, inDocumentOrder, type StructureIssue } from "../structure/issues.ts";
3
3
  import { numberingBreaks } from "../structure/numbering.ts";
4
- import { attachedPartStarts } from "../structure/attached-parts.ts";
5
4
  import { numberingReadings } from "./numbering-readings.ts";
6
5
  import { listsNumberBreaks } from "../structure/list-numbering.ts";
7
6
  import { weekdayMismatches } from "../structure/weekday.ts";
@@ -38,7 +37,7 @@ export const quoteAt = (source: string, offset: number): string => {
38
37
  .trim();
39
38
  };
40
39
 
41
- const findingsOf =
40
+ export const findingsOf =
42
41
  (rule: string, issuesOf: (tree: NonNullable<ProseDocument["structure"]>, source: string) => StructureIssue[]): Detector =>
43
42
  (doc): Finding[] =>
44
43
  doc.structure === undefined
@@ -95,11 +94,6 @@ export const numberingGap: Detector = (doc, options): Finding[] => {
95
94
  (left, right) => Number(left.values["offset"]) - Number(right.values["offset"]),
96
95
  );
97
96
  };
98
- export const duplicateDefinition: Detector = (doc, options) => {
99
- const labels = patternsOf(doc, "attached-instrument-label");
100
- return findingsOf("duplicate-definition", (tree, source) => duplicateDefinitions(tree, attachedPartStarts(source, labels), source))(doc, options);
101
- };
102
-
103
97
  /** 曜日の名前は言語パッケージの語彙表(weekday、日曜日から順)から取る。無ければ番号のまま。 */
104
98
  const dayName = (doc: ProseDocument, day: unknown): string => {
105
99
  const index = Number(day);
@@ -4,7 +4,7 @@ import type { Detector, DetectorOptions, Finding, LengthUnit, Paragraph, ProseDo
4
4
  import { dateStampIndexes, stampCandidates } from "../date-stamp.ts";
5
5
  import { inDocumentOrder } from "../structure/issues.ts";
6
6
  import { preambleParagraphs } from "../preamble-paragraphs.ts";
7
- import { isTooLongParagraph } from "../paragraph-length.ts";
7
+ import { isTooLongParagraph, labelledBlocks, opensWithFusedHeading } from "../paragraph-length.ts";
8
8
  import { bodySectionOf } from "../body-section.ts";
9
9
  import { threeShare } from "../rule-of-three.ts";
10
10
  import { isInterview, sectionLevels } from "../section-levels.ts";
@@ -62,23 +62,39 @@ const uniformity = (doc: ProseDocument, values: readonly number[], span: { start
62
62
  const sentenceSize = (sentence: Sentence, unit: LengthUnit): number =>
63
63
  lengthOf(sentence, unit) + (unit === "word" ? contractionExtraWords(proseText(sentence)) : 0);
64
64
 
65
+ type Block = { readonly start: number; readonly sentences: readonly Sentence[] };
66
+
67
+ /**
68
+ * 段落の中の、長さを測る文の組と、その頭の位置(最初の組は段落の頭)。見出しが本文に溶けた段落(改行の落ちた文書)は測らない。
69
+ * 【】の見出しや段落番号だけの行で段落を割る。
70
+ */
71
+ const measuredBlocks = (doc: ProseDocument, paragraph: Paragraph): Block[] => {
72
+ const text = doc.source.slice(paragraph.span.start, paragraph.span.end);
73
+ if (opensWithFusedHeading(text)) return [];
74
+ return labelledBlocks(text, paragraph.span.start, paragraph.sentences).map((sentences, index) => ({
75
+ start: index === 0 ? paragraph.span.start : (sentences[0]?.span.start ?? paragraph.span.start),
76
+ sentences,
77
+ }));
78
+ };
79
+
65
80
  /** 1 段落に文を詰めすぎると、読み手はどこで息継ぎしていいか分からなくなる。 */
66
81
  export const paragraphLength: Detector = (doc, options): Finding[] =>
67
82
  doc.paragraphs
68
- .filter((paragraph) =>
83
+ .flatMap((paragraph) => measuredBlocks(doc, paragraph))
84
+ .filter((block) =>
69
85
  isTooLongParagraph(
70
- paragraph.sentences.map((sentence) => sentenceSize(sentence, doc.lengthUnit)),
86
+ block.sentences.map((sentence) => sentenceSize(sentence, doc.lengthUnit)),
71
87
  options.limit,
72
88
  options.fullSentence,
73
89
  ),
74
90
  )
75
- .map((paragraph) => ({
91
+ .map((block) => ({
76
92
  rule: "max-paragraph-length",
77
93
  severity: "warning",
78
94
  line: 0,
79
95
  column: 0,
80
- quote: doc.source.slice(paragraph.span.start, paragraph.span.start + 80).trim(),
81
- values: { count: paragraph.sentences.length, limit: options.limit, offset: paragraph.span.start },
96
+ quote: doc.source.slice(block.start, block.start + 80).trim(),
97
+ values: { count: block.sentences.length, limit: options.limit, offset: block.start },
82
98
  }));
83
99
 
84
100
  const charsOf = (paragraph: Paragraph): number => paragraph.sentences.reduce((sum, sentence) => sum + charLength(sentence), 0);
@@ -73,15 +73,23 @@ const verbAt = (tokens: readonly Token[], range: TokenRange, end: number): numbe
73
73
  return end - 1 > range.end && isVerbal(tokens[end - 1]) ? end - 1 : undefined;
74
74
  };
75
75
 
76
+ /** The first token after the verb at `at` and the auxiliaries and verbs that follow it (are addressed, should be fixed). */
77
+ const pastVerbs = (tokens: readonly Token[], at: number): number => {
78
+ const rest = tokens.slice(at + 1).findIndex((token) => !isVerbal(token));
79
+ return rest < 0 ? tokens.length : at + 1 + rest;
80
+ };
81
+
76
82
  /**
77
83
  * 最上級の名詞句が主語で、述語がどれかを指しているか(The best plan is the one you keep・The most important divergence is
78
- * the second)。どれが一番なのかを決める言い方で、一番だという主張ではない。
84
+ * the second)、順番のどこに来るかを言うか(the most critical vulnerabilities are addressed first)。どれが一番なのかを決める
85
+ * 言い方で、一番だという主張ではない。
79
86
  */
80
87
  export const pointsAtReferent = (tokens: readonly Token[], range: TokenRange, referents: Lexicon): boolean => {
81
88
  const end = phraseEnd(tokens, range.end);
82
89
  const at = verbAt(tokens, range, end);
83
90
  if (at === undefined) return false;
84
- const next = tokens[at + 1]?.pos === "DET" ? at + 2 : at + 1;
91
+ const object = pastVerbs(tokens, at);
92
+ const next = tokens[object]?.pos === "DET" ? object + 1 : object;
85
93
  return isWord(tokens[next], referents);
86
94
  };
87
95
 
@@ -0,0 +1,21 @@
1
+ // A list of titles written in sentence case (The bridge witch, The story of bubble gum, The law of finance and regulation). Pure.
2
+ import type { Token } from "../plugin.ts";
3
+
4
+ /** Items that open with a capitalised article after a comma or colon: a title's first word, not the writer's sentence. */
5
+ const TITLE_ITEMS = 2;
6
+
7
+ const ITEM_BREAKS: ReadonlySet<string> = new Set([",", ":"]);
8
+
9
+ const isCapitalised = (token: Token | undefined): boolean => /^\p{Lu}/u.test(token?.surface ?? "");
10
+
11
+ const opensTitle = (tokens: readonly Token[], at: number): boolean =>
12
+ at > 0 && tokens[at]?.pos === "DET" && isCapitalised(tokens[at]) && ITEM_BREAKS.has(tokens[at - 1]?.surface ?? "");
13
+
14
+ /**
15
+ * Whether the and / or at `at` is inside one of the titles: the sentence lists titles (two or more items open with a capitalised
16
+ * article mid-sentence) and the word after the and / or is lower case. The joint between two titles is followed by a capital.
17
+ */
18
+ export const insideSentenceCaseTitle = (tokens: readonly Token[]): ((at: number) => boolean) => {
19
+ const titles = tokens.filter((__token, at) => opensTitle(tokens, at)).length;
20
+ return (at) => titles >= TITLE_ITEMS && /^\p{Ll}/u.test(tokens[at + 1]?.surface ?? "");
21
+ };
@@ -5,8 +5,10 @@ import { externalLinkTitleSpans } from "../link-title.ts";
5
5
  import type { Detector, Finding, Span, Token } from "../plugin.ts";
6
6
  import { countedTokens, uncountedWordsOf, type UncountedWords } from "../uncounted-particles.ts";
7
7
  import { honorificGroupParticles } from "../honorific-group.ts";
8
+ import { setPhraseParticles } from "../set-phrase-particles.ts";
8
9
  import { noteSentences } from "../note-paragraphs.ts";
9
10
  import { documentNameSpans } from "./particle-run-names.ts";
11
+ import { isFlattenedTable } from "./sentence-parts.ts";
10
12
 
11
13
  /**
12
14
  * 文末が名詞で終わる(体言止め)。箇条書きでは普通だが、本文では文が途中で切れて読める。
@@ -93,11 +95,17 @@ const RUN_BREAK_LEXICON = "particle-run-break";
93
95
  /** 人の集まりを敬って呼ぶ語(国民の皆様の「皆様」)。直前の助詞は呼び方の一部で、入れ子の輪に数えない。 */
94
96
  const HONORIFIC_GROUP_LEXICON = "honorific-group";
95
97
 
96
- /** 数えない助詞(番号をつなぐ「の」と、敬って呼ぶ語の前の「の」)を除いた語。 */
97
- const chainTokens = (tokens: readonly Token[], numbering: UncountedWords, groups: readonly string[]): readonly Token[] => {
98
- const honorific = honorificGroupParticles(tokens, numbering.particles, groups);
98
+ /** 助詞を挟んで一語のように読む決まった言い回し(おそれのある)。中の助詞は入れ子の輪に数えない。 */
99
+ const SET_PHRASE_LEXICON = "particle-run-set-phrase";
100
+
101
+ /** 敬って呼ぶ語(皆様)と決まった言い回し(おそれのある)。 */
102
+ type Phrases = { readonly groups: readonly string[]; readonly setPhrases: readonly string[] };
103
+
104
+ /** 数えない助詞(番号をつなぐ「の」、敬って呼ぶ語の前の「の」、決まった言い回しの中の「の」)を除いた語。 */
105
+ const chainTokens = (tokens: readonly Token[], numbering: UncountedWords, { groups, setPhrases }: Phrases): readonly Token[] => {
106
+ const uncounted = new Set([...honorificGroupParticles(tokens, numbering.particles, groups), ...setPhraseParticles(tokens, numbering.particles, setPhrases)]);
99
107
  const counted = countedTokens(tokens, numbering);
100
- return honorific.size === 0 ? counted : counted.filter((token) => !honorific.has(token));
108
+ return uncounted.size === 0 ? counted : counted.filter((token) => !uncounted.has(token));
101
109
  };
102
110
 
103
111
  export const doubledParticle: Detector = (doc, options): Finding[] => {
@@ -105,22 +113,28 @@ export const doubledParticle: Detector = (doc, options): Finding[] => {
105
113
  const titles = externalLinkTitleSpans(doc.source, doc.links);
106
114
  const breaks = (doc.lexicons[RUN_BREAK_LEXICON] ?? []).map((entry) => entry.pattern);
107
115
  const numbering = uncountedWordsOf(doc.lexicons, nesting);
108
- const groups = (doc.lexicons[HONORIFIC_GROUP_LEXICON] ?? []).map((entry) => entry.pattern);
116
+ const phrases: Phrases = {
117
+ groups: (doc.lexicons[HONORIFIC_GROUP_LEXICON] ?? []).map((entry) => entry.pattern),
118
+ setPhrases: (doc.lexicons[SET_PHRASE_LEXICON] ?? []).map((entry) => entry.pattern),
119
+ };
109
120
  const prose = doc.prose ?? doc.source;
110
- return doc.sentences.flatMap((sentence) => {
111
- const tokens = chainTokens(sentence.tokens ?? [], numbering, groups);
112
- const quoted = [...quotedIn(sentence), ...titles];
113
- const longRuns = (skipped: readonly Span[]): Run[] => runsOf(tokens, nesting, breaks, skipped).filter((run) => run.tokens.length > options.limit);
114
- const found = longRuns(quoted);
115
- // 文書の名前を読むのは長い連なりのある文だけ。名前は位置ごとに読むので、全部の文で読むと遅い。
116
- const runs = found.length === 0 ? found : longRuns([...quoted, ...documentNameSpans(prose, sentence.span, doc.namedDocument)]);
117
- return runs.map((run) => ({
118
- rule: "no-doubled-joshi",
119
- severity: "warning" as const,
120
- line: 0,
121
- column: 0,
122
- quote: sentence.text.trim(),
123
- values: { word: run.surface, count: run.tokens.length, limit: options.limit, offset: run.tokens[0]?.span.start ?? sentence.span.start },
124
- }));
125
- });
121
+ // 平らにした表の文は、見出しのセル(役員の兼任等・営業上の取引・設備の賃貸借)の切れ目が見えず、別のセルの「の」が一つの連なりに見える。
122
+ return doc.sentences
123
+ .filter((sentence) => !isFlattenedTable(sentence.text))
124
+ .flatMap((sentence) => {
125
+ const tokens = chainTokens(sentence.tokens ?? [], numbering, phrases);
126
+ const quoted = [...quotedIn(sentence), ...titles];
127
+ const longRuns = (skipped: readonly Span[]): Run[] => runsOf(tokens, nesting, breaks, skipped).filter((run) => run.tokens.length > options.limit);
128
+ const found = longRuns(quoted);
129
+ // 文書の名前を読むのは長い連なりのある文だけ。名前は位置ごとに読むので、全部の文で読むと遅い。
130
+ const runs = found.length === 0 ? found : longRuns([...quoted, ...documentNameSpans(prose, sentence.span, doc.namedDocument)]);
131
+ return runs.map((run) => ({
132
+ rule: "no-doubled-joshi",
133
+ severity: "warning" as const,
134
+ line: 0,
135
+ column: 0,
136
+ quote: sentence.text.trim(),
137
+ values: { word: run.surface, count: run.tokens.length, limit: options.limit, offset: run.tokens[0]?.span.start ?? sentence.span.start },
138
+ }));
139
+ });
126
140
  };
@@ -49,6 +49,8 @@ export type TermWords = {
49
49
  readonly named: readonly string[];
50
50
  /** What turns a term into another one (本報告書等 after 本報告書): a group the document has to define on its own. */
51
51
  readonly groupSuffixes: readonly string[];
52
+ /** The document takes the definitions of another one (本共同研究開発契約において定義した用語…同契約内の定義に従う). */
53
+ readonly inheritsDefinitions?: boolean;
52
54
  };
53
55
 
54
56
  const QUOTED = /[「『“"](?<term>[^「」『』“”"\n]{1,40})[」』”"]/gu;
@@ -84,17 +86,37 @@ const knownForms = (defined: readonly string[], groups: TermWords["prefixGroups"
84
86
  ...defined.flatMap((term) => prefixVariants(term, groups)),
85
87
  ];
86
88
 
89
+ /** Every character of the shorter one, in order, in the longer one (本学習モデル in 本学習済みモデル). */
90
+ const isSubsequence = (shorter: string, longer: string): boolean => {
91
+ const chars = Array.from(longer);
92
+ let at = 0;
93
+ return Array.from(shorter).every((char) => {
94
+ const found = chars.indexOf(char, at);
95
+ at = found + 1;
96
+ return found !== -1;
97
+ });
98
+ };
99
+
100
+ /** A slip for another term: the same prefix, its characters a part of the other's, and not the other's start (本学習モデル for 本学習済みモデル). */
101
+ const isSlipOf = (term: string, other: string, prefix: string): boolean =>
102
+ other.startsWith(prefix) && other.length > term.length && !other.startsWith(term) && isSubsequence(term, other);
103
+
87
104
  /**
88
105
  * The first use of each term written with the document's prefix and defined nowhere, when the document defines at
89
106
  * least one term with that prefix (else the prefix is not its way of naming terms). A use that starts with a known
90
107
  * form (本サービス上 where 本サービス is defined) is that term, unless the rest is a group's mark (本サービス等).
108
+ * A name of a document (本共同開発契約) is left like the document's name for itself, unless it is a slip for a defined term
109
+ * (本共同研究開発契約). A document that takes the definitions of another one has terms defined there: only a slip for
110
+ * another of its terms (本学習モデル beside 本学習済みモデル) is reported then.
91
111
  */
92
112
  export const undefinedTerms = (source: string, sentences: readonly (readonly Token[])[], defined: readonly string[], words: TermWords): UndefinedTerm[] => {
93
113
  const prefixes = words.prefixes.filter((prefix) => prefix !== "");
94
114
  if (!defined.some((term) => hasPrefix(term, prefixes))) return [];
115
+ const selfNouns = words.selfNouns.filter((noun) => noun !== "");
95
116
  const isSelf = (term: string, prefix: string): boolean => {
96
117
  const rest = term.slice(prefix.length);
97
- return words.selfNouns.some((noun) => noun !== "" && (rest.startsWith(noun) || rest.endsWith(noun)));
118
+ if (!selfNouns.some((noun) => rest.startsWith(noun) || rest.endsWith(noun))) return false;
119
+ return selfNouns.includes(rest) || !defined.some((other) => isSlipOf(term, other, prefix));
98
120
  };
99
121
  const runs = sentences.flatMap((tokens) =>
100
122
  tokens.flatMap((token, index) => {
@@ -106,8 +128,10 @@ export const undefinedTerms = (source: string, sentences: readonly (readonly Tok
106
128
  // A name that does not start a run of nouns (② 本研究の具体的な遂行方法) is an item of a list, not a term.
107
129
  const named = words.named.filter((term) => runs.some((run) => run.term.startsWith(term)));
108
130
  const known = knownForms([...defined, ...named], words.prefixGroups);
131
+ const terms = [...defined, ...runs.map((run) => run.term)];
109
132
  const uses = runs
110
133
  .filter((run) => !isSelf(run.term, run.prefix) && !words.isQuoted(run.term) && !isKnownUse(run.term, known, words.groupSuffixes))
134
+ .filter((run) => words.inheritsDefinitions !== true || terms.some((other) => isSlipOf(run.term, other, run.prefix)))
111
135
  .map((run) => ({ offset: run.offset, term: run.term }));
112
136
  return uses.filter((use, index) => uses.findIndex((other) => other.term === use.term) === index);
113
137
  };
@@ -167,6 +191,7 @@ export const undefinedTerm: Detector = (doc): Finding[] => {
167
191
  isQuoted: (term) => QUOTE_PAIRS.some(([open, close]) => doc.source.includes(`${open}${term}${close}`)),
168
192
  named: namedTerms(doc.source, prefixes),
169
193
  groupSuffixes: patternsOf(doc, "defined-term-group-suffix"),
194
+ inheritsDefinitions: patternsOf(doc, "definitions-inherited").some((phrase) => phrase !== "" && doc.source.includes(phrase)),
170
195
  });
171
196
  return [...prefixed, ...capitalisedUses(doc, sentences, definitions)].map((use) => findingOf(doc, use));
172
197
  };
@@ -1,7 +1,23 @@
1
- import type { Detector } from "../plugin.ts";
1
+ import type { Detector, Finding, Lexicon, ProseDocument } from "../plugin.ts";
2
2
  import { entriesForGenre } from "../lexicon-genres.ts";
3
3
  import { unfilledPlaceholder } from "./ai-phrasing.ts";
4
+ import { placeholderSpans } from "./placeholder-text.ts";
4
5
  import { TEMPLATE, isInside, templateSections } from "./template-sections.ts";
6
+ import { tableBodyCells } from "../facts/table-facts.ts";
7
+ import { proseAndTablesOf } from "../table-text.ts";
8
+
9
+ /** The prose covers tables, so a blank left in a cell (| Owner | [Name] |) is read from the cells themselves. */
10
+ const cellBlanks = (doc: ProseDocument, lexicon: Lexicon): Finding[] =>
11
+ tableBodyCells(proseAndTablesOf(doc)).flatMap((cell) =>
12
+ placeholderSpans(cell.text, lexicon).map((span) => ({
13
+ rule: "",
14
+ severity: "info" as const,
15
+ line: 0,
16
+ column: 0,
17
+ quote: cell.text.trim(),
18
+ values: { matched: cell.text.slice(span.start, span.end), offset: cell.start + span.start },
19
+ })),
20
+ );
5
21
 
6
22
  /**
7
23
  * A blank under a heading that names a template (Template, 雛形) is what the template is for, so it is not reported.
@@ -11,5 +27,7 @@ export const unfilledPlaceholderOutsideTemplates: Detector = (doc, options) => {
11
27
  const lexicon = entriesForGenre(options.lexicon ?? [], options.genre);
12
28
  const words = lexicon.filter((word) => word.group === TEMPLATE);
13
29
  const templates = templateSections(doc.markup?.headings ?? [], doc.source.length, words);
14
- return unfilledPlaceholder(doc, { ...options, lexicon }).filter((finding) => !isInside(templates, Number(finding.values["offset"])));
30
+ return [...unfilledPlaceholder(doc, { ...options, lexicon }), ...cellBlanks(doc, lexicon)]
31
+ .filter((finding) => !isInside(templates, Number(finding.values["offset"])))
32
+ .toSorted((left, right) => Number(left.values["offset"]) - Number(right.values["offset"]));
15
33
  };
@@ -110,3 +110,26 @@ export const usedOnce = (words: readonly CheckedWord[], speller: Speller): Check
110
110
  const shared = countsOf([...families.values()].flat());
111
111
  return words.filter(({ word }) => uses.get(word) === 1 && (families.get(word) ?? []).every((key) => shared.get(key) === 1));
112
112
  };
113
+
114
+ /** A release number of three parts or more (1.21.5, v2.0.1), after spaces. */
115
+ const VERSION_AFTER = /^[ \t]+v?\d+\.\d+\.\d+/u;
116
+
117
+ /** The word names what a release number follows (golang 1.21.5): a product or a tool, written as its makers write it. */
118
+ export const beforeVersion = (source: string, offset: number, word: string): boolean => VERSION_AFTER.test(source.slice(offset + word.length));
119
+
120
+ /** A journal's volume and issue (22 (3), 5(2)), after spaces. */
121
+ const VOLUME_AFTER = /^[ \t]+\d+[ \t]*\(\d+\)/u;
122
+
123
+ /** The word ends a journal's title before its volume and issue (Biochemia medica 22 (3)): the title as the journal writes it, often Latin. */
124
+ export const beforeVolume = (source: string, offset: number, word: string): boolean => VOLUME_AFTER.test(source.slice(offset + word.length));
125
+
126
+ /** Two words of one length that differ in one letter only. */
127
+ const oneLetterApart = (left: string, right: string): boolean =>
128
+ left.length === right.length && [...left].filter((letter, index) => letter !== right.charAt(index)).length === 1;
129
+
130
+ /**
131
+ * Another word of the document, itself not in the dictionary, one letter from this one (pthread and bthread): a family of
132
+ * names built on one scheme. A slip is one letter from a word the dictionary knows, and two slips seldom make such a pair.
133
+ */
134
+ export const hasSiblingName = (word: string, unknownWords: ReadonlySet<string>): boolean =>
135
+ [...unknownWords].some((other) => other !== word && oneLetterApart(word, other));
@@ -3,7 +3,18 @@ import { hasTwoEndings, isKnownWord, isSplitWord, suggestionFor, wordsToCheck, t
3
3
  import { parse } from "../markdown-read.ts";
4
4
  import { eachPreOrder } from "../tree-walk.ts";
5
5
  import { quoteAt } from "./structure-tree.ts";
6
- import { addressWordsOf, besideForeignWord, hasDrugStem, inSearchTermList, isClosedCompound, isMention, usedOnce } from "./unknown-word-context.ts";
6
+ import {
7
+ addressWordsOf,
8
+ beforeVersion,
9
+ beforeVolume,
10
+ besideForeignWord,
11
+ hasDrugStem,
12
+ hasSiblingName,
13
+ inSearchTermList,
14
+ isClosedCompound,
15
+ isMention,
16
+ usedOnce,
17
+ } from "./unknown-word-context.ts";
7
18
 
8
19
  /** これより短い語は見ない。短い語は一字違いの語が多すぎて言い直しが決まらず(tost は test か toast か)、略した語(impl)も多い。 */
9
20
  const MIN_LENGTH = 5;
@@ -43,9 +54,16 @@ export const codeWordsOf = (source: string): Set<string> => {
43
54
  /** 辞書の語か、派生した語に活用の語尾を付けた語(operationalises、rightsized)か、四字以上の辞書の語二つを続けた語(crowdwork)。 */
44
55
  const isFormedWord = (word: string, speller: Speller): boolean => isKnownWord(word, speller) || hasTwoEndings(word, speller) || isClosedCompound(word, speller);
45
56
 
46
- /** 置かれた場所から、名前や用語と分かる語。名指した語("mailto"、(jchaplin))、検索語の並び(vaccin*)、外国語の句(bête noire)。 */
57
+ /**
58
+ * 置かれた場所から、名前や用語と分かる語。名指した語("mailto"、(jchaplin))、検索語の並び(vaccin*)、外国語の句(bête noire)、
59
+ * 版の番号の前(golang 1.21.5)、誌の巻と号の前(Biochemia medica 22 (3))。
60
+ */
47
61
  const isTermByPlace = (source: string, offset: number, word: string): boolean =>
48
- isMention(source, offset, word) || inSearchTermList(source, offset) || besideForeignWord(source, offset, word);
62
+ isMention(source, offset, word) ||
63
+ inSearchTermList(source, offset) ||
64
+ besideForeignWord(source, offset, word) ||
65
+ beforeVersion(source, offset, word) ||
66
+ beforeVolume(source, offset, word);
49
67
 
50
68
  /**
51
69
  * 辞書に無い英語の語で、一字違いの辞書の語があるもの(recieve → receive)。辞書は adapter が持ち、無い言語では動かない。
@@ -59,8 +77,9 @@ export const unknownWord: Detector = (doc): Finding[] => {
59
77
  const drugStems = patternsOf(doc, "drug-stem");
60
78
  const words = wordsToCheck(doc.prose ?? doc.source, MIN_LENGTH, MAX_LENGTH).filter(({ offset }) => !isSplitWord(doc.source, offset));
61
79
  const used = new Set(words.map(({ word }) => word).filter((word) => isKnownWord(word, speller)));
80
+ const unformed = new Set(words.map(({ word }) => word).filter((word) => !known.has(word) && !isFormedWord(word, speller)));
62
81
  return usedOnce(words, speller).flatMap(({ offset, word }) => {
63
- if (known.has(word) || isFormedWord(word, speller) || hasDrugStem(word, drugStems) || isTermByPlace(doc.source, offset, word)) return [];
82
+ if (!unformed.has(word) || hasDrugStem(word, drugStems) || hasSiblingName(word, unformed) || isTermByPlace(doc.source, offset, word)) return [];
64
83
  const suggestion = suggestionFor(word, speller, used);
65
84
  if (suggestion === undefined) return [];
66
85
  return [{ rule: "", severity: "warning", line: 0, column: 0, quote: quoteAt(doc.source, offset), values: { word, suggestion, offset } }];