Skip to content

Commit

Permalink
feat: add deinflection for -得る
Browse files Browse the repository at this point in the history
Adds a new deinflection reason '-eru/-uru', with three new rules:

- masu-stem + 得る
- しえる → する
- しうる → する

The rules for しえる and しうる are explicitly included since,
when 得る is used with する, it is common that it is written in
kana instead of kanji.
  • Loading branch information
enellis committed Oct 22, 2024
1 parent 60fe2ca commit 912184f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@
"deinflect_continuous": {
"message": "continuous"
},
"deinflect_eru_uru": {
"message": "-eru/-uru"
},
"deinflect_humble": {
"message": "humble"
},
Expand Down
3 changes: 3 additions & 0 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@
"deinflect_continuous": {
"message": "進行形"
},
"deinflect_eru_uru": {
"message": "-得る"
},
"deinflect_humble": {
"message": "謙譲語"
},
Expand Down
3 changes: 3 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@
"deinflect_continuous": {
"message": "现在进行形"
},
"deinflect_eru_uru": {
"message": "-得る"
},
"deinflect_humble": {
"message": "谦让语"
},
Expand Down
17 changes: 17 additions & 0 deletions src/background/deinflect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]]);
}
});
});
5 changes: 5 additions & 0 deletions src/background/deinflect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const enum Reason {
Ba,
Volitional,
Potential,
EruUru,
CausativePassive,
Te,
Zu,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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]],
Expand Down Expand Up @@ -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]],
Expand Down

0 comments on commit 912184f

Please sign in to comment.