diff --git a/CHANGELOG.md b/CHANGELOG.md index bf6527e153..bedd488ba5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ app. - (Chrome) Fixed language code for Chinese localization ([#2051](https://github.com/birchill/10ten-ja-reader/issues/2051)). +- Added deinflection for -得る + ([#2060](https://github.com/birchill/10ten-ja-reader/pull/2060)). ## [1.22.0] - 2024-10-17 diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d79ac3d14d..6052abc66c 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -359,6 +359,9 @@ "deinflect_continuous": { "message": "continuous" }, + "deinflect_eru_uru": { + "message": "-eru/-uru" + }, "deinflect_humble": { "message": "humble" }, diff --git a/_locales/ja/messages.json b/_locales/ja/messages.json index 410076301f..9324f43358 100644 --- a/_locales/ja/messages.json +++ b/_locales/ja/messages.json @@ -359,6 +359,9 @@ "deinflect_continuous": { "message": "進行形" }, + "deinflect_eru_uru": { + "message": "-得る" + }, "deinflect_humble": { "message": "謙譲語" }, diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index 0d625f0222..a0a5e3751d 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -359,6 +359,9 @@ "deinflect_continuous": { "message": "现在进行形" }, + "deinflect_eru_uru": { + "message": "-得る" + }, "deinflect_humble": { "message": "谦让语" }, diff --git a/src/background/deinflect.test.ts b/src/background/deinflect.test.ts index 146657b029..cdcc89c13b 100644 --- a/src/background/deinflect.test.ts +++ b/src/background/deinflect.test.ts @@ -549,4 +549,21 @@ describe('deinflect', () => { expect(match!.reasonChains[0][0]).toBe(Reason.NegativeTe); } }); + + it('deinflects -得る', () => { + const cases = [ + ['し得る', 'する'], + ['しえる', 'する'], + ['しうる', 'する'], + ['来得る', '来る'], + ['あり得る', 'ある'], + ['考え得る', '考える'], + ]; + for (const [inflected, plain] of cases) { + const result = deinflect(inflected); + const match = result.find((candidate) => candidate.word == plain); + expect(match).toBeDefined(); + expect(match!.reasonChains).toEqual([[Reason.EruUru]]); + } + }); }); diff --git a/src/background/deinflect.ts b/src/background/deinflect.ts index c8e1a354c7..49f03f416f 100644 --- a/src/background/deinflect.ts +++ b/src/background/deinflect.ts @@ -24,6 +24,7 @@ export const enum Reason { Ba, Volitional, Potential, + EruUru, CausativePassive, Te, Zu, @@ -64,6 +65,7 @@ export const deinflectL10NKeys: { [key: number]: string } = { [Reason.Ba]: 'deinflect_ba', [Reason.Volitional]: 'deinflect_volitional', [Reason.Potential]: 'deinflect_potential', + [Reason.EruUru]: 'deinflect_eru_uru', [Reason.CausativePassive]: 'deinflect_causative_passive', [Reason.Te]: 'deinflect_te', [Reason.Zu]: 'deinflect_zu', @@ -211,6 +213,8 @@ const deinflectRuleData: Array< ['さない', 'する', Type.IAdj, Type.SpecialSuruVerb, [Reason.Irregular, Reason.Negative]], ['される', '', Type.IchidanVerb, Type.IrrealisStem, [Reason.CausativePassive]], ['される', 'する', Type.IchidanVerb, Type.SuruVerb, [Reason.Passive]], + ['しうる', 'する', Type.Initial, Type.SuruVerb, [Reason.EruUru]], + ['しえる', 'する', Type.IchidanVerb, Type.SuruVerb, [Reason.EruUru]], ['しない', 'する', Type.IAdj, Type.SuruVerb, [Reason.Negative]], ['しよう', 'する', Type.Initial, Type.SuruVerb, [Reason.Volitional]], ['じゃう', '', Type.GodanVerb, Type.DaDeStem, [Reason.Chau]], @@ -245,6 +249,7 @@ const deinflectRuleData: Array< ['致す', '', Type.GodanVerb, Type.NounVS, [Reason.SuruNoun, Reason.Humble]], ['えば', 'う', Type.Initial, Type.GodanVerb, [Reason.Ba]], ['える', 'う', Type.IchidanVerb, Type.GodanVerb, [Reason.Potential]], + ['得る', '', Type.IchidanVerb, Type.MasuStem, [Reason.EruUru]], ['おう', 'う', Type.Initial, Type.GodanVerb, [Reason.Volitional]], ['仰い', '仰る', Type.MasuStem, Type.GodanVerb, [Reason.MasuStem]], ['仰い', '仰る', Type.Initial, Type.GodanVerb, [Reason.Imperative]],