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.
- package/dist/bound-word-particles.d.ts +9 -0
- package/dist/bound-word-particles.d.ts.map +1 -0
- package/dist/bound-word-particles.js +16 -0
- package/dist/bound-word-particles.js.map +1 -0
- package/dist/derived/stays.d.ts +0 -1
- package/dist/derived/stays.d.ts.map +1 -1
- package/dist/derived/stays.js +3 -1
- package/dist/derived/stays.js.map +1 -1
- package/dist/detectors/absolute-exception.d.ts.map +1 -1
- package/dist/detectors/absolute-exception.js +10 -4
- package/dist/detectors/absolute-exception.js.map +1 -1
- package/dist/detectors/abstract-length.d.ts +5 -1
- package/dist/detectors/abstract-length.d.ts.map +1 -1
- package/dist/detectors/abstract-length.js +13 -5
- package/dist/detectors/abstract-length.js.map +1 -1
- package/dist/detectors/adversative-ga.d.ts +1 -1
- package/dist/detectors/adversative-ga.d.ts.map +1 -1
- package/dist/detectors/adversative-ga.js +19 -2
- package/dist/detectors/adversative-ga.js.map +1 -1
- package/dist/detectors/agreement-slip.d.ts +2 -0
- package/dist/detectors/agreement-slip.d.ts.map +1 -1
- package/dist/detectors/agreement-slip.js +22 -8
- package/dist/detectors/agreement-slip.js.map +1 -1
- package/dist/detectors/bold-label.d.ts +5 -1
- package/dist/detectors/bold-label.d.ts.map +1 -1
- package/dist/detectors/bold-label.js +74 -14
- package/dist/detectors/bold-label.js.map +1 -1
- package/dist/detectors/bold-quoted.d.ts +4 -0
- package/dist/detectors/bold-quoted.d.ts.map +1 -0
- package/dist/detectors/bold-quoted.js +17 -0
- package/dist/detectors/bold-quoted.js.map +1 -0
- package/dist/detectors/caps-caption.d.ts +5 -0
- package/dist/detectors/caps-caption.d.ts.map +1 -1
- package/dist/detectors/caps-caption.js +7 -0
- package/dist/detectors/caps-caption.js.map +1 -1
- package/dist/detectors/char-shape.d.ts +0 -6
- package/dist/detectors/char-shape.d.ts.map +1 -1
- package/dist/detectors/char-shape.js +4 -21
- package/dist/detectors/char-shape.js.map +1 -1
- package/dist/detectors/clause-shape.d.ts +2 -0
- package/dist/detectors/clause-shape.d.ts.map +1 -1
- package/dist/detectors/clause-shape.js +11 -2
- package/dist/detectors/clause-shape.js.map +1 -1
- package/dist/detectors/cleft-focus.d.ts +4 -0
- package/dist/detectors/cleft-focus.d.ts.map +1 -0
- package/dist/detectors/cleft-focus.js +31 -0
- package/dist/detectors/cleft-focus.js.map +1 -0
- package/dist/detectors/count-per-section.d.ts.map +1 -1
- package/dist/detectors/count-per-section.js +7 -4
- package/dist/detectors/count-per-section.js.map +1 -1
- package/dist/detectors/defined-term-form.d.ts.map +1 -1
- package/dist/detectors/defined-term-form.js +2 -1
- package/dist/detectors/defined-term-form.js.map +1 -1
- package/dist/detectors/definition-use.d.ts.map +1 -1
- package/dist/detectors/definition-use.js +13 -3
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/emoticon.d.ts +6 -0
- package/dist/detectors/emoticon.d.ts.map +1 -0
- package/dist/detectors/emoticon.js +19 -0
- package/dist/detectors/emoticon.js.map +1 -0
- package/dist/detectors/empty-section.d.ts +1 -1
- package/dist/detectors/empty-section.d.ts.map +1 -1
- package/dist/detectors/empty-section.js +3 -2
- package/dist/detectors/empty-section.js.map +1 -1
- package/dist/detectors/en-shape.d.ts +6 -1
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +9 -1
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/fullwidth-alnum.d.ts +2 -2
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
- package/dist/detectors/fullwidth-alnum.js +19 -3
- package/dist/detectors/fullwidth-alnum.js.map +1 -1
- package/dist/detectors/heading-echo.d.ts.map +1 -1
- package/dist/detectors/heading-echo.js +20 -7
- package/dist/detectors/heading-echo.js.map +1 -1
- package/dist/detectors/heading-number.d.ts +7 -0
- package/dist/detectors/heading-number.d.ts.map +1 -0
- package/dist/detectors/heading-number.js +21 -0
- package/dist/detectors/heading-number.js.map +1 -0
- package/dist/detectors/katakana-density.d.ts +6 -1
- package/dist/detectors/katakana-density.d.ts.map +1 -1
- package/dist/detectors/katakana-density.js +14 -1
- package/dist/detectors/katakana-density.js.map +1 -1
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +2 -1
- package/dist/detectors/lexicon.js.map +1 -1
- package/dist/detectors/lookalike-character.d.ts +2 -1
- package/dist/detectors/lookalike-character.d.ts.map +1 -1
- package/dist/detectors/lookalike-character.js +14 -1
- package/dist/detectors/lookalike-character.js.map +1 -1
- package/dist/detectors/mark-shape.d.ts +8 -3
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +55 -16
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/mentioned-phrase.d.ts +3 -1
- package/dist/detectors/mentioned-phrase.d.ts.map +1 -1
- package/dist/detectors/mentioned-phrase.js +9 -0
- package/dist/detectors/mentioned-phrase.js.map +1 -1
- package/dist/detectors/middle-dot.d.ts +7 -0
- package/dist/detectors/middle-dot.d.ts.map +1 -1
- package/dist/detectors/middle-dot.js +19 -0
- package/dist/detectors/middle-dot.js.map +1 -1
- package/dist/detectors/named-by-context.d.ts +13 -0
- package/dist/detectors/named-by-context.d.ts.map +1 -0
- package/dist/detectors/named-by-context.js +10 -0
- package/dist/detectors/named-by-context.js.map +1 -0
- package/dist/detectors/number-style.d.ts.map +1 -1
- package/dist/detectors/number-style.js +13 -1
- package/dist/detectors/number-style.js.map +1 -1
- package/dist/detectors/obligation-without-deadline.d.ts +10 -2
- package/dist/detectors/obligation-without-deadline.d.ts.map +1 -1
- package/dist/detectors/obligation-without-deadline.js +47 -2
- package/dist/detectors/obligation-without-deadline.js.map +1 -1
- package/dist/detectors/open-end-names.d.ts +2 -0
- package/dist/detectors/open-end-names.d.ts.map +1 -1
- package/dist/detectors/open-end-names.js +8 -1
- package/dist/detectors/open-end-names.js.map +1 -1
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +5 -3
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/paragraph-pointer.d.ts +4 -0
- package/dist/detectors/paragraph-pointer.d.ts.map +1 -0
- package/dist/detectors/paragraph-pointer.js +22 -0
- package/dist/detectors/paragraph-pointer.js.map +1 -0
- package/dist/detectors/phrase-match.d.ts +4 -1
- package/dist/detectors/phrase-match.d.ts.map +1 -1
- package/dist/detectors/phrase-match.js +12 -5
- package/dist/detectors/phrase-match.js.map +1 -1
- package/dist/detectors/placeholder-context.d.ts +16 -0
- package/dist/detectors/placeholder-context.d.ts.map +1 -0
- package/dist/detectors/placeholder-context.js +57 -0
- package/dist/detectors/placeholder-context.js.map +1 -0
- package/dist/detectors/placeholder-text.d.ts +2 -0
- package/dist/detectors/placeholder-text.d.ts.map +1 -1
- package/dist/detectors/placeholder-text.js +1 -1
- package/dist/detectors/placeholder-text.js.map +1 -1
- package/dist/detectors/redundant-pair.d.ts +5 -0
- package/dist/detectors/redundant-pair.d.ts.map +1 -0
- package/dist/detectors/redundant-pair.js +18 -0
- package/dist/detectors/redundant-pair.js.map +1 -0
- package/dist/detectors/registry/middle-dot.js +1 -1
- package/dist/detectors/registry/redundant-pair.d.ts +3 -0
- package/dist/detectors/registry/redundant-pair.d.ts.map +1 -0
- package/dist/detectors/registry/redundant-pair.js +3 -0
- package/dist/detectors/registry/redundant-pair.js.map +1 -0
- package/dist/detectors/request-owner.d.ts +1 -0
- package/dist/detectors/request-owner.d.ts.map +1 -1
- package/dist/detectors/request-owner.js +6 -3
- package/dist/detectors/request-owner.js.map +1 -1
- package/dist/detectors/sentence-counts.d.ts +2 -0
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +13 -4
- package/dist/detectors/sentence-counts.js.map +1 -1
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +10 -1
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +1 -0
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/structure.d.ts.map +1 -1
- package/dist/detectors/structure.js +6 -5
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/superlative-context.d.ts +7 -0
- package/dist/detectors/superlative-context.d.ts.map +1 -1
- package/dist/detectors/superlative-context.js +9 -0
- package/dist/detectors/superlative-context.js.map +1 -1
- package/dist/detectors/template-sections.d.ts +1 -0
- package/dist/detectors/template-sections.d.ts.map +1 -1
- package/dist/detectors/template-sections.js +1 -1
- package/dist/detectors/template-sections.js.map +1 -1
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +7 -5
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
- package/dist/detectors/unbalanced-bracket.js +2 -1
- package/dist/detectors/unbalanced-bracket.js.map +1 -1
- package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
- package/dist/detectors/unfilled-placeholder.js +18 -1
- package/dist/detectors/unfilled-placeholder.js.map +1 -1
- package/dist/detectors/verse-block.d.ts +4 -0
- package/dist/detectors/verse-block.d.ts.map +1 -0
- package/dist/detectors/verse-block.js +40 -0
- package/dist/detectors/verse-block.js.map +1 -0
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +1 -0
- package/dist/document.js.map +1 -1
- package/dist/email-parts.d.ts +2 -0
- package/dist/email-parts.d.ts.map +1 -1
- package/dist/email-parts.js +10 -7
- package/dist/email-parts.js.map +1 -1
- package/dist/eval.d.ts.map +1 -1
- package/dist/eval.js +3 -0
- package/dist/eval.js.map +1 -1
- package/dist/paragraph-length.d.ts +4 -0
- package/dist/paragraph-length.d.ts.map +1 -1
- package/dist/paragraph-length.js +6 -0
- package/dist/paragraph-length.js.map +1 -1
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/reasons.d.ts +2 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +2 -0
- package/dist/reasons.js.map +1 -1
- package/dist/rule-of-three.d.ts +13 -1
- package/dist/rule-of-three.d.ts.map +1 -1
- package/dist/rule-of-three.js +32 -3
- package/dist/rule-of-three.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -1
- package/dist/run.js.map +1 -1
- package/dist/structure/build.d.ts.map +1 -1
- package/dist/structure/build.js +2 -1
- package/dist/structure/build.js.map +1 -1
- package/dist/structure/cited-elsewhere.d.ts +5 -2
- package/dist/structure/cited-elsewhere.d.ts.map +1 -1
- package/dist/structure/cited-elsewhere.js +16 -6
- package/dist/structure/cited-elsewhere.js.map +1 -1
- package/dist/structure/definition-use.d.ts +2 -1
- package/dist/structure/definition-use.d.ts.map +1 -1
- package/dist/structure/definition-use.js +10 -2
- package/dist/structure/definition-use.js.map +1 -1
- package/dist/structure/issues.js +1 -1
- package/dist/structure/issues.js.map +1 -1
- package/dist/structure/negated-act.d.ts +1 -0
- package/dist/structure/negated-act.d.ts.map +1 -1
- package/dist/structure/negated-act.js +1 -1
- package/dist/structure/negated-act.js.map +1 -1
- package/dist/structure/own-name.d.ts +4 -0
- package/dist/structure/own-name.d.ts.map +1 -0
- package/dist/structure/own-name.js +20 -0
- package/dist/structure/own-name.js.map +1 -0
- package/dist/structure/percent-sum-prose.d.ts.map +1 -1
- package/dist/structure/percent-sum-prose.js +9 -1
- package/dist/structure/percent-sum-prose.js.map +1 -1
- package/dist/structure/percent-sum.d.ts +2 -0
- package/dist/structure/percent-sum.d.ts.map +1 -1
- package/dist/structure/percent-sum.js.map +1 -1
- package/dist/structure/reference-text.d.ts.map +1 -1
- package/dist/structure/reference-text.js +3 -1
- package/dist/structure/reference-text.js.map +1 -1
- package/dist/te-form-helper.d.ts +22 -0
- package/dist/te-form-helper.d.ts.map +1 -0
- package/dist/te-form-helper.js +35 -0
- package/dist/te-form-helper.js.map +1 -0
- package/dist/word-use.d.ts +7 -0
- package/dist/word-use.d.ts.map +1 -1
- package/dist/word-use.js +11 -0
- package/dist/word-use.js.map +1 -1
- package/package.json +3 -3
- package/rules/absolute-exception.yaml +3 -3
- package/rules/abstract-length.yaml +2 -2
- package/rules/adversative-ga-repeat.yaml +2 -2
- package/rules/all-caps-shouting.yaml +2 -2
- package/rules/attachment-not-attached.yaml +11 -6
- package/rules/bold-label-list.yaml +29 -6
- package/rules/bracket-width-consistency.yaml +2 -2
- package/rules/demonstrative-opener-run.yaml +2 -2
- package/rules/duration-mismatch.yaml +2 -2
- package/rules/emoji-density.yaml +2 -2
- package/rules/empty-section.yaml +2 -2
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/katakana-density.yaml +3 -3
- package/rules/lookalike-character.yaml +8 -5
- package/rules/max-kanji-continuous.yaml +4 -0
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/number-style-consistency.yaml +2 -2
- package/rules/obligation-without-deadline.yaml +2 -2
- package/rules/padded-intro.yaml +1 -1
- package/rules/paragraph-length-variance.yaml +27 -3
- package/rules/redundant-expression.yaml +1 -1
- package/rules/repeated-sentence-ending.yaml +2 -2
- package/rules/request-without-deadline.yaml +2 -2
- package/rules/requirement-smell.yaml +2 -2
- package/rules/rule-of-three.yaml +2 -2
- package/rules/sentence-spacing-consistency.yaml +2 -2
- package/rules/teki-overuse.yaml +2 -0
- package/rules/unfilled-placeholder.yaml +2 -2
- package/rules/use-before-definition.yaml +2 -2
- package/src/bound-word-particles.ts +23 -0
- package/src/derived/stays.ts +4 -1
- package/src/detectors/absolute-exception.ts +11 -5
- package/src/detectors/abstract-length.ts +16 -6
- package/src/detectors/adversative-ga.ts +24 -2
- package/src/detectors/agreement-slip.ts +35 -10
- package/src/detectors/bold-label.ts +82 -14
- package/src/detectors/bold-quoted.ts +21 -0
- package/src/detectors/caps-caption.ts +10 -0
- package/src/detectors/char-shape.ts +8 -22
- package/src/detectors/clause-shape.ts +14 -3
- package/src/detectors/cleft-focus.ts +40 -0
- package/src/detectors/count-per-section.ts +9 -4
- package/src/detectors/defined-term-form.ts +2 -1
- package/src/detectors/definition-use.ts +23 -4
- package/src/detectors/emoticon.ts +21 -0
- package/src/detectors/empty-section.ts +3 -2
- package/src/detectors/en-shape.ts +10 -1
- package/src/detectors/fullwidth-alnum.ts +24 -3
- package/src/detectors/heading-echo.ts +21 -8
- package/src/detectors/heading-number.ts +20 -0
- package/src/detectors/katakana-density.ts +17 -2
- package/src/detectors/lexicon.ts +2 -1
- package/src/detectors/lookalike-character.ts +19 -2
- package/src/detectors/mark-shape.ts +61 -13
- package/src/detectors/mentioned-phrase.ts +13 -1
- package/src/detectors/middle-dot.ts +22 -0
- package/src/detectors/named-by-context.ts +15 -0
- package/src/detectors/number-style.ts +14 -1
- package/src/detectors/obligation-without-deadline.ts +69 -5
- package/src/detectors/open-end-names.ts +21 -2
- package/src/detectors/orthographic-variant.ts +20 -15
- package/src/detectors/paragraph-pointer.ts +28 -0
- package/src/detectors/phrase-match.ts +13 -5
- package/src/detectors/placeholder-context.ts +72 -0
- package/src/detectors/placeholder-text.ts +1 -1
- package/src/detectors/redundant-pair.ts +25 -0
- package/src/detectors/registry/middle-dot.ts +1 -1
- package/src/detectors/registry/redundant-pair.ts +4 -0
- package/src/detectors/request-owner.ts +6 -3
- package/src/detectors/sentence-counts.ts +16 -4
- package/src/detectors/signals.ts +11 -1
- package/src/detectors/structure-tree.ts +1 -0
- package/src/detectors/structure.ts +6 -5
- package/src/detectors/superlative-context.ts +12 -0
- package/src/detectors/template-sections.ts +1 -1
- package/src/detectors/token-shape.ts +10 -7
- package/src/detectors/unbalanced-bracket.ts +2 -1
- package/src/detectors/unfilled-placeholder.ts +22 -1
- package/src/detectors/verse-block.ts +48 -0
- package/src/document.ts +1 -0
- package/src/email-parts.ts +16 -7
- package/src/eval.ts +2 -0
- package/src/paragraph-length.ts +10 -0
- package/src/plugin.ts +4 -0
- package/src/reasons.ts +4 -0
- package/src/rule-of-three.ts +47 -4
- package/src/run.ts +3 -1
- package/src/structure/build.ts +2 -1
- package/src/structure/cited-elsewhere.ts +18 -6
- package/src/structure/definition-use.ts +10 -1
- package/src/structure/issues.ts +1 -1
- package/src/structure/negated-act.ts +1 -1
- package/src/structure/own-name.ts +28 -0
- package/src/structure/percent-sum-prose.ts +12 -1
- package/src/structure/percent-sum.ts +2 -0
- package/src/structure/reference-text.ts +5 -1
- package/src/te-form-helper.ts +52 -0
- package/src/word-use.ts +13 -0
- 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;
|
package/src/honorific-group.ts
DELETED
|
@@ -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
|
-
);
|