More types
This commit is contained in:
parent
a9703a9529
commit
44156694a2
@ -20,6 +20,7 @@ module.exports = {
|
|||||||
"@typescript-eslint"
|
"@typescript-eslint"
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
"arrow-parens": ["error", "always"]
|
"arrow-parens": ["error", "always"],
|
||||||
|
"indent": ["error", 4]
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"build": "parcel build index.html --no-source-maps",
|
"build": "parcel build index.html --no-source-maps",
|
||||||
"prebuild": "yarn run typecheck",
|
"prebuild": "yarn run typecheck",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"lint": "eslint src/*"
|
"lint": "eslint src/*",
|
||||||
|
"lint-fix": "eslint src/* --fix"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@parcel/transformer-image": "2.0.0-rc.0",
|
"@parcel/transformer-image": "2.0.0-rc.0",
|
||||||
|
@ -1,99 +1,110 @@
|
|||||||
const rootEndingPair = (str) => ({root: str.slice(0, -1), ending: str.slice(-1)});
|
const rootEndingPair = (str) => ({root: str.slice(0, -1), ending: str.slice(-1)});
|
||||||
|
|
||||||
function declineSaimiar(entry) {
|
type SaimiarDeclension = {
|
||||||
const split = entry.sai.split(' ');
|
abs: string;
|
||||||
const sai = split.at(-1);
|
erg: string;
|
||||||
const morph = entry.morph_type;
|
adp: string;
|
||||||
|
all: string;
|
||||||
|
loc: string;
|
||||||
|
ell: string;
|
||||||
|
inst: string;
|
||||||
|
rel: string;
|
||||||
|
};
|
||||||
|
|
||||||
if (morph === '-V') {
|
function declineSaimiar(entry): SaimiarDeclension {
|
||||||
return vowelDeclension(sai);
|
const split = entry.sai.split(' ');
|
||||||
}
|
const sai = split.at(-1);
|
||||||
|
const morph = entry.morph_type;
|
||||||
|
|
||||||
if (morph === '-a/i') {
|
if (morph === '-V') {
|
||||||
return aiDeclension(sai);
|
return vowelDeclension(sai);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (morph === 'e-') {
|
if (morph === '-a/i') {
|
||||||
return initalDeclension(sai);
|
return aiDeclension(sai);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (morph === '-C') {
|
if (morph === 'e-') {
|
||||||
return consonantDeclension(sai);
|
return initalDeclension(sai);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn(`Can't decline entry '${entry.sai}'`);
|
if (morph === '-C') {
|
||||||
console.log(entry);
|
return consonantDeclension(sai);
|
||||||
return null;
|
}
|
||||||
|
|
||||||
|
console.warn(`Can't decline entry '${entry.sai}'`);
|
||||||
|
console.log(entry);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function vowelDeclension(sai: string) {
|
function vowelDeclension(sai: string): SaimiarDeclension {
|
||||||
const {root, ending} = rootEndingPair(sai);
|
const {root, ending} = rootEndingPair(sai);
|
||||||
const adpEnding = ending === 'u' ? 'ys' : `${ending}s`;
|
const adpEnding = ending === 'u' ? 'ys' : `${ending}s`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
abs: `${root}${ending}`,
|
abs: `${root}${ending}`,
|
||||||
erg: `${root}${ending}na`,
|
erg: `${root}${ending}na`,
|
||||||
adp: `${root}${adpEnding}`,
|
adp: `${root}${adpEnding}`,
|
||||||
all: `so${root}${adpEnding}`,
|
all: `so${root}${adpEnding}`,
|
||||||
loc: `${root}${ending}xa`,
|
loc: `${root}${ending}xa`,
|
||||||
ell: `tlê${root}${adpEnding}`,
|
ell: `tlê${root}${adpEnding}`,
|
||||||
inst: `${root}${ending}ŕa`,
|
inst: `${root}${ending}ŕa`,
|
||||||
rel: `${root}${ending}źi`,
|
rel: `${root}${ending}źi`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function aiDeclension(sai: string) {
|
function aiDeclension(sai: string): SaimiarDeclension {
|
||||||
const {root, ending} = rootEndingPair(sai);
|
const {root, ending} = rootEndingPair(sai);
|
||||||
return {
|
return {
|
||||||
abs: `${root}${ending}`,
|
abs: `${root}${ending}`,
|
||||||
erg: `${root}iad`,
|
erg: `${root}iad`,
|
||||||
adp: `${root}i`,
|
adp: `${root}i`,
|
||||||
all: `so${root}i`,
|
all: `so${root}i`,
|
||||||
loc: `${root}iath`,
|
loc: `${root}iath`,
|
||||||
ell: `tlê${root}i`,
|
ell: `tlê${root}i`,
|
||||||
inst: `${root}iar`,
|
inst: `${root}iar`,
|
||||||
rel: `${root}iai`,
|
rel: `${root}iai`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function consonantDeclension(sai: string) {
|
function consonantDeclension(sai: string): SaimiarDeclension {
|
||||||
const split = rootEndingPair(sai);
|
const split = rootEndingPair(sai);
|
||||||
const root = split.ending === 'ø' ? split.root : sai;
|
const root = split.ending === 'ø' ? split.root : sai;
|
||||||
const absFinal = split.ending === 'ø' ? 'ø' : '';
|
const absFinal = split.ending === 'ø' ? 'ø' : '';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
abs: `${root}${absFinal}`,
|
abs: `${root}${absFinal}`,
|
||||||
erg: `${root}ad`,
|
erg: `${root}ad`,
|
||||||
adp: `${root}e`,
|
adp: `${root}e`,
|
||||||
all: `so${root}i`,
|
all: `so${root}i`,
|
||||||
loc: `${root}ak`,
|
loc: `${root}ak`,
|
||||||
ell: `tlê${root}i`,
|
ell: `tlê${root}i`,
|
||||||
inst: `${root}ar`,
|
inst: `${root}ar`,
|
||||||
rel: `${root}ai`,
|
rel: `${root}ai`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const vowels = ['a', 'e', 'ê', 'i', 'o', 'ô', 'u', 'y'];
|
const vowels = ['a', 'e', 'ê', 'i', 'o', 'ô', 'u', 'y'];
|
||||||
|
|
||||||
function initalDeclension(sai: string) {
|
function initalDeclension(sai: string): SaimiarDeclension {
|
||||||
const initial = sai.slice(0, 1);
|
const initial = sai.slice(0, 1);
|
||||||
const root = sai.slice(1);
|
const root = sai.slice(1);
|
||||||
|
|
||||||
const finalRootSound = root.slice(-1);
|
const finalRootSound = root.slice(-1);
|
||||||
const finalVowel = vowels.includes(finalRootSound);
|
const finalVowel = vowels.includes(finalRootSound);
|
||||||
const instEnding = finalVowel ? 'ŕø' : 'ar';
|
const instEnding = finalVowel ? 'ŕø' : 'ar';
|
||||||
const relEnding = finalVowel ? 'źi' : 'ai';
|
const relEnding = finalVowel ? 'źi' : 'ai';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
abs: `${initial}${root}`,
|
abs: `${initial}${root}`,
|
||||||
erg: `da${root}`,
|
erg: `da${root}`,
|
||||||
adp: `i${root}`,
|
adp: `i${root}`,
|
||||||
all: `so${root}`,
|
all: `so${root}`,
|
||||||
loc: `xa${root}`,
|
loc: `xa${root}`,
|
||||||
ell: `tlê${root}`,
|
ell: `tlê${root}`,
|
||||||
inst: `i${root}${instEnding}`,
|
inst: `i${root}${instEnding}`,
|
||||||
rel: `${initial}${root}${relEnding}`,
|
rel: `${initial}${root}${relEnding}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export {declineSaimiar};
|
export {declineSaimiar, SaimiarDeclension};
|
||||||
|
Loading…
Reference in New Issue
Block a user