/*
Character Boundaries: 0 3 6
Word Boundaries:0 6
*/
import java.text.BreakIterator;
import java.util.Locale;
public class HangulTextBoundaryDetection {
static void printBoundaries(String source, BreakIterator bi) {
bi.setText(source);
int boundary = bi.first();
while (boundary != BreakIterator.DONE) {
System.out.print(boundary + " ");
boundary = bi.next();
}
}
public static void main(String s[]) {
String hangul = "\u1112\u1161\u11ab\u1100\u1173\u11af";
BreakIterator ci = BreakIterator.getCharacterInstance(Locale.KOREAN);
BreakIterator wi = BreakIterator.getWordInstance(Locale.KOREAN);
System.out.print("Character Boundaries: ");
printBoundaries(hangul, ci);
System.out.print("\nWord Boundaries:");
printBoundaries(hangul, wi);
}
}