chaffjs 0.43.0 → 0.45.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 (348) hide show
  1. package/dist/bound-word-particles.d.ts +9 -0
  2. package/dist/bound-word-particles.d.ts.map +1 -0
  3. package/dist/bound-word-particles.js +16 -0
  4. package/dist/bound-word-particles.js.map +1 -0
  5. package/dist/derived/stays.d.ts +0 -1
  6. package/dist/derived/stays.d.ts.map +1 -1
  7. package/dist/derived/stays.js +3 -1
  8. package/dist/derived/stays.js.map +1 -1
  9. package/dist/detectors/absolute-exception.d.ts.map +1 -1
  10. package/dist/detectors/absolute-exception.js +10 -4
  11. package/dist/detectors/absolute-exception.js.map +1 -1
  12. package/dist/detectors/abstract-length.d.ts +5 -1
  13. package/dist/detectors/abstract-length.d.ts.map +1 -1
  14. package/dist/detectors/abstract-length.js +13 -5
  15. package/dist/detectors/abstract-length.js.map +1 -1
  16. package/dist/detectors/adversative-ga.d.ts +1 -1
  17. package/dist/detectors/adversative-ga.d.ts.map +1 -1
  18. package/dist/detectors/adversative-ga.js +19 -2
  19. package/dist/detectors/adversative-ga.js.map +1 -1
  20. package/dist/detectors/agreement-slip.d.ts +2 -0
  21. package/dist/detectors/agreement-slip.d.ts.map +1 -1
  22. package/dist/detectors/agreement-slip.js +22 -8
  23. package/dist/detectors/agreement-slip.js.map +1 -1
  24. package/dist/detectors/bold-label.d.ts +5 -1
  25. package/dist/detectors/bold-label.d.ts.map +1 -1
  26. package/dist/detectors/bold-label.js +74 -14
  27. package/dist/detectors/bold-label.js.map +1 -1
  28. package/dist/detectors/bold-quoted.d.ts +4 -0
  29. package/dist/detectors/bold-quoted.d.ts.map +1 -0
  30. package/dist/detectors/bold-quoted.js +17 -0
  31. package/dist/detectors/bold-quoted.js.map +1 -0
  32. package/dist/detectors/caps-caption.d.ts +5 -0
  33. package/dist/detectors/caps-caption.d.ts.map +1 -1
  34. package/dist/detectors/caps-caption.js +7 -0
  35. package/dist/detectors/caps-caption.js.map +1 -1
  36. package/dist/detectors/char-shape.d.ts +0 -6
  37. package/dist/detectors/char-shape.d.ts.map +1 -1
  38. package/dist/detectors/char-shape.js +4 -21
  39. package/dist/detectors/char-shape.js.map +1 -1
  40. package/dist/detectors/clause-shape.d.ts +2 -0
  41. package/dist/detectors/clause-shape.d.ts.map +1 -1
  42. package/dist/detectors/clause-shape.js +11 -2
  43. package/dist/detectors/clause-shape.js.map +1 -1
  44. package/dist/detectors/cleft-focus.d.ts +4 -0
  45. package/dist/detectors/cleft-focus.d.ts.map +1 -0
  46. package/dist/detectors/cleft-focus.js +31 -0
  47. package/dist/detectors/cleft-focus.js.map +1 -0
  48. package/dist/detectors/count-per-section.d.ts.map +1 -1
  49. package/dist/detectors/count-per-section.js +7 -4
  50. package/dist/detectors/count-per-section.js.map +1 -1
  51. package/dist/detectors/defined-term-form.d.ts.map +1 -1
  52. package/dist/detectors/defined-term-form.js +2 -1
  53. package/dist/detectors/defined-term-form.js.map +1 -1
  54. package/dist/detectors/definition-use.d.ts.map +1 -1
  55. package/dist/detectors/definition-use.js +13 -3
  56. package/dist/detectors/definition-use.js.map +1 -1
  57. package/dist/detectors/emoticon.d.ts +6 -0
  58. package/dist/detectors/emoticon.d.ts.map +1 -0
  59. package/dist/detectors/emoticon.js +19 -0
  60. package/dist/detectors/emoticon.js.map +1 -0
  61. package/dist/detectors/empty-section.d.ts +1 -1
  62. package/dist/detectors/empty-section.d.ts.map +1 -1
  63. package/dist/detectors/empty-section.js +3 -2
  64. package/dist/detectors/empty-section.js.map +1 -1
  65. package/dist/detectors/en-shape.d.ts +6 -1
  66. package/dist/detectors/en-shape.d.ts.map +1 -1
  67. package/dist/detectors/en-shape.js +9 -1
  68. package/dist/detectors/en-shape.js.map +1 -1
  69. package/dist/detectors/fullwidth-alnum.d.ts +2 -2
  70. package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
  71. package/dist/detectors/fullwidth-alnum.js +19 -3
  72. package/dist/detectors/fullwidth-alnum.js.map +1 -1
  73. package/dist/detectors/heading-echo.d.ts.map +1 -1
  74. package/dist/detectors/heading-echo.js +20 -7
  75. package/dist/detectors/heading-echo.js.map +1 -1
  76. package/dist/detectors/heading-number.d.ts +7 -0
  77. package/dist/detectors/heading-number.d.ts.map +1 -0
  78. package/dist/detectors/heading-number.js +21 -0
  79. package/dist/detectors/heading-number.js.map +1 -0
  80. package/dist/detectors/katakana-density.d.ts +6 -1
  81. package/dist/detectors/katakana-density.d.ts.map +1 -1
  82. package/dist/detectors/katakana-density.js +14 -1
  83. package/dist/detectors/katakana-density.js.map +1 -1
  84. package/dist/detectors/lexicon.d.ts.map +1 -1
  85. package/dist/detectors/lexicon.js +2 -1
  86. package/dist/detectors/lexicon.js.map +1 -1
  87. package/dist/detectors/lookalike-character.d.ts +2 -1
  88. package/dist/detectors/lookalike-character.d.ts.map +1 -1
  89. package/dist/detectors/lookalike-character.js +14 -1
  90. package/dist/detectors/lookalike-character.js.map +1 -1
  91. package/dist/detectors/mark-shape.d.ts +8 -3
  92. package/dist/detectors/mark-shape.d.ts.map +1 -1
  93. package/dist/detectors/mark-shape.js +55 -16
  94. package/dist/detectors/mark-shape.js.map +1 -1
  95. package/dist/detectors/mentioned-phrase.d.ts +3 -1
  96. package/dist/detectors/mentioned-phrase.d.ts.map +1 -1
  97. package/dist/detectors/mentioned-phrase.js +9 -0
  98. package/dist/detectors/mentioned-phrase.js.map +1 -1
  99. package/dist/detectors/middle-dot.d.ts +7 -0
  100. package/dist/detectors/middle-dot.d.ts.map +1 -1
  101. package/dist/detectors/middle-dot.js +19 -0
  102. package/dist/detectors/middle-dot.js.map +1 -1
  103. package/dist/detectors/named-by-context.d.ts +13 -0
  104. package/dist/detectors/named-by-context.d.ts.map +1 -0
  105. package/dist/detectors/named-by-context.js +10 -0
  106. package/dist/detectors/named-by-context.js.map +1 -0
  107. package/dist/detectors/number-style.d.ts.map +1 -1
  108. package/dist/detectors/number-style.js +13 -1
  109. package/dist/detectors/number-style.js.map +1 -1
  110. package/dist/detectors/obligation-without-deadline.d.ts +10 -2
  111. package/dist/detectors/obligation-without-deadline.d.ts.map +1 -1
  112. package/dist/detectors/obligation-without-deadline.js +47 -2
  113. package/dist/detectors/obligation-without-deadline.js.map +1 -1
  114. package/dist/detectors/open-end-names.d.ts +2 -0
  115. package/dist/detectors/open-end-names.d.ts.map +1 -1
  116. package/dist/detectors/open-end-names.js +8 -1
  117. package/dist/detectors/open-end-names.js.map +1 -1
  118. package/dist/detectors/orthographic-variant.d.ts.map +1 -1
  119. package/dist/detectors/orthographic-variant.js +5 -3
  120. package/dist/detectors/orthographic-variant.js.map +1 -1
  121. package/dist/detectors/paragraph-pointer.d.ts +4 -0
  122. package/dist/detectors/paragraph-pointer.d.ts.map +1 -0
  123. package/dist/detectors/paragraph-pointer.js +22 -0
  124. package/dist/detectors/paragraph-pointer.js.map +1 -0
  125. package/dist/detectors/phrase-match.d.ts +4 -1
  126. package/dist/detectors/phrase-match.d.ts.map +1 -1
  127. package/dist/detectors/phrase-match.js +12 -5
  128. package/dist/detectors/phrase-match.js.map +1 -1
  129. package/dist/detectors/placeholder-context.d.ts +16 -0
  130. package/dist/detectors/placeholder-context.d.ts.map +1 -0
  131. package/dist/detectors/placeholder-context.js +57 -0
  132. package/dist/detectors/placeholder-context.js.map +1 -0
  133. package/dist/detectors/placeholder-text.d.ts +2 -0
  134. package/dist/detectors/placeholder-text.d.ts.map +1 -1
  135. package/dist/detectors/placeholder-text.js +1 -1
  136. package/dist/detectors/placeholder-text.js.map +1 -1
  137. package/dist/detectors/redundant-pair.d.ts +5 -0
  138. package/dist/detectors/redundant-pair.d.ts.map +1 -0
  139. package/dist/detectors/redundant-pair.js +18 -0
  140. package/dist/detectors/redundant-pair.js.map +1 -0
  141. package/dist/detectors/registry/middle-dot.js +1 -1
  142. package/dist/detectors/registry/redundant-pair.d.ts +3 -0
  143. package/dist/detectors/registry/redundant-pair.d.ts.map +1 -0
  144. package/dist/detectors/registry/redundant-pair.js +3 -0
  145. package/dist/detectors/registry/redundant-pair.js.map +1 -0
  146. package/dist/detectors/request-owner.d.ts +1 -0
  147. package/dist/detectors/request-owner.d.ts.map +1 -1
  148. package/dist/detectors/request-owner.js +6 -3
  149. package/dist/detectors/request-owner.js.map +1 -1
  150. package/dist/detectors/sentence-counts.d.ts +2 -0
  151. package/dist/detectors/sentence-counts.d.ts.map +1 -1
  152. package/dist/detectors/sentence-counts.js +13 -4
  153. package/dist/detectors/sentence-counts.js.map +1 -1
  154. package/dist/detectors/signals.d.ts.map +1 -1
  155. package/dist/detectors/signals.js +10 -1
  156. package/dist/detectors/signals.js.map +1 -1
  157. package/dist/detectors/structure-tree.d.ts.map +1 -1
  158. package/dist/detectors/structure-tree.js +1 -0
  159. package/dist/detectors/structure-tree.js.map +1 -1
  160. package/dist/detectors/structure.d.ts.map +1 -1
  161. package/dist/detectors/structure.js +6 -5
  162. package/dist/detectors/structure.js.map +1 -1
  163. package/dist/detectors/superlative-context.d.ts +7 -0
  164. package/dist/detectors/superlative-context.d.ts.map +1 -1
  165. package/dist/detectors/superlative-context.js +9 -0
  166. package/dist/detectors/superlative-context.js.map +1 -1
  167. package/dist/detectors/template-sections.d.ts +1 -0
  168. package/dist/detectors/template-sections.d.ts.map +1 -1
  169. package/dist/detectors/template-sections.js +1 -1
  170. package/dist/detectors/template-sections.js.map +1 -1
  171. package/dist/detectors/token-shape.d.ts.map +1 -1
  172. package/dist/detectors/token-shape.js +7 -5
  173. package/dist/detectors/token-shape.js.map +1 -1
  174. package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
  175. package/dist/detectors/unbalanced-bracket.js +2 -1
  176. package/dist/detectors/unbalanced-bracket.js.map +1 -1
  177. package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
  178. package/dist/detectors/unfilled-placeholder.js +18 -1
  179. package/dist/detectors/unfilled-placeholder.js.map +1 -1
  180. package/dist/detectors/verse-block.d.ts +4 -0
  181. package/dist/detectors/verse-block.d.ts.map +1 -0
  182. package/dist/detectors/verse-block.js +40 -0
  183. package/dist/detectors/verse-block.js.map +1 -0
  184. package/dist/document.d.ts.map +1 -1
  185. package/dist/document.js +1 -0
  186. package/dist/document.js.map +1 -1
  187. package/dist/email-parts.d.ts +2 -0
  188. package/dist/email-parts.d.ts.map +1 -1
  189. package/dist/email-parts.js +10 -7
  190. package/dist/email-parts.js.map +1 -1
  191. package/dist/eval.d.ts.map +1 -1
  192. package/dist/eval.js +3 -0
  193. package/dist/eval.js.map +1 -1
  194. package/dist/paragraph-length.d.ts +4 -0
  195. package/dist/paragraph-length.d.ts.map +1 -1
  196. package/dist/paragraph-length.js +6 -0
  197. package/dist/paragraph-length.js.map +1 -1
  198. package/dist/plugin.d.ts +4 -0
  199. package/dist/plugin.d.ts.map +1 -1
  200. package/dist/reasons.d.ts +2 -0
  201. package/dist/reasons.d.ts.map +1 -1
  202. package/dist/reasons.js +2 -0
  203. package/dist/reasons.js.map +1 -1
  204. package/dist/rule-of-three.d.ts +13 -1
  205. package/dist/rule-of-three.d.ts.map +1 -1
  206. package/dist/rule-of-three.js +32 -3
  207. package/dist/rule-of-three.js.map +1 -1
  208. package/dist/run.d.ts.map +1 -1
  209. package/dist/run.js +4 -1
  210. package/dist/run.js.map +1 -1
  211. package/dist/structure/build.d.ts.map +1 -1
  212. package/dist/structure/build.js +2 -1
  213. package/dist/structure/build.js.map +1 -1
  214. package/dist/structure/cited-elsewhere.d.ts +5 -2
  215. package/dist/structure/cited-elsewhere.d.ts.map +1 -1
  216. package/dist/structure/cited-elsewhere.js +16 -6
  217. package/dist/structure/cited-elsewhere.js.map +1 -1
  218. package/dist/structure/definition-use.d.ts +2 -1
  219. package/dist/structure/definition-use.d.ts.map +1 -1
  220. package/dist/structure/definition-use.js +10 -2
  221. package/dist/structure/definition-use.js.map +1 -1
  222. package/dist/structure/issues.js +1 -1
  223. package/dist/structure/issues.js.map +1 -1
  224. package/dist/structure/negated-act.d.ts +1 -0
  225. package/dist/structure/negated-act.d.ts.map +1 -1
  226. package/dist/structure/negated-act.js +1 -1
  227. package/dist/structure/negated-act.js.map +1 -1
  228. package/dist/structure/own-name.d.ts +4 -0
  229. package/dist/structure/own-name.d.ts.map +1 -0
  230. package/dist/structure/own-name.js +20 -0
  231. package/dist/structure/own-name.js.map +1 -0
  232. package/dist/structure/percent-sum-prose.d.ts.map +1 -1
  233. package/dist/structure/percent-sum-prose.js +9 -1
  234. package/dist/structure/percent-sum-prose.js.map +1 -1
  235. package/dist/structure/percent-sum.d.ts +2 -0
  236. package/dist/structure/percent-sum.d.ts.map +1 -1
  237. package/dist/structure/percent-sum.js.map +1 -1
  238. package/dist/structure/reference-text.d.ts.map +1 -1
  239. package/dist/structure/reference-text.js +3 -1
  240. package/dist/structure/reference-text.js.map +1 -1
  241. package/dist/te-form-helper.d.ts +22 -0
  242. package/dist/te-form-helper.d.ts.map +1 -0
  243. package/dist/te-form-helper.js +35 -0
  244. package/dist/te-form-helper.js.map +1 -0
  245. package/dist/word-use.d.ts +7 -0
  246. package/dist/word-use.d.ts.map +1 -1
  247. package/dist/word-use.js +11 -0
  248. package/dist/word-use.js.map +1 -1
  249. package/package.json +3 -3
  250. package/rules/absolute-exception.yaml +3 -3
  251. package/rules/abstract-length.yaml +2 -2
  252. package/rules/adversative-ga-repeat.yaml +2 -2
  253. package/rules/all-caps-shouting.yaml +2 -2
  254. package/rules/attachment-not-attached.yaml +11 -6
  255. package/rules/bold-label-list.yaml +29 -6
  256. package/rules/bracket-width-consistency.yaml +2 -2
  257. package/rules/demonstrative-opener-run.yaml +2 -2
  258. package/rules/duration-mismatch.yaml +2 -2
  259. package/rules/emoji-density.yaml +2 -2
  260. package/rules/empty-section.yaml +2 -2
  261. package/rules/fullwidth-alnum-consistency.yaml +2 -2
  262. package/rules/katakana-density.yaml +3 -3
  263. package/rules/lookalike-character.yaml +8 -5
  264. package/rules/max-kanji-continuous.yaml +4 -0
  265. package/rules/no-doubled-joshi.yaml +2 -2
  266. package/rules/number-style-consistency.yaml +2 -2
  267. package/rules/obligation-without-deadline.yaml +2 -2
  268. package/rules/padded-intro.yaml +1 -1
  269. package/rules/paragraph-length-variance.yaml +27 -3
  270. package/rules/redundant-expression.yaml +1 -1
  271. package/rules/repeated-sentence-ending.yaml +2 -2
  272. package/rules/request-without-deadline.yaml +2 -2
  273. package/rules/requirement-smell.yaml +2 -2
  274. package/rules/rule-of-three.yaml +2 -2
  275. package/rules/sentence-spacing-consistency.yaml +2 -2
  276. package/rules/teki-overuse.yaml +2 -0
  277. package/rules/unfilled-placeholder.yaml +2 -2
  278. package/rules/use-before-definition.yaml +2 -2
  279. package/src/bound-word-particles.ts +23 -0
  280. package/src/derived/stays.ts +4 -1
  281. package/src/detectors/absolute-exception.ts +11 -5
  282. package/src/detectors/abstract-length.ts +16 -6
  283. package/src/detectors/adversative-ga.ts +24 -2
  284. package/src/detectors/agreement-slip.ts +35 -10
  285. package/src/detectors/bold-label.ts +82 -14
  286. package/src/detectors/bold-quoted.ts +21 -0
  287. package/src/detectors/caps-caption.ts +10 -0
  288. package/src/detectors/char-shape.ts +8 -22
  289. package/src/detectors/clause-shape.ts +14 -3
  290. package/src/detectors/cleft-focus.ts +40 -0
  291. package/src/detectors/count-per-section.ts +9 -4
  292. package/src/detectors/defined-term-form.ts +2 -1
  293. package/src/detectors/definition-use.ts +23 -4
  294. package/src/detectors/emoticon.ts +21 -0
  295. package/src/detectors/empty-section.ts +3 -2
  296. package/src/detectors/en-shape.ts +10 -1
  297. package/src/detectors/fullwidth-alnum.ts +24 -3
  298. package/src/detectors/heading-echo.ts +21 -8
  299. package/src/detectors/heading-number.ts +20 -0
  300. package/src/detectors/katakana-density.ts +17 -2
  301. package/src/detectors/lexicon.ts +2 -1
  302. package/src/detectors/lookalike-character.ts +19 -2
  303. package/src/detectors/mark-shape.ts +61 -13
  304. package/src/detectors/mentioned-phrase.ts +13 -1
  305. package/src/detectors/middle-dot.ts +22 -0
  306. package/src/detectors/named-by-context.ts +15 -0
  307. package/src/detectors/number-style.ts +14 -1
  308. package/src/detectors/obligation-without-deadline.ts +69 -5
  309. package/src/detectors/open-end-names.ts +21 -2
  310. package/src/detectors/orthographic-variant.ts +20 -15
  311. package/src/detectors/paragraph-pointer.ts +28 -0
  312. package/src/detectors/phrase-match.ts +13 -5
  313. package/src/detectors/placeholder-context.ts +72 -0
  314. package/src/detectors/placeholder-text.ts +1 -1
  315. package/src/detectors/redundant-pair.ts +25 -0
  316. package/src/detectors/registry/middle-dot.ts +1 -1
  317. package/src/detectors/registry/redundant-pair.ts +4 -0
  318. package/src/detectors/request-owner.ts +6 -3
  319. package/src/detectors/sentence-counts.ts +16 -4
  320. package/src/detectors/signals.ts +11 -1
  321. package/src/detectors/structure-tree.ts +1 -0
  322. package/src/detectors/structure.ts +6 -5
  323. package/src/detectors/superlative-context.ts +12 -0
  324. package/src/detectors/template-sections.ts +1 -1
  325. package/src/detectors/token-shape.ts +10 -7
  326. package/src/detectors/unbalanced-bracket.ts +2 -1
  327. package/src/detectors/unfilled-placeholder.ts +22 -1
  328. package/src/detectors/verse-block.ts +48 -0
  329. package/src/document.ts +1 -0
  330. package/src/email-parts.ts +16 -7
  331. package/src/eval.ts +2 -0
  332. package/src/paragraph-length.ts +10 -0
  333. package/src/plugin.ts +4 -0
  334. package/src/reasons.ts +4 -0
  335. package/src/rule-of-three.ts +47 -4
  336. package/src/run.ts +3 -1
  337. package/src/structure/build.ts +2 -1
  338. package/src/structure/cited-elsewhere.ts +18 -6
  339. package/src/structure/definition-use.ts +10 -1
  340. package/src/structure/issues.ts +1 -1
  341. package/src/structure/negated-act.ts +1 -1
  342. package/src/structure/own-name.ts +28 -0
  343. package/src/structure/percent-sum-prose.ts +12 -1
  344. package/src/structure/percent-sum.ts +2 -0
  345. package/src/structure/reference-text.ts +5 -1
  346. package/src/te-form-helper.ts +52 -0
  347. package/src/word-use.ts +13 -0
  348. package/src/honorific-group.ts +0 -22
@@ -0,0 +1,52 @@
1
+ import type { Token } from "./plugin.ts";
2
+ import { isHelperByTeFormOnly, teFormVerbOf, type InContext } from "./word-use.ts";
3
+
4
+ // orthographic-variant: a kanji verb after a て-form is the helper (書いて見る) or the next act (並んで見た), and the form alone
5
+ // cannot tell. These decide which, from the document's own spellings.
6
+
7
+ /** Where a word stands after a て-form. */
8
+ export type TeForm = {
9
+ /** A full verb read as a helper only for the て-form before it, whose verb takes no object (並んで見た). */
10
+ readonly teFormOnly?: boolean;
11
+ /** The verb whose て-form stands before it (まとめる in まとめてみる). */
12
+ readonly teVerb?: string;
13
+ };
14
+
15
+ type KeyedTeWord = TeForm & { readonly key: string; readonly spelling: string };
16
+
17
+ const OBJECT_PARTICLE = "を";
18
+
19
+ /** The て-form verb takes an object (芽を残して置く): the verb after it has none of its own, and is the helper. */
20
+ const teVerbHasObject = (word: InContext, tokens: readonly Token[], at: number): boolean => {
21
+ const teVerbAt = word.previous?.pos === "SCONJ" ? at - 2 : at - 1;
22
+ const particle = tokens[teVerbAt - 1];
23
+ return particle?.pos === "ADP" && particle.surface === OBJECT_PARTICLE;
24
+ };
25
+
26
+ export const teFormOf = (word: InContext, tokens: readonly Token[], at: number): TeForm => {
27
+ const teVerb = teFormVerbOf(word);
28
+ const doubtful = isHelperByTeFormOnly(word) && !teVerbHasObject(word, tokens, at);
29
+ return { ...(doubtful ? { teFormOnly: true } : {}), ...(teVerb === undefined ? {} : { teVerb }) };
30
+ };
31
+
32
+ const BOUND_USE = "|bound|";
33
+ const FREE_USE = "|free|";
34
+
35
+ /**
36
+ * A verb after a て-form that may be the helper or the next act (並んで見た) is read as the full verb where the document writes
37
+ * the full verb that way and its sure helpers (投資してみる) the other way: the writer keeps the helper in kana on purpose. It stays
38
+ * a helper where the same verb takes the sure helper elsewhere (まとめてみました beside まとめて見ました).
39
+ */
40
+ export const withTeFormFullVerbs = <Word extends KeyedTeWord>(words: readonly Word[]): Word[] => {
41
+ const sureOf = (key: string): Word[] => words.filter((word) => word.key === key && word.teFormOnly !== true);
42
+ const freeSpellingsOf = (key: string): Set<string> => new Set(words.filter((word) => word.key === key).map((word) => word.spelling));
43
+ return words.map((word) => {
44
+ if (word.teFormOnly !== true || !word.key.includes(BOUND_USE)) return word;
45
+ const freeKey = word.key.replace(BOUND_USE, FREE_USE);
46
+ const sure = sureOf(word.key);
47
+ const sureSpellings = new Set(sure.map((helper) => helper.spelling));
48
+ const helpsSameVerb = sure.some((helper) => helper.teVerb !== undefined && helper.teVerb === word.teVerb);
49
+ const isFullVerbSpelling = freeSpellingsOf(freeKey).has(word.spelling) && sure.length > 0 && !sureSpellings.has(word.spelling) && !helpsSameVerb;
50
+ return isFullVerbSpelling ? { ...word, key: freeKey } : word;
51
+ });
52
+ };
package/src/word-use.ts CHANGED
@@ -35,6 +35,19 @@ const negatesAfterTopic = ({ token, previous, before }: InContext): boolean =>
35
35
 
36
36
  const isHelper = (word: InContext): boolean => word.token.features?.["Bound"] === "Yes" || followsTeForm(word.previous) || negatesAfterTopic(word);
37
37
 
38
+ /**
39
+ * A verb the tokenizer reads as a full verb, taken for a helper only because a て-form stands before it: 見た in 並んで見た is
40
+ * the next act, 見る in 書いて見る a helper, and the form cannot tell them apart.
41
+ */
42
+ export const isHelperByTeFormOnly = (word: InContext): boolean =>
43
+ word.token.pos === "VERB" && word.token.features?.["Bound"] !== "Yes" && followsTeForm(word.previous);
44
+
45
+ /** The verb whose て-form stands before the word (まとめる in まとめてみる), or undefined after no て-form. */
46
+ export const teFormVerbOf = ({ previous, before }: InContext): string | undefined => {
47
+ if (!followsTeForm(previous)) return undefined;
48
+ return (previous?.pos === "SCONJ" ? before : previous)?.lemma;
49
+ };
50
+
38
51
  export const isTouching = (left: Token | undefined, right: Token): boolean => left !== undefined && left.span.end === right.span.start;
39
52
 
40
53
  export const HIRAGANA_ONLY = /^[ぁ-ゖー]+$/u;
@@ -1,22 +0,0 @@
1
- import type { Token } from "./plugin.ts";
2
-
3
- const touches = (left: Token | undefined, right: Token | undefined): boolean => left !== undefined && right !== undefined && left.span.end === right.span.start;
4
-
5
- /**
6
- * 人の集まりを敬って呼ぶ語(皆様、方々)の直前の助詞で、呼び方がさらに同じ助詞で次の語に係るもの。「国民の皆様の期待」の
7
- * 「国民の皆様」は一つの呼び方として次の語に係り、その中の「の」は入れ子を深くしない。呼び方で連なりが終わるとき
8
- * (それ以外の全てのVim使いの皆様が)は、呼び方が連なりの頭の語なので数える。particles は数える助詞(の)、groups は呼び方の語(皆様)。
9
- */
10
- export const honorificGroupParticles = (tokens: readonly Token[], particles: readonly string[], groups: readonly string[]): ReadonlySet<Token> =>
11
- new Set(
12
- tokens.filter((token, at) => {
13
- const [group, after] = [tokens[at + 1], tokens[at + 2]];
14
- return (
15
- particles.includes(token.surface) &&
16
- groups.includes(group?.surface ?? "") &&
17
- touches(token, group) &&
18
- touches(group, after) &&
19
- particles.includes(after?.surface ?? "")
20
- );
21
- }),
22
- );