Java Code Examples for com.ibm.icu.text.BreakIterator#getWordInstance()
The following examples show how to use
com.ibm.icu.text.BreakIterator#getWordInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CaseMapImpl.java From trekarta with GNU General Public License v3.0 | 6 votes |
public static BreakIterator getTitleBreakIterator( Locale locale, int options, BreakIterator iter) { options &= TITLECASE_ITERATOR_MASK; if (options != 0 && iter != null) { throw new IllegalArgumentException( "titlecasing iterator option together with an explicit iterator"); } if (iter == null) { switch (options) { case 0: iter = BreakIterator.getWordInstance(locale); break; case TITLECASE_WHOLE_STRING: iter = new WholeStringBreakIterator(); break; case TITLECASE_SENTENCES: iter = BreakIterator.getSentenceInstance(locale); break; default: throw new IllegalArgumentException("unknown titlecasing iterator option"); } } return iter; }
Example 2
Source File: CaseMapImpl.java From trekarta with GNU General Public License v3.0 | 6 votes |
public static BreakIterator getTitleBreakIterator( ULocale locale, int options, BreakIterator iter) { options &= TITLECASE_ITERATOR_MASK; if (options != 0 && iter != null) { throw new IllegalArgumentException( "titlecasing iterator option together with an explicit iterator"); } if (iter == null) { switch (options) { case 0: iter = BreakIterator.getWordInstance(locale); break; case TITLECASE_WHOLE_STRING: iter = new WholeStringBreakIterator(); break; case TITLECASE_SENTENCES: iter = BreakIterator.getSentenceInstance(locale); break; default: throw new IllegalArgumentException("unknown titlecasing iterator option"); } } return iter; }
Example 3
Source File: SegmenterObject.java From es6draft with MIT License | 6 votes |
private BreakIterator createBreakIterator() { ULocale locale = ULocale.forLanguageTag(this.locale); if ("line".equals(granularity)) { // "strictness" cannot be set through unicode extensions (u-lb-strict), handle here: locale = locale.setKeywordValue("lb", strictness); } BreakIterator breakIterator; switch (granularity) { case "grapheme": breakIterator = BreakIterator.getCharacterInstance(locale); break; case "word": breakIterator = BreakIterator.getWordInstance(locale); break; case "sentence": breakIterator = BreakIterator.getSentenceInstance(locale); break; case "line": breakIterator = BreakIterator.getLineInstance(locale); break; default: throw new AssertionError(); } return breakIterator; }
Example 4
Source File: GlobalizationPreferences.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * This function can be overridden by subclasses to use different heuristics. * <b>It MUST return a 'safe' value, * one whose modification will not affect this object.</b> * * @param type * @draft ICU 3.6 * @provisional This API might change or be removed in a future release. */ protected BreakIterator guessBreakIterator(int type) { BreakIterator bitr = null; ULocale brkLocale = getAvailableLocale(TYPE_BREAKITERATOR); if (brkLocale == null) { brkLocale = ULocale.ROOT; } switch (type) { case BI_CHARACTER: bitr = BreakIterator.getCharacterInstance(brkLocale); break; case BI_TITLE: bitr = BreakIterator.getTitleInstance(brkLocale); break; case BI_WORD: bitr = BreakIterator.getWordInstance(brkLocale); break; case BI_LINE: bitr = BreakIterator.getLineInstance(brkLocale); break; case BI_SENTENCE: bitr = BreakIterator.getSentenceInstance(brkLocale); break; default: throw new IllegalArgumentException("Unknown break iterator type"); } return bitr; }
Example 5
Source File: ICUWordRecognizer.java From birt with Eclipse Public License 1.0 | 5 votes |
public ICUWordRecognizer( String text, Locale locale ) { if(locale!=null) { wordBreaker = BreakIterator.getWordInstance(locale); } else { wordBreaker = BreakIterator.getWordInstance(Locale.getDefault( )); } this.text = text; wordBreaker.setText( text); }
Example 6
Source File: JavaBreakIterator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Creates a new break iterator. */ public JavaBreakIterator() { fIterator= BreakIterator.getWordInstance(); fIndex= fIterator.current(); }
Example 7
Source File: SpellCheckIterator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * 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)); }