From 79d2b4281e34c4a7b8cb8a07b8da76aef46b426d Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Sat, 29 Jun 2024 15:33:12 +0300 Subject: [PATCH] =?UTF-8?q?fix(noun):=20ljj=20=E2=86=92=20=C4=BAj,=20njj?= =?UTF-8?q?=20=E2=86=92=20=C5=84j=20in=20instrumental=20(#57)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/feminine.test.ts.snap | 72 +++++++++---------- .../__snapshots__/miscellaneous.test.ts.snap | 4 +- src/noun/declensionNoun.ts | 24 +++---- 3 files changed, 47 insertions(+), 53 deletions(-) diff --git a/src/noun/__tests__/__snapshots__/feminine.test.ts.snap b/src/noun/__tests__/__snapshots__/feminine.test.ts.snap index 444d101..79ce2cb 100644 --- a/src/noun/__tests__/__snapshots__/feminine.test.ts.snap +++ b/src/noun/__tests__/__snapshots__/feminine.test.ts.snap @@ -2886,7 +2886,7 @@ exports[`noun feminine 443 1`] = ` "jesenjij", ], "ins": [ - "jesenjjų", + "jeseńjų", "jesenjami", ], "loc": [ @@ -8042,7 +8042,7 @@ exports[`noun feminine 1395 1`] = ` null, ], "ins": [ - "staljjų", + "staľjų", null, ], "loc": [ @@ -8471,7 +8471,7 @@ exports[`noun feminine 1441 1`] = ` "soljij", ], "ins": [ - "soljjų", + "soľjų", "soljami", ], "loc": [ @@ -10552,7 +10552,7 @@ exports[`noun feminine 1846 1`] = ` "basnjij", ], "ins": [ - "basnjjų", + "basńjų", "basnjami", ], "loc": [ @@ -10915,7 +10915,7 @@ exports[`noun feminine 1927 1`] = ` "grtanjij", ], "ins": [ - "grtanjjų", + "grtańjų", "grtanjami", ], "loc": [ @@ -11773,7 +11773,7 @@ exports[`noun feminine 2068 1`] = ` "plěsnjij", ], "ins": [ - "plěsnjjų", + "plěsńjų", "plěsnjami", ], "loc": [ @@ -14514,7 +14514,7 @@ exports[`noun feminine 2489 1`] = ` "dlånjij", ], "ins": [ - "dlånjjų", + "dlåńjų", "dlånjami", ], "loc": [ @@ -15999,7 +15999,7 @@ exports[`noun feminine 2731 1`] = ` "mysljij", ], "ins": [ - "mysljjų", + "mysľjų", "mysljami", ], "loc": [ @@ -19074,7 +19074,7 @@ exports[`noun feminine 3451 1`] = ` "kųpěljij", ], "ins": [ - "kųpěljjų", + "kųpěľjų", "kųpěljami", ], "loc": [ @@ -19239,7 +19239,7 @@ exports[`noun feminine 3483-1 1`] = ` "kontroljij", ], "ins": [ - "kontroljjų", + "kontroľjų", "kontroljami", ], "loc": [ @@ -24001,7 +24001,7 @@ exports[`noun feminine 4769 1`] = ` "bojaznjij", ], "ins": [ - "bojaznjjų", + "bojazńjų", "bojaznjami", ], "loc": [ @@ -28264,7 +28264,7 @@ exports[`noun feminine 5805 1`] = ` "medaljij", ], "ins": [ - "medaljjų", + "medaľjų", "medaljami", ], "loc": [ @@ -35107,7 +35107,7 @@ exports[`noun feminine 11012 1`] = ` "posteljij", ], "ins": [ - "posteljjų", + "posteľjų", "posteljami", ], "loc": [ @@ -38770,7 +38770,7 @@ exports[`noun feminine 14475 1`] = ` "bolěznjij", ], "ins": [ - "bolěznjjų", + "bolězńjų", "bolěznjami", ], "loc": [ @@ -39238,7 +39238,7 @@ exports[`noun feminine 14829 1`] = ` "pečenjij", ], "ins": [ - "pečenjjų", + "pečeńjų", "pečenjami", ], "loc": [ @@ -42286,7 +42286,7 @@ exports[`noun feminine 16764 1`] = ` "kěšenjij", ], "ins": [ - "kěšenjjų", + "kěšeńjų", "kěšenjami", ], "loc": [ @@ -45625,7 +45625,7 @@ exports[`noun feminine 17601 1`] = ` "jablånjij", ], "ins": [ - "jablånjjų", + "jablåńjų", "jablånjami", ], "loc": [ @@ -46928,7 +46928,7 @@ exports[`noun feminine 18049 1`] = ` null, ], "ins": [ - "oceljjų", + "oceľjų", null, ], "loc": [ @@ -54154,7 +54154,7 @@ exports[`noun feminine 20837 1`] = ` "žȯlvij", ], "ins": [ - "žȯlȯvjų", + "žȯlvjų", "žȯlvami", ], "loc": [ @@ -56142,7 +56142,7 @@ exports[`noun feminine 21572 1`] = ` "sęženjij", ], "ins": [ - "sęženjjų", + "sęžeńjų", "sęženjami", ], "loc": [ @@ -57664,7 +57664,7 @@ exports[`noun feminine 22547 1`] = ` "vodobojaznjij", ], "ins": [ - "vodobojaznjjų", + "vodobojazńjų", "vodobojaznjami", ], "loc": [ @@ -66141,7 +66141,7 @@ exports[`noun feminine 25111 1`] = ` "danjij", ], "ins": [ - "danjjų", + "dańjų", "danjami", ], "loc": [ @@ -67760,7 +67760,7 @@ exports[`noun feminine 25704 1`] = ` "golěnjij", ], "ins": [ - "golěnjjų", + "golěńjų", "golěnjami", ], "loc": [ @@ -68288,7 +68288,7 @@ exports[`noun feminine 25915 1`] = ` "hanteljij", ], "ins": [ - "hanteljjų", + "hanteľjų", "hanteljami", ], "loc": [ @@ -69643,7 +69643,7 @@ exports[`noun feminine 26494 1`] = ` "kaznjij", ], "ins": [ - "kaznjjų", + "kazńjų", "kaznjami", ], "loc": [ @@ -70967,7 +70967,7 @@ exports[`noun feminine 26955 1`] = ` "kųděljij", ], "ins": [ - "kųděljjų", + "kųděľjų", "kųděljami", ], "loc": [ @@ -72584,7 +72584,7 @@ exports[`noun feminine 27513 1`] = ` "měljij", ], "ins": [ - "měljjų", + "měľjų", "měljami", ], "loc": [ @@ -73112,7 +73112,7 @@ exports[`noun feminine 27777 1`] = ` "mozoljij", ], "ins": [ - "mozoljjų", + "mozoľjų", "mozoljami", ], "loc": [ @@ -77280,7 +77280,7 @@ exports[`noun feminine 31133 1`] = ` "vermišeljij", ], "ins": [ - "vermišeljjų", + "vermišeľjų", "vermišeljami", ], "loc": [ @@ -77874,7 +77874,7 @@ exports[`noun feminine 31327 1`] = ` "vonjij", ], "ins": [ - "vonjjų", + "vońjų", "vonjami", ], "loc": [ @@ -77973,7 +77973,7 @@ exports[`noun feminine 31394 1`] = ` "vualjij", ], "ins": [ - "vualjjų", + "vuaľjų", "vualjami", ], "loc": [ @@ -78402,7 +78402,7 @@ exports[`noun feminine 31606 1`] = ` "zelenjij", ], "ins": [ - "zelenjjų", + "zeleńjų", "zelenjami", ], "loc": [ @@ -88719,7 +88719,7 @@ exports[`noun feminine 35429 1`] = ` "tkanjij", ], "ins": [ - "tkanjjų", + "tkańjų", "tkanjami", ], "loc": [ @@ -97018,7 +97018,7 @@ exports[`noun feminine 36538 1`] = ` "karuseljij", ], "ins": [ - "karuseljjų", + "karuseľjų", "karuseljami", ], "loc": [ @@ -100311,7 +100311,7 @@ exports[`noun feminine 37061 1`] = ` null, ], "ins": [ - "Horynjjų", + "Horyńjų", null, ], "loc": [ @@ -101835,7 +101835,7 @@ exports[`noun feminine 37170 1`] = ` "glåvoboljij", ], "ins": [ - "glåvoboljjų", + "glåvoboľjų", "glåvoboljami", ], "loc": [ diff --git a/src/noun/__tests__/__snapshots__/miscellaneous.test.ts.snap b/src/noun/__tests__/__snapshots__/miscellaneous.test.ts.snap index fa0d834..7274080 100644 --- a/src/noun/__tests__/__snapshots__/miscellaneous.test.ts.snap +++ b/src/noun/__tests__/__snapshots__/miscellaneous.test.ts.snap @@ -279,7 +279,7 @@ exports[`noun miscellaneous 3749 (as feminine): feminine 1`] = ` "uråvnjij", ], "ins": [ - "uråvnjjų", + "uråvńjų", "uråvnjami", ], "loc": [ @@ -477,7 +477,7 @@ exports[`noun miscellaneous 18959 (as feminine): feminine 1`] = ` "těnjij", ], "ins": [ - "těnjjų", + "těńjų", "těnjami", ], "loc": [ diff --git a/src/noun/declensionNoun.ts b/src/noun/declensionNoun.ts index 5bd646a..65868bd 100644 --- a/src/noun/declensionNoun.ts +++ b/src/noun/declensionNoun.ts @@ -5,12 +5,13 @@ import { declensionAdjective } from '../adjective'; import { inferFluentVowel, markFluentVowel } from '../common'; import type { Noun } from '../partOfSpeech'; -import { VOWELS } from '../substitutions'; import { removeBrackets, replaceStringAt } from '../utils'; import { establishGender } from './establishGender'; // endings like -i, -u are not declinable usually const AEEO$ = /[aeęo]$/; +// should omit words like: obUv, žOLv +const XV$ = /(?:[^aåeęěėioȯuųyl]|[^oȯ]l)v$/; export function declensionNounFlat( rawNoun: string, @@ -224,13 +225,6 @@ function establish_root(noun: string, gender: string) { result = noun.slice(0, -1) + 'ь'; } else if (hasVowelEnding) { result = noun.slice(0, -1); - } else if (gender == 'f2' && noun.slice(-1) === 'ь') { - /*else if (noun.slice(-2) === 'um') { - result = (noun.substring(0, noun.length - 2)); - }*/ - /* else if ((gender == 'f2') && (noun.lastIndexOf('ь') == noun.length - 1)) - { result = (noun.substring (0, noun.length - 1)); } */ - result = noun + 'ь'; } else { result = noun; } @@ -285,7 +279,9 @@ function nominative_sg(noun: string, root: string, gender: string) { if (gender == 'f2') { result = root; } - if (gender == 'f3') { + if (gender == 'f3' && XV$.test(root)) { + result = root.slice(0, root.length - 1) + 'ȯv'; + } else if (gender == 'f3') { result = noun; } else if (gender == 'm3' && root == 'dn') { result = 'den / denj'; @@ -361,11 +357,7 @@ function instrumental_sg(root: string, gender: string) { result = root + 'ojų'; } else if (gender == 'f2') { result = root + 'jų'; - } else if ( - gender == 'f3' && - root.endsWith('v') && - !VOWELS.has(root.slice(-2, -1)) - ) { + } else if (gender == 'f3' && XV$.test(root)) { result = root.substring(0, root.length - 1) + 'ȯvjų'; } else if (gender == 'f3') { result = root + 'jų'; @@ -570,7 +562,9 @@ function rules(word: string): string { .replace('ńi', 'ni') .replace('ŕi', 'ri') .replace('jy', 'ji') - .replace('cy', 'ci'); + .replace('cy', 'ci') + .replace('ljj', 'ľj') + .replace('njj', 'ńj'); } function declensionPluralNoun(