Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deinflection bug #547

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions ext/data/deinflect.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,28 +324,28 @@
{"kanaIn": "", "kanaOut": "", "rulesIn": [], "rulesOut": ["v1", "v5", "vk", "vs", "vz"]}
],
"masu stem": [
{"kanaIn": "", "kanaOut": "いる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "える", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "きる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "ぎる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "ける", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "げる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "じる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "せる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "ぜる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "ちる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "てる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "でる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "にる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "ねる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "ひる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "びる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "へる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "べる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "みる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "める", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "りる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "れる", "rulesIn": [], "rulesOut": ["v1"]},
{"kanaIn": "", "kanaOut": "いる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "える", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "きる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "ぎる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "ける", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "げる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "じる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "せる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "ぜる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "ちる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "てる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "でる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "にる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "ねる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "ひる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "びる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "へる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "べる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "みる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "める", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "りる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "れる", "rulesIn": [], "rulesOut": ["v1d"]},
{"kanaIn": "", "kanaOut": "", "rulesIn": [], "rulesOut": ["v5"]},
{"kanaIn": "", "kanaOut": "", "rulesIn": [], "rulesOut": ["v5"]},
{"kanaIn": "", "kanaOut": "", "rulesIn": [], "rulesOut": ["v5"]},
Expand Down Expand Up @@ -603,10 +603,10 @@
"progressive or perfect": [
{"kanaIn": "ている", "kanaOut": "", "rulesIn": ["v1"], "rulesOut": ["iru"]},
{"kanaIn": "ておる", "kanaOut": "", "rulesIn": ["v5"], "rulesOut": ["iru"]},
{"kanaIn": "てる", "kanaOut": "", "rulesIn": ["v1"], "rulesOut": ["iru"]},
{"kanaIn": "てる", "kanaOut": "", "rulesIn": ["v1p"], "rulesOut": ["iru"]},
{"kanaIn": "でいる", "kanaOut": "", "rulesIn": ["v1"], "rulesOut": ["iru"]},
{"kanaIn": "でおる", "kanaOut": "", "rulesIn": ["v5"], "rulesOut": ["iru"]},
{"kanaIn": "でる", "kanaOut": "", "rulesIn": ["v1"], "rulesOut": ["iru"]},
{"kanaIn": "でる", "kanaOut": "", "rulesIn": ["v1p"], "rulesOut": ["iru"]},
{"kanaIn": "とる", "kanaOut": "", "rulesIn": ["v5"], "rulesOut": ["iru"]},
{"kanaIn": "ないでいる", "kanaOut": "ない", "rulesIn": ["v1"], "rulesOut": ["adj-i"]}
],
Expand Down
16 changes: 9 additions & 7 deletions ext/js/language/deinflector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ export class Deinflector {
/* eslint-disable no-multi-spaces */
/** @type {Map<string, import('translation-internal').DeinflectionRuleFlags>} @readonly */
static _ruleTypes = new Map([
['v1', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000001)], // Verb ichidan
['v5', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000010)], // Verb godan
['vs', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000100)], // Verb suru
['vk', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00001000)], // Verb kuru
['vz', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00010000)], // Verb zuru
['adj-i', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00100000)], // Adjective i
['iru', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b01000000)] // Intermediate -iru endings for progressive or perfect tense
['v1', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b000000011)], // Verb ichidan
['v1d', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b000000010)], // Verb ichidan dictionary form
['v1p', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b000000001)], // Verb ichidan progressive or perfect
['v5', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b000000100)], // Verb godan
['vs', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b000001000)], // Verb suru
['vk', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b000010000)], // Verb kuru
['vz', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b000100000)], // Verb zuru
['adj-i', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b001000000)], // Adjective i
['iru', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b010000000)] // Intermediate -iru endings for progressive or perfect tense
]);
/* eslint-enable no-multi-spaces */

Expand Down
8 changes: 5 additions & 3 deletions test/deinflector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));
* @param {Deinflector} deinflector
* @param {string} source
* @param {string} expectedTerm
* @param {string} expectedRule
* @param {string|undefined} expectedRule
* @param {string[]|undefined} expectedReasons
* @returns {{has: false, reasons: null, rules: null}|{has: true, reasons: string[], rules: number}}
*/
Expand Down Expand Up @@ -115,7 +115,7 @@ function testDeinflections() {
{term: '食べる', source: '食べたり', rule: 'v1', reasons: ['-tari']},
{term: '食べる', source: '食べず', rule: 'v1', reasons: ['-zu']},
{term: '食べる', source: '食べぬ', rule: 'v1', reasons: ['-nu']},
{term: '食べる', source: '食べ', rule: 'v1', reasons: ['masu stem']},
{term: '食べる', source: '食べ', rule: 'v1d', reasons: ['masu stem']},
{term: '食べる', source: '食べましょう', rule: 'v1', reasons: ['polite volitional']},
{term: '食べる', source: '食べよう', rule: 'v1', reasons: ['volitional']},
// ['causative passive']
Expand Down Expand Up @@ -895,7 +895,9 @@ function testDeinflections() {
{term: 'くる', source: 'くさせられない', rule: 'vk'},

{term: 'かわいい', source: 'かわいげ', rule: 'adj-i', reasons: ['-ge']},
{term: '可愛い', source: 'かわいげ', rule: 'adj-i', reasons: ['-ge']}
{term: '可愛い', source: 'かわいげ', rule: 'adj-i', reasons: ['-ge']},

{term: '食べる', source: '食べて', reasons: ['-te', 'progressive or perfect', 'masu stem']}
toasted-nutbread marked this conversation as resolved.
Show resolved Hide resolved
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion types/ext/deinflector.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import type * as TranslationInternal from './translation-internal';

export type ReasonTypeRaw = 'v1' | 'v5' | 'vs' | 'vk' | 'vz' | 'adj-i' | 'iru';
export type ReasonTypeRaw = 'v1' | 'v1d' | 'v1p' | 'v5' | 'vs' | 'vk' | 'vz' | 'adj-i' | 'iru';

export type ReasonsRaw = {
[reason: string]: {
Expand Down