public int getKoreanLength(String line) { mBrokedHistory = false; // 기존에 변경된 문자가 있는가? int longest = getLongestSameWord(line); // 기중에서 가장 긴 문자, 이후의 한글 수를 찾아야 함. String korWord = line.substring(longest); mRearWordCount = 0; String lastChar = ""; STATE next = STATE.CHOSUNG; for (String stroke : korWord.split("")) { if (next == STATE.CHOSUNG) { if (isMoum(stroke)) { next = STATE.JUNGSUNG_DOUBLE; setBroken(); } else { next = STATE.CHOSUNG_DOUBLE; } } else if (next == STATE.CHOSUNG_DOUBLE) { if (isMoum(stroke)) { next = STATE.JUNGSUNG_DOUBLE; } else if (isDoubleJaum(lastChar, stroke)) { next = STATE.JUNGSUNG; } else { setBroken(); addLength(); next = STATE.CHOSUNG_DOUBLE; } } else if (next == STATE.JUNGSUNG_DOUBLE) { if (isDoubleMoum(lastChar, stroke)) { if (isBroken()) { next = STATE.CHOSUNG; addLength(); } else { next = STATE.JONGSUNG; } } else if (isMoum(stroke)) { addLength(); setBroken(); next = STATE.JUNGSUNG_DOUBLE; } else { if (isBroken()) { addLength(); next = STATE.CHOSUNG_DOUBLE; } else { next = STATE.JONGSUNG_DOUBLE; } } } else if (next == STATE.JUNGSUNG) { if (isMoum(stroke)) { next = STATE.JUNGSUNG_DOUBLE; } else { addLength(); next = STATE.JUNGSUNG; } } else if (next == STATE.JONGSUNG) { if (isMoum(stroke)) { addLength(); setBroken(); next = STATE.JUNGSUNG_DOUBLE; } else { next = STATE.JONGSUNG_DOUBLE; } } else if (next == STATE.JONGSUNG_DOUBLE) { if (isMoum(stroke)) { addLength(); next = STATE.JUNGSUNG_DOUBLE; } else { // 이전 값이 같이 쓸 수 있는 자음인가? if (isDoubleJaum(lastChar, stroke)) { next = STATE.CHOSUNG; addLength(); } else { next = STATE.JUNGSUNG; addLength(); } } } lastChar = stroke; } if (next != STATE.CHOSUNG) { addLength(); } System.out.println(line + "\tSplit:" + longest + ":" + korWord + "\tCNT:" + mRearWordCount); return longest + mRearWordCount; } private boolean isBroken() { return mBroken; }