function* basicAlternativeForms(
stem,
isVerb,
isPast,
) {
yield ["unconjugated stem", stem];
if (stem.endsWith("하")) {
const noun = stem.slice(0, -1);
yield ["formal polite", noun + "합니다"];
if (isVerb === undefined || isVerb === true) {
yield ["formal casual", noun + "한다"];
}
if (isVerb === undefined || isVerb === false) {
yield ["formal casual", noun + "하다"];
}
yield ["informal polite", noun + "해요"];
yield ["informal casual", noun + "해"];
return;
}
if (stem.endsWith("시")) {
const wo시 = stem.slice(0, -1);
yield ["formal polite", wo시 + "십니다"];
yield ["formal casual", wo시 + "신다"];
yield ["informal polite", wo시 + "세요"];
yield ["informal casual", wo시 + "셔"];
return;
}
if (stem.endsWith("되")) {
const noun = stem.slice(0, -1);
yield ["formal polite", noun + "됩니다"];
if (isVerb === undefined || isVerb === true) {
yield ["formal casual", noun + "된다"];
}
if (isVerb === undefined || isVerb === false) {
yield ["formal casual", noun + "되다"];
}
yield ["informal polite", noun + "돼요"];
yield ["informal casual", noun + "돼"];
return;
}
const jamo = Jamo.fromSyllables(stem[stem.length - 1]);
const trimmedStem = stem.slice(0, -1);
if (jamo[1] === "ㅏ" && !isPast) {
if (jamo.length === 2) {
yield ["informal casual", stem];
yield ["informal polite", stem + "요"];
yield [
"formal casual",
trimmedStem + (isVerb ? Jamo.toSyllable(jamo[0] + "ㅏㄴ") : jamo) + "다",
];
yield [
"formal polite",
trimmedStem + Jamo.toSyllable(jamo[0] + "ㅏㅂ") + "니다",
];
} else {
yield ["informal casual", stem + "아"];
yield ["informal polite", stem + "아요"];
yield ["formal casual", (isVerb ? stem + "는" : stem) + "다"];
yield ["formal polite", stem + "습니다"];
}
} else if (jamo[1] === "ㅗ") {
if (jamo.length === 2) {
yield ["informal casual", trimmedStem + Jamo.toSyllable(jamo[0] + "ㅘ")];
yield [
"informal polite",
trimmedStem + Jamo.toSyllable(jamo[0] + "ㅘ") + "요",
];
yield [
"formal casual",
(isVerb ? trimmedStem + Jamo.toSyllable(jamo[0] + "ㅗㄴ") : stem) + "다",
];
yield [
"formal polite",
trimmedStem + Jamo.toSyllable(jamo[0] + "ㅗㅂ") + "니다",
];
} else {
yield ["informal casual", stem + "아"];
yield ["informal polite", stem + "아요"];
yield ["formal casual", (isVerb ? stem + "는" : stem) + "다"];
yield ["formal polite", stem + "습니다"];
}
} else if (jamo[1] === "ㅡ" && jamo.length === 2) {
yield ["informal casual", trimmedStem + Jamo.toSyllable(jamo[0] + "ㅓ")];
yield ["informal polite", trimmedStem + Jamo.toSyllable(jamo[0] + "ㅓ") + "요"];
yield ["formal casual", trimmedStem + (isVerb ? stem + "는" : stem) + "다"];
yield [
"formal polite",
trimmedStem + Jamo.toSyllable(jamo[0] + "ㅡㅂ") + "니다",
];
} else {
if (stem[stem.length - 1] === "업") {
yield ["informal casual", trimmedStem + "어워"];
yield ["formal polite", trimmedStem + "업니다"];
} else if (jamo.length === 2) {
let casualLastJamo = "";
switch (jamo[1]) {
case "ㅣ":
casualLastJamo = jamo[0] + "ㅕ";
break;
case "ㅓㅔ":
casualLastJamo = jamo[0] + jamo[1];
break;
default:
casualLastJamo = jamo[0] + jamo[1];
break;
}
yield ["informal casual", trimmedStem + Jamo.toSyllable(casualLastJamo)];
yield [
"formal polite",
trimmedStem + Jamo.toSyllable(jamo[0] + jamo[1] + "ㅂ") + "니다",
];
} else {
yield ["informal casual", stem + "어"];
yield ["informal polite", stem + "어요"];
yield ["formal polite", stem + "습니다"];
yield ["format casual", (isVerb ? stem + "는" : stem) + "다"];
}
}
}