in src/main/scala/com/twitter/penguin/korean/normalizer/KoreanNormalizer.scala [146:169]
private[this] def normalizeEmotionAttachedChunk(s: CharSequence, toNormalize: CharSequence): CharSequence = {
val init = s.subSequence(0, s.length() - 1)
val secondToLastDecomposed = init match {
case si: CharSequence if si.length > 0 =>
val hc = decomposeHangul(si.charAt(si.length() - 1))
if (hc.coda == ' ') Some(hc) else None
case _ => None
}
decomposeHangul(s.charAt(s.length() - 1)) match {
case hc: HangulChar if hc.coda == 'ㅋ' || hc.coda == 'ㅎ' =>
new StringBuilder()
.append(init)
.append(composeHangul(hc.onset, hc.vowel))
case HangulChar(o: Char, v: Char, ' ') if secondToLastDecomposed.isDefined &&
(v == toNormalize.charAt(0)) &&
Hangul.CODA_MAP.contains(o) =>
val hc = secondToLastDecomposed.get
new StringBuilder()
.append(init.subSequence(0, init.length() - 1))
.append(composeHangul(hc.onset, hc.vowel, o))
case _ => s
}
}