From a5b9e32619688a724324e0e8f3b23cd31f1fe754 Mon Sep 17 00:00:00 2001 From: pshdev1030 Date: Sat, 16 Nov 2024 14:57:45 +0900 Subject: [PATCH] =?UTF-8?q?josa=20=ED=95=A8=EC=88=98=EC=9D=98=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=EA=B3=BC=20=EB=B6=84=EA=B8=B0=EB=A5=BC=20=EC=B5=9C?= =?UTF-8?q?=EC=A0=81=ED=99=94=ED=95=98=EC=98=80=EC=8A=B5=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/josa/josa.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/josa/josa.ts b/src/josa/josa.ts index 5a1e643e..fe596ba2 100644 --- a/src/josa/josa.ts +++ b/src/josa/josa.ts @@ -17,7 +17,7 @@ type JosaOption = | '으로부터/로부터' | '이라/라'; -const 로_조사: JosaOption[] = ['으로/로', '으로서/로서', '으로써/로써', '으로부터/로부터']; +const 로_조사 = new Set(['으로/로', '으로서/로서', '으로써/로써', '으로부터/로부터']); export function josa(word: string, josa: JosaOption): string { if (word.length === 0) { @@ -37,18 +37,22 @@ function josaPicker(word: string, josa: JosaOption): string { const has받침 = hasBatchim(word); let index = has받침 ? 0 : 1; - const is종성ㄹ = has받침 && disassembleCompleteCharacter(word[word.length - 1])?.jongseong === 'ㄹ'; + if (josa === '와/과') { + return josa.split('/')[has받침 ? 1 : 0]; + } - const isCaseOf로 = has받침 && is종성ㄹ && 로_조사.includes(josa); + const 마지막글자 = word[word.length - 1]; + const isEndsWith이 = 마지막글자 === '이'; - if (josa === '와/과' || isCaseOf로) { - index = index === 0 ? 1 : 0; + if (josa === '이에요/예요' && isEndsWith이) { + return josa.split('/')[1]; } - const isEndsWith이 = word[word.length - 1] === '이'; + const is종성ㄹ = has받침 && disassembleCompleteCharacter(마지막글자)?.jongseong === 'ㄹ'; + const isCaseOf로 = has받침 && is종성ㄹ && 로_조사.has(josa); - if (josa === '이에요/예요' && isEndsWith이) { - index = 1; + if (isCaseOf로) { + return josa.split('/')[has받침 ? 1 : 0]; } return josa.split('/')[index];