62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
|
const vowelLetters = ['a', 'e', 'ê', 'i', 'o', 'ô', 'u', 'y', 'ø'];
|
||
|
|
||
|
const rootEndingPair = (str) => {
|
||
|
return { root: str.slice(0, -1), ending: str.slice(-1) };
|
||
|
};
|
||
|
|
||
|
function declineSaimiar(entry) {
|
||
|
const sai = entry.sai;
|
||
|
const morph = entry.morph_type;
|
||
|
if (morph == '-V') {
|
||
|
return vowelDeclension(sai);
|
||
|
} else if (morph == '-a/i') {
|
||
|
return aiDeclension(sai)
|
||
|
} else if (morph == "e-") {
|
||
|
return initalDeclension(sai);
|
||
|
} else if (morph == "-C") {
|
||
|
return consonantDeclension(sai);
|
||
|
} else {
|
||
|
console.warn(`Can't decline entry '${entry.sai}'`);
|
||
|
console.log(entry)
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function vowelDeclension(sai) {
|
||
|
const { root, ending } = rootEndingPair(sai);
|
||
|
return {
|
||
|
"abs": `${root}${ending}`,
|
||
|
"erg": `${root}${ending}na`,
|
||
|
"adp": `${root}${ending}s`,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function aiDeclension(sai) {
|
||
|
const { root, ending } = rootEndingPair(sai);
|
||
|
return {
|
||
|
"abs": `${root}${ending}`,
|
||
|
"erg": `${root}${ending}na`,
|
||
|
"adp": `${root}${ending}s`,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function consonantDeclension(sai) {
|
||
|
const { root, ending } = rootEndingPair(sai);
|
||
|
return {
|
||
|
"abs": `${root}${ending}`,
|
||
|
"erg": `${root}${ending}na`,
|
||
|
"adp": `${root}${ending}s`,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function initalDeclension(sai) {
|
||
|
const { root, ending } = rootEndingPair(sai);
|
||
|
return {
|
||
|
"abs": `${root}${ending}`,
|
||
|
"erg": `${root}${ending}na`,
|
||
|
"adp": `${root}${ending}s`,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export { declineSaimiar };
|