boolean (String text, int i) { int cur = text.codePointAt(i); int prev = i > 0 ? text.codePointBefore(i) : -1; if (Character.isUpperCase(cur)) { if (Character.isUpperCase(prev)) { // check that we're not in the middle of an all-caps word int nextPos = i + Character.charCount(cur); return nextPos < text.length() && Character.isLowerCase(text.codePointAt(nextPos)); } return true; } if (Character.isDigit(cur)) { return true; } if (!Character.isLetter(cur)) { return false; } if (Character.isIdeographic(cur)) { // Consider every ideograph as a separate word return true; } return i == 0 || !Character.isLetterOrDigit(text.charAt(i - 1)) || isHardCodedWordStart(text, i) || isKanaBreak(cur, prev); }