From 431a07931af5b592e7aae60d8a4085b6d08214d8 Mon Sep 17 00:00:00 2001 From: Khai Truong Date: Thu, 29 Aug 2024 22:51:18 +0700 Subject: [PATCH 1/2] add -nbakari form --- ext/js/language/ja/japanese-transforms.js | 41 ++++++++++++++++++++--- test/language/japanese-transforms.test.js | 15 +++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/ext/js/language/ja/japanese-transforms.js b/ext/js/language/ja/japanese-transforms.js index 56949eae83..6befe62a96 100644 --- a/ext/js/language/ja/japanese-transforms.js +++ b/ext/js/language/ja/japanese-transforms.js @@ -697,9 +697,9 @@ export const japaneseTransforms = { }, '-n': { name: '-n', - description: '1. Negative form of verbs; a sound change of ぬ.\n' + - '2. (As …んばかり) Shows an action or condition is on the verge of occurring, or an excessive/extreme degree.\n' + - 'Usage: Attach ん to the irrealis form (mizenkei) of verbs.', + description: 'Negative form of verbs; a sound change of ぬ.\n' + + 'Usage: Attach ん to the irrealis form (mizenkei) of verbs.\n' + + 'する becomes せん', i18n: [ { language: 'ja', @@ -728,7 +728,9 @@ export const japaneseTransforms = { }, '-n past': { name: '-n', - description: 'Past negative form of verbs; a sound change of ぬ.\n', + description: 'Past negative form of verbs; a sound change of ぬ.\n' + + 'Usage: Attach んかった to the irrealis form (mizenkei) of verbs.\n' + + 'する becomes せんかった', i18n: [ { language: 'ja', @@ -756,6 +758,37 @@ export const japaneseTransforms = { suffixInflection('ませんかった', 'ません', [], ['v']), ], }, + '-nbakari': { + name: '-nbakari', + description: 'Shows an action or condition is on the verge of occurring, or an excessive/extreme degree.\n' + + 'Usage: Attach んばかり to the irrealis form (mizenkei) of verbs.\n' + + 'する becomes せんばかり', + i18n: [ + { + language: 'ja', + name: '~ん', + description: '今にもそうなりそうな、しかし辛うじてそうなっていないようなさまを指す表現', + }, + ], + rules: [ + suffixInflection('んばかり', 'る', [], ['v1']), + suffixInflection('かんばかり', 'く', [], ['v5']), + suffixInflection('がんばかり', 'ぐ', [], ['v5']), + suffixInflection('さんばかり', 'す', [], ['v5']), + suffixInflection('たんばかり', 'つ', [], ['v5']), + suffixInflection('なんばかり', 'ぬ', [], ['v5']), + suffixInflection('ばんばかり', 'ぶ', [], ['v5']), + suffixInflection('まんばかり', 'む', [], ['v5']), + suffixInflection('らんばかり', 'る', [], ['v5']), + suffixInflection('わんばかり', 'う', [], ['v5']), + suffixInflection('ぜんばかり', 'ずる', [], ['vz']), + suffixInflection('せんばかり', 'する', [], ['vs']), + suffixInflection('為んばかり', '為る', [], ['vs']), + suffixInflection('こんばかり', 'くる', [], ['vk']), + suffixInflection('来んばかり', '来る', [], ['vk']), + suffixInflection('來んばかり', '來る', [], ['vk']), + ], + }, '-mu': { name: '-mu', description: 'Archaic.\n' + diff --git a/test/language/japanese-transforms.test.js b/test/language/japanese-transforms.test.js index 1b3532f761..244d1762f9 100644 --- a/test/language/japanese-transforms.test.js +++ b/test/language/japanese-transforms.test.js @@ -89,6 +89,7 @@ const tests = [ {term: '食べる', source: '食べぬ', rule: 'v1', reasons: ['-nu']}, {term: '食べる', source: '食べん', rule: 'v1', reasons: ['-n']}, {term: '食べる', source: '食べんかった', rule: 'v1', reasons: ['-n past']}, + {term: '食べる', source: '食べんばかり', rule: 'v1', reasons: ['-nbakari']}, {term: '食べる', source: '食べざる', rule: 'v1', reasons: ['-zaru']}, {term: '食べる', source: '食べねば', rule: 'v1', reasons: ['-neba']}, {term: '食べる', source: '食べにゃ', rule: 'v1', reasons: ['-neba', '-ya']}, @@ -149,6 +150,7 @@ const tests = [ {term: '買う', source: '買わぬ', rule: 'v5', reasons: ['-nu']}, {term: '買う', source: '買わん', rule: 'v5', reasons: ['-n']}, {term: '買う', source: '買わんかった', rule: 'v5', reasons: ['-n past']}, + {term: '買う', source: '買わんばかり', rule: 'v5', reasons: ['-nbakari']}, {term: '買う', source: '買わざる', rule: 'v5', reasons: ['-zaru']}, {term: '買う', source: '買わねば', rule: 'v5', reasons: ['-neba']}, {term: '買う', source: '買わにゃ', rule: 'v5', reasons: ['-neba', '-ya']}, @@ -208,6 +210,7 @@ const tests = [ {term: '行く', source: '行かぬ', rule: 'v5', reasons: ['-nu']}, {term: '行く', source: '行かん', rule: 'v5', reasons: ['-n']}, {term: '行く', source: '行かんかった', rule: 'v5', reasons: ['-n past']}, + {term: '行く', source: '行かんばかり', rule: 'v5', reasons: ['-nbakari']}, {term: '行く', source: '行かざる', rule: 'v5', reasons: ['-zaru']}, {term: '行く', source: '行かねば', rule: 'v5', reasons: ['-neba']}, {term: '行く', source: '行かにゃ', rule: 'v5', reasons: ['-neba', '-ya']}, @@ -267,6 +270,7 @@ const tests = [ {term: '泳ぐ', source: '泳がぬ', rule: 'v5', reasons: ['-nu']}, {term: '泳ぐ', source: '泳がん', rule: 'v5', reasons: ['-n']}, {term: '泳ぐ', source: '泳がんかった', rule: 'v5', reasons: ['-n past']}, + {term: '泳ぐ', source: '泳がんばかり', rule: 'v5', reasons: ['-nbakari']}, {term: '泳ぐ', source: '泳がざる', rule: 'v5', reasons: ['-zaru']}, {term: '泳ぐ', source: '泳がねば', rule: 'v5', reasons: ['-neba']}, {term: '泳ぐ', source: '泳がにゃ', rule: 'v5', reasons: ['-neba', '-ya']}, @@ -342,6 +346,7 @@ const tests = [ {term: '増す', source: '増せん', rule: 'v5', reasons: ['potential', '-n']}, {term: '増す', source: '増せんかった', rule: 'v5', reasons: ['potential', '-n past']}, + {term: '増す', source: '増せんばかり', rule: 'v5', reasons: ['potential', '-nbakari']}, ], }, { @@ -387,6 +392,7 @@ const tests = [ {term: '待つ', source: '待たぬ', rule: 'v5', reasons: ['-nu']}, {term: '待つ', source: '待たん', rule: 'v5', reasons: ['-n']}, {term: '待つ', source: '待たんかった', rule: 'v5', reasons: ['-n past']}, + {term: '待つ', source: '待たんばかり', rule: 'v5', reasons: ['-nbakari']}, {term: '待つ', source: '待たざる', rule: 'v5', reasons: ['-zaru']}, {term: '待つ', source: '待たねば', rule: 'v5', reasons: ['-neba']}, {term: '待つ', source: '待たにゃ', rule: 'v5', reasons: ['-neba', '-ya']}, @@ -446,6 +452,7 @@ const tests = [ {term: '死ぬ', source: '死なぬ', rule: 'v5', reasons: ['-nu']}, {term: '死ぬ', source: '死なん', rule: 'v5', reasons: ['-n']}, {term: '死ぬ', source: '死なんかった', rule: 'v5', reasons: ['-n past']}, + {term: '死ぬ', source: '死なんばかり', rule: 'v5', reasons: ['-nbakari']}, {term: '死ぬ', source: '死なざる', rule: 'v5', reasons: ['-zaru']}, {term: '死ぬ', source: '死なねば', rule: 'v5', reasons: ['-neba']}, {term: '死ぬ', source: '死なにゃ', rule: 'v5', reasons: ['-neba', '-ya']}, @@ -504,6 +511,7 @@ const tests = [ {term: '遊ぶ', source: '遊ばぬ', rule: 'v5', reasons: ['-nu']}, {term: '遊ぶ', source: '遊ばん', rule: 'v5', reasons: ['-n']}, {term: '遊ぶ', source: '遊ばんかった', rule: 'v5', reasons: ['-n past']}, + {term: '遊ぶ', source: '遊ばんばかり', rule: 'v5', reasons: ['-nbakari']}, {term: '遊ぶ', source: '遊ばざる', rule: 'v5', reasons: ['-zaru']}, {term: '遊ぶ', source: '遊ばねば', rule: 'v5', reasons: ['-neba']}, {term: '遊ぶ', source: '遊ばにゃ', rule: 'v5', reasons: ['-neba', '-ya']}, @@ -562,6 +570,7 @@ const tests = [ {term: '飲む', source: '飲まぬ', rule: 'v5', reasons: ['-nu']}, {term: '飲む', source: '飲まん', rule: 'v5', reasons: ['-n']}, {term: '飲む', source: '飲まんかった', rule: 'v5', reasons: ['-n past']}, + {term: '飲む', source: '飲まんばかり', rule: 'v5', reasons: ['-nbakari']}, {term: '飲む', source: '飲まざる', rule: 'v5', reasons: ['-zaru']}, {term: '飲む', source: '飲まねば', rule: 'v5', reasons: ['-neba']}, {term: '飲む', source: '飲まにゃ', rule: 'v5', reasons: ['-neba', '-ya']}, @@ -683,6 +692,7 @@ const tests = [ {term: '為る', source: '為ぬ', rule: 'vs', reasons: ['-nu']}, {term: '為る', source: '為ん', rule: 'vs', reasons: ['-n']}, {term: '為る', source: '為んかった', rule: 'vs', reasons: ['-n past']}, + {term: '為る', source: '為んばかり', rule: 'vs', reasons: ['-nbakari']}, {term: '為る', source: '為ざる', rule: 'vs', reasons: ['-zaru']}, {term: '為る', source: '為ねば', rule: 'vs', reasons: ['-neba']}, {term: '為る', source: '為にゃ', rule: 'vs', reasons: ['-neba', '-ya']}, @@ -744,6 +754,7 @@ const tests = [ {term: 'する', source: 'せぬ', rule: 'vs', reasons: ['-nu']}, {term: 'する', source: 'せん', rule: 'vs', reasons: ['-n']}, {term: 'する', source: 'せんかった', rule: 'vs', reasons: ['-n past']}, + {term: 'する', source: 'せんばかり', rule: 'vs', reasons: ['-nbakari']}, {term: 'する', source: 'せざる', rule: 'vs', reasons: ['-zaru']}, {term: 'する', source: 'せねば', rule: 'vs', reasons: ['-neba']}, {term: 'する', source: 'せにゃ', rule: 'vs', reasons: ['-neba', '-ya']}, @@ -800,6 +811,7 @@ const tests = [ {term: '来る', source: '来ぬ', rule: 'vk', reasons: ['-nu']}, {term: '来る', source: '来ん', rule: 'vk', reasons: ['-n']}, {term: '来る', source: '来んかった', rule: 'vk', reasons: ['-n past']}, + {term: '来る', source: '来んばかり', rule: 'vk', reasons: ['-nbakari']}, {term: '来る', source: '来ざる', rule: 'vk', reasons: ['-zaru']}, {term: '来る', source: '来ねば', rule: 'vk', reasons: ['-neba']}, {term: '来る', source: '来にゃ', rule: 'vk', reasons: ['-neba', '-ya']}, @@ -855,6 +867,7 @@ const tests = [ {term: '來る', source: '來ぬ', rule: 'vk', reasons: ['-nu']}, {term: '來る', source: '來ん', rule: 'vk', reasons: ['-n']}, {term: '來る', source: '來んかった', rule: 'vk', reasons: ['-n past']}, + {term: '來る', source: '來んばかり', rule: 'vk', reasons: ['-nbakari']}, {term: '來る', source: '來ざる', rule: 'vk', reasons: ['-zaru']}, {term: '來る', source: '來ねば', rule: 'vk', reasons: ['-neba']}, {term: '來る', source: '來にゃ', rule: 'vk', reasons: ['-neba', '-ya']}, @@ -910,6 +923,7 @@ const tests = [ {term: 'くる', source: 'こぬ', rule: 'vk', reasons: ['-nu']}, {term: 'くる', source: 'こん', rule: 'vk', reasons: ['-n']}, {term: 'くる', source: 'こんかった', rule: 'vk', reasons: ['-n past']}, + {term: 'くる', source: 'こんばかり', rule: 'vk', reasons: ['-nbakari']}, {term: 'くる', source: 'こざる', rule: 'vk', reasons: ['-zaru']}, {term: 'くる', source: 'こねば', rule: 'vk', reasons: ['-neba']}, {term: 'くる', source: 'こにゃ', rule: 'vk', reasons: ['-neba', '-ya']}, @@ -977,6 +991,7 @@ const tests = [ {term: '論ずる', source: '論ぜぬ', rule: 'vz', reasons: ['-nu']}, {term: '論ずる', source: '論ぜん', rule: 'vz', reasons: ['-n']}, {term: '論ずる', source: '論ぜんかった', rule: 'vz', reasons: ['-n past']}, + {term: '論ずる', source: '論ぜんばかり', rule: 'vz', reasons: ['-nbakari']}, {term: '論ずる', source: '論ぜざる', rule: 'vz', reasons: ['-zaru']}, {term: '論ずる', source: '論ぜねば', rule: 'vz', reasons: ['-neba']}, {term: '論ずる', source: '論ぜにゃ', rule: 'vz', reasons: ['-neba', '-ya']}, From f8bf5ca38dbd7985afdd2ec05ac1e6b76324b504 Mon Sep 17 00:00:00 2001 From: Khai Truong Date: Thu, 29 Aug 2024 22:57:54 +0700 Subject: [PATCH 2/2] add all -n forms to bench --- benches/japanese-language-transformer.bench.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/benches/japanese-language-transformer.bench.js b/benches/japanese-language-transformer.bench.js index a2ed8626f7..d547949de9 100644 --- a/benches/japanese-language-transformer.bench.js +++ b/benches/japanese-language-transformer.bench.js @@ -85,6 +85,9 @@ describe('japanese language transformer', () => { '食べてる', '食べとる', '食べてしまう', + '食べん', + '食べんかった', + '食べんばかり', ]; const inflectionCombinations = [ @@ -141,6 +144,9 @@ describe('japanese language transformer', () => { 'きてる', 'きとる', 'きてしまう', + 'こん', + 'こんかった', + 'こんばかり', ]; const suruInflections = [ @@ -195,6 +201,9 @@ describe('japanese language transformer', () => { 'してる', 'しとる', 'してしまう', + 'せん', + 'せんかった', + 'せんばかり', ]; const kansaibenInflections = [