From 62071356645cfa9ccdbda687933978badf89d4ab Mon Sep 17 00:00:00 2001 From: isamu Date: Mon, 30 Nov 2026 14:26:10 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20comparative-without-baseline=20reads=20?= =?UTF-8?q?=E3=80=9C=E3=81=99=E3=82=8B=E3=81=93=E3=81=A8=E3=81=A7=20before?= =?UTF-8?q?=20a=20comparison=20as=20its=20cause?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 情報を見ることで、より早く理解できる compares with not doing so, as これにより does. A cause word may now be two tokens (こと で); ことで joins the cause group. Co-Authored-By: Claude Opus 5.5 --- .../chaff/rules/comparative-without-baseline.yaml | 4 ++-- .../chaff/src/detectors/comparative-context.ts | 13 ++++++++++--- .../lang-ja/lexicons/comparative-baseline.yaml | 2 ++ text/test/test_comparative_without_baseline.ts | 7 +++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/text/packages/chaff/rules/comparative-without-baseline.yaml b/text/packages/chaff/rules/comparative-without-baseline.yaml index ee971413d..76e8ed564 100644 --- a/text/packages/chaff/rules/comparative-without-baseline.yaml +++ b/text/packages/chaff/rules/comparative-without-baseline.yaml @@ -42,8 +42,8 @@ example: after: We rewrote the parser. The new engine is twice as fast as version 2. not_flagged: - ja: 同じ文か直前の文に比べる相手(従来、以前、前回、昨年、「〜より」「〜に比べて」「〜一方」)がある比較、「より多くの」「より詳しく」「さらに一般に」のような決まった言い方、程度を言う語が続かない「さらに」(さらに、〜します)、条件の下の比較(入れるとより良くなる)、今より良くする目当て(より良い社会、より良いものにする、より簡単にする)、願いや目的の中の比較(より広く進めたい、より円滑にするためには)、目当ての語で終わる複合語(より良い高齢社会)、比べた形で終わる決まった言い方(英語の or to be more precise, …)、二つのコードの例のすぐ後ろの比較(例を書き直した後の This is much better!)、比べた語より前に原因を書いた比較(これにより、手続きがより簡単になった。記録を残すことにより、点検がより確実になる)、「場合」の下の比較(負担の大きい作業がある場合は、より軽い作業に替える)、「の実現」が続く比較(より良い多文化共生の実現)、層の並びの中の位置(より低い層で動作する)、何かを取り除いた数との比較(物価の影響を取り除いた指数で、生活水準をより的確に把握できる)、ほかの手立てがあると言う比較(より安全な書き方があるため、while文は使う場面が限られる)、「さらに新たな」(加えて別の)、「〜とよい」の中の比較(より明確に示していただけるとよい)、前の振る舞いを書いたコードの例のすぐ後ろの比較(「Used to error」と書いた例の後の This behavior is more desirable)は指しません。 - en: 'A comparison whose sentence or the one before names a baseline ("than", "previous", "before", "compared", "whereas"), one that goes past what was just named ("even better", "still faster"), a comparative before a noun ("better results", read only in Japanese), a comparative that does not close its clause ("runs faster on large files"), one under a condition or a hypothesis ("if it looks better", "would be easier"), an aim to make something better than it is now (より良い社会, より良い高齢社会, より良いものにする, より簡単にする in Japanese), a comparison inside a wish or a purpose (より広く進めたい, より円滑にするためには), a set phrase ending in a comparative ("or to be more precise, it created"), a comparison right after two code examples ("This is much better!" after a rewritten function, compared with the first), a comparison set against the clause before it ("Log lines work, but a profiler is better"), one in a sentence opening on a change or a topic ("As the service splits, the team can move faster", "By caching the index, …", "As to the second clause, …"), a change from now ("to make releases more predictable", "we can do better"), a maxim ("simpler is better"), another kind of a thing the sentence before names ("Plain backgrounds are fine. A blurred background looks better."), a comparison with what comes before ("the trail that follows is harder"), a comparison right after a code example whose comment names the behaviour before ("This behavior is more desirable" after "// Used to error, now doesn''t."), and in Japanese a place in a stack of layers (より低い層で動作する), a figure with something taken out (物価の影響を取り除いた指数で、より的確に把握できる, against the figure before), another way that exists beside the one discussed (より安全な書き方があるため、while文は使う場面が限られる), さらに新たな (one more), and a comparison inside "it would be good if" (より明確に示していただけるとよい) are not reported.' + ja: 同じ文か直前の文に比べる相手(従来、以前、前回、昨年、「〜より」「〜に比べて」「〜一方」)がある比較、「より多くの」「より詳しく」「さらに一般に」のような決まった言い方、程度を言う語が続かない「さらに」(さらに、〜します)、条件の下の比較(入れるとより良くなる)、今より良くする目当て(より良い社会、より良いものにする、より簡単にする)、願いや目的の中の比較(より広く進めたい、より円滑にするためには)、目当ての語で終わる複合語(より良い高齢社会)、比べた形で終わる決まった言い方(英語の or to be more precise, …)、二つのコードの例のすぐ後ろの比較(例を書き直した後の This is much better!)、比べた語より前に原因を書いた比較(これにより、手続きがより簡単になった。記録を残すことにより、点検がより確実になる。手順を図にすることで、作業がより確実になる)、「場合」の下の比較(負担の大きい作業がある場合は、より軽い作業に替える)、「の実現」が続く比較(より良い多文化共生の実現)、層の並びの中の位置(より低い層で動作する)、何かを取り除いた数との比較(物価の影響を取り除いた指数で、生活水準をより的確に把握できる)、ほかの手立てがあると言う比較(より安全な書き方があるため、while文は使う場面が限られる)、「さらに新たな」(加えて別の)、「〜とよい」の中の比較(より明確に示していただけるとよい)、前の振る舞いを書いたコードの例のすぐ後ろの比較(「Used to error」と書いた例の後の This behavior is more desirable)は指しません。 + en: 'A comparison whose sentence or the one before names a baseline ("than", "previous", "before", "compared", "whereas"), one that goes past what was just named ("even better", "still faster"), a comparative before a noun ("better results", read only in Japanese), a comparative that does not close its clause ("runs faster on large files"), one under a condition or a hypothesis ("if it looks better", "would be easier"), an aim to make something better than it is now (より良い社会, より良い高齢社会, より良いものにする, より簡単にする in Japanese), a comparison inside a wish or a purpose (より広く進めたい, より円滑にするためには), a set phrase ending in a comparative ("or to be more precise, it created"), a comparison right after two code examples ("This is much better!" after a rewritten function, compared with the first), a comparison set against the clause before it ("Log lines work, but a profiler is better"), one in a sentence opening on a change or a topic ("As the service splits, the team can move faster", "By caching the index, …", "As to the second clause, …"), one after the cause it follows from (これにより, 図にすることで in Japanese), a change from now ("to make releases more predictable", "we can do better"), a maxim ("simpler is better"), another kind of a thing the sentence before names ("Plain backgrounds are fine. A blurred background looks better."), a comparison with what comes before ("the trail that follows is harder"), a comparison right after a code example whose comment names the behaviour before ("This behavior is more desirable" after "// Used to error, now doesn''t."), and in Japanese a place in a stack of layers (より低い層で動作する), a figure with something taken out (物価の影響を取り除いた指数で、より的確に把握できる, against the figure before), another way that exists beside the one discussed (より安全な書き方があるため、while文は使う場面が限られる), さらに新たな (one more), and a comparison inside "it would be good if" (より明確に示していただけるとよい) are not reported.' rewrite: depth: light diff --git a/text/packages/chaff/src/detectors/comparative-context.ts b/text/packages/chaff/src/detectors/comparative-context.ts index c7bbbe554..4c13c8352 100644 --- a/text/packages/chaff/src/detectors/comparative-context.ts +++ b/text/packages/chaff/src/detectors/comparative-context.ts @@ -11,14 +11,21 @@ const firstWordAt = (tokens: readonly Token[]): number => tokens.findIndex((toke const wordOf = (token: Token): readonly string[] => [lower(token), token.lemma?.toLowerCase() ?? ""]; +/** The token's words, and the token run together with the next one when both stand before the comparative (こと + で). */ +const wordsBefore = (tokens: readonly Token[], at: number, first: Token): readonly string[] => { + const [token, next] = [tokens[at], tokens[at + 1]]; + if (token === undefined) return []; + return next === undefined || next.span.end > first.span.start ? wordOf(token) : [...wordOf(token), `${lower(token)}${lower(next)}`]; +}; + /** * A word inside the sentence, before the comparative, that names the change or the alternative it follows from: a cause - * (これにより、…ことにより、…できるため、) or a contrast (Print statements work, but a debugger is better). The word must - * follow another word: the clause before it is what the comparison sets itself against. + * (これにより、…ことにより、…ことで、…できるため、) or a contrast (Print statements work, but a debugger is better). The word must + * follow another word: the clause before it is what the comparison sets itself against. A cause may be two words (こと で). */ export const followsCause = (tokens: readonly Token[], first: Token, causes: ReadonlySet): boolean => { const opening = firstWordAt(tokens); - return tokens.some((token, at) => at > opening && token.span.end <= first.span.start && wordOf(token).some((word) => causes.has(word))); + return tokens.some((token, at) => at > opening && token.span.end <= first.span.start && wordsBefore(tokens, at, first).some((word) => causes.has(word))); }; /** The sentence opens with a word that puts it after a change or a topic it names (As the application grows, …; By pairing …, …). */ diff --git a/text/packages/lang-ja/lexicons/comparative-baseline.yaml b/text/packages/lang-ja/lexicons/comparative-baseline.yaml index bbde66b30..14baa6b6e 100644 --- a/text/packages/lang-ja/lexicons/comparative-baseline.yaml +++ b/text/packages/lang-ja/lexicons/comparative-baseline.yaml @@ -7,6 +7,7 @@ # 比べる相手は今の状態。「より速くなる」「より速くした」は変わったことを言うだけで目当てではないので、なると過去の形は含まない。 # 名詞の並びに「の」と続けて目当てを言うこともある(より良い多文化共生の実現)。 # cause: 比べた語より前で、比較が何の結果かを言う語(これにより互換性の確保がより困難になった、把握できるため、指導がより可能になる)。 +# 「情報を見ることで、より早く理解できる」の「ことで」も、比較が何の結果かを言う(こと と で の二語で読む)。 # 比べる相手は、その原因が無かったときの状態。比べた語より後ろの「ため」は理由か目的で、intent が読む。 # 取り除く・差し引く(消費支出から物価の影響を取り除いた指数で、生活水準をより的確に把握できる)は、取り除く前の数を相手に立てる。 # layer: 程度を言う語のすぐ後ろで、層の並びの中の位置を言う語(より低い層で動作する)。比べる相手は、いま述べている層。 @@ -68,6 +69,7 @@ entries: - { pattern: 実現, group: aim } - { pattern: により, group: cause } - { pattern: によって, group: cause } + - { pattern: ことで, group: cause } - { pattern: ため, group: cause } - { pattern: 取り除く, group: cause } - { pattern: 差し引く, group: cause } diff --git a/text/test/test_comparative_without_baseline.ts b/text/test/test_comparative_without_baseline.ts index 77ac402b0..e4ada027c 100644 --- a/text/test/test_comparative_without_baseline.ts +++ b/text/test/test_comparative_without_baseline.ts @@ -120,6 +120,13 @@ describe("comparative-without-baseline: 比べる相手の無い比較", () => { assert.deepEqual(findingsOf("新しい数で、景気の動きをより的確に把握できる。", ja), ["「より的確」は、何と比べているかが書かれていません"]); }); + it("「〜することで」の後ろの比較は、そうしなかったときと比べている", () => { + assert.deepEqual(findingsOf("新しい担当者は、引き継ぎの記録を読むことで、仕事の流れをより早く覚えられます。", ja), []); + assert.deepEqual(findingsOf("手順を図にすることで作業がより確実になる。", ja), []); + assert.deepEqual(findingsOf("新しい担当者は、仕事の流れをより早く覚えられます。", ja), ["「より早く」は、何と比べているかが書かれていません"]); + assert.deepEqual(findingsOf("作業がより確実になることで、手順を図にした。", ja), ["「より確実」は、何と比べているかが書かれていません"]); + }); + it("鉤括弧の中の比較は、題や語を挙げたもの", () => { assert.deepEqual(findingsOf("詳しくは「申告がさらに簡単に!」のページを見てください。", ja), []); assert.deepEqual(findingsOf("詳しくは、申告がさらに簡単になったことを見てください。", ja), ["「さらに簡単」は、何と比べているかが書かれていません"]);