class_name Korean ## 한글 조사 처리. 앞 글자의 받침 유무에 따라 을/를, 이/가, 은/는이 갈린다. ## 구역 이름을 문장에 끼워 넣을 때 "켈프 숲를" 같은 어색한 말이 나오지 않게 한다. const HANGUL_FIRST := 0xAC00 const HANGUL_LAST := 0xD7A3 ## 마지막 글자에 받침이 있는지. 한글 음절이 아니면 없는 것으로 친다. static func has_final(word: String) -> bool: if word.is_empty(): return false var c := word.unicode_at(word.length() - 1) if c < HANGUL_FIRST or c > HANGUL_LAST: return false return (c - HANGUL_FIRST) % 28 != 0 static func josa(word: String, with_final: String, without_final: String) -> String: return word + (with_final if has_final(word) else without_final) static func eul(word: String) -> String: return josa(word, "을", "를") static func i(word: String) -> String: return josa(word, "이", "가") static func eun(word: String) -> String: return josa(word, "은", "는")