If you're looking for (or wanting to implement) a general Korean word "destructurer", it's not an easy problem. The problem is called "morphological analyzer" and in fact, there have been many academic/industry projects to solve it (IMHO, I don't think it's solved along with all other computational linguistic problems). Here's an early study that's 100% rule-based: Klex, but it's neither free nor open source. See koNLPy for some open-source python options. Also for a larger neural model, Kakao, a Korean big tech, published and maintains khaiii
, an open-source morph-analyzer on github. And finally, see also this paper to see how a recent climate-changing AI approach still is struggling with the problem.
Plus, you want to take input from users. That adds even harder components to the problem. Namely, you might want to handle all non-standard input strings, such as spell errors, puns, trendy coinages, creative nonces, and rare loanwords, which probably are not part of your rules or training data.
If what you're looking for is a simpler piece of software that composes Hangul characters from smaller jamo pieces, for example 가
+ ㅆ
= 갔
, Unicode has algorithmic ways to achieve that. See, for example, tech report #47. Note that these normalization algorithms only work when the input already somewhat normalized (e.g. ㅆ
comes in not as U+3146 nor U+110A, but as U+11BB, and U+11BB alone without other "filler" characters). More importantly, Unicode can't give you any language-level composition algorithm that properly supports irregular conjugations (e.g. 춥
+ ㅆ
= 추웠
), so you need a morph-analyzer at some point anyway.
de_codepoint(codepoint(추) + 1 + (codepoint(ㅂ) - codepoint(ㄱ)))
. Still the rule won't work for a verb 키워요 for example.