/** * Returns the locale specific word break iterator. * * @return the locale specific word break iterator * @since 3.7 */ private BreakIterator getWordBreakIterator() { if (fWordBreakIterator == null) fWordBreakIterator= BreakIterator.getWordInstance(); return fWordBreakIterator; }
/** * Creates a new spell check iterator. * * @param document the document containing the specified partition * @param region the region to spell check * @param locale the locale to use for spell checking */ public SpellCheckIterator(IDocument document, IRegion region, Locale locale) { this(document, region, locale, BreakIterator.getWordInstance(locale)); }
/** * Returns the locale specific word break iterator. * * @return the locale specific word break iterator * @since 3.7 */ private BreakIterator getWordBreakIterator() { if (fWordBreakIterator == null) fWordBreakIterator= BreakIterator.getWordInstance(); return fWordBreakIterator; }
/** * Creates a new spell check iterator. * * @param document the document containing the specified partition * @param region the region to spell check * @param locale the locale to use for spell checking */ public SpellCheckIterator(IDocument document, IRegion region, Locale locale) { this(document, region, locale, BreakIterator.getWordInstance(locale)); }
/** * Creates a new spell check iterator. * * @param document the document containing the specified partition * @param region the region to spell check * @param locale the locale to use for spell checking */ public SpellCheckIterator(IDocument document, IRegion region, Locale locale) { this(document, region, locale, BreakIterator.getWordInstance(locale)); }
/** * Returns a new instance of BreakIterator that locates word boundaries. * This function assumes that the text being analyzed is in the default * locale's language. * @return An instance of BreakIterator that locates word boundaries. * @stable ICU 2.0 */ public static BreakIterator getWordInstance() { return getWordInstance(Locale.getDefault()); }
/** * Returns a new instance of BreakIterator that locates word boundaries. * This function assumes that the text being analyzed is in the default * locale's language. * @return An instance of BreakIterator that locates word boundaries. * @stable ICU 2.0 */ public static BreakIterator getWordInstance() { return getWordInstance(Locale.getDefault()); }
/** * Returns the POSIX word break iterator. * * <p> * Used to workaround ICU bug not treating '.' as word boundary, see * http://bugs.icu-project.org/trac/ticket/8371 for details. * </p> * * @return the POSIX word break iterator. * @since 3.7 */ private BreakIterator getPOSIXWordBreakIterator() { if (fPOSIXWordBreakIterator == null) fPOSIXWordBreakIterator= BreakIterator.getWordInstance(new Locale("en", "US", "POSIX")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return fPOSIXWordBreakIterator; }
/** * Creates a new break iterator. */ public JavaBreakIterator() { fIterator= BreakIterator.getWordInstance(); fIndex= fIterator.current(); }
/** * Returns a new instance of BreakIterator that locates word boundaries. * This function assumes that the text being analyzed is in the default * locale's language. * @return An instance of BreakIterator that locates word boundaries. * @stable ICU 2.0 */ public static BreakIterator getWordInstance() { return getWordInstance(ULocale.getDefault()); }
/** * Creates a new break iterator. */ public JavaBreakIterator() { fIterator= BreakIterator.getWordInstance(); fIndex= fIterator.current(); }
/** * Creates a new break iterator. */ public JavaBreakIterator() { fIterator= BreakIterator.getWordInstance(); fIndex= fIterator.current(); }
/** * Creates a new break iterator. */ public JavaBreakIterator() { fIterator = BreakIterator.getWordInstance(); fIndex = fIterator.current(); }
public BreakIterator getBreakIterator() { // Defer initialization of BreakIterator because it is slow, // typically over 2000 ms. if (bi == null) bi = BreakIterator.getWordInstance(new ULocale("th_TH")); return bi; }
private String capitalizeWordsByDictionaries(final String value) { final String preparedString = UCharacter.toTitleCase(value, BreakIterator.getWordInstance()); for (final DictionaryConnection allWordsDictionaryConnection : allWordsDictionaryConnections) { final Iterator<String> lengthSortedValues = allWordsDictionaryConnection.getLengthSortedValues(); while (lengthSortedValues.hasNext()) { final String candidate = lengthSortedValues.next(); if (candidate.equalsIgnoreCase(value)) { return candidate; } } } return getAllWords(preparedString).stream().map(this::capitalizeWordByDictionaries) .collect(Collectors.joining()); }
@Override public BreakIterator getWordInstance(Locale locale) { com.ibm.icu.text.BreakIterator icuBrkItr = com.ibm.icu.text.BreakIterator.getWordInstance( ICULocaleServiceProvider.toULocaleNoSpecialVariant(locale)); return BreakIteratorICU.wrap(icuBrkItr); }
private List<String> getAllWords(final String preparedString) { final List<String> words = new ArrayList<>(); final BreakIterator breakIterator = BreakIterator.getWordInstance(); breakIterator.setText(preparedString); int start = breakIterator.first(); for (int end = breakIterator.next(); end != BreakIterator.DONE; start = end, end = breakIterator.next()) { words.add(preparedString.substring(start, end)); } return words; } }
public static int computeMinimumWidth(GC gc, String text) { BreakIterator wb = BreakIterator.getWordInstance(); wb.setText(text); int last = 0; int width = 0; for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { String word = text.substring(last, loc); Point extent = gc.textExtent(word); width = Math.max(width, extent.x); last = loc; } String lastWord = text.substring(last); Point extent = gc.textExtent(lastWord); width = Math.max(width, extent.x); return width; }
@StepParameterMapping(parameterType = StepParameterType.SOURCE_LOCALE) public void setSourceLocale (LocaleId sourceLocale) { this.srcLoc = sourceLocale; srcWordIterator = (RuleBasedBreakIterator) BreakIterator.getWordInstance(ULocale .createCanonical(srcLoc.toString())); RuleBasedBreakIterator.registerInstance(srcWordIterator, srcLoc.toJavaLocale(), BreakIterator.KIND_WORD); }
/** * Creates a new break iterator. */ public CommonBreakIterator(boolean camelCase) { fIterator = BreakIterator.getWordInstance(); fIndex = fIterator.current(); whitespace = new Whitespace(); delimiter = new LineDelimiter(); if (camelCase) identifier = new CamelCaseIdentifier(); else identifier = new Identifier(); other = new Other(); }