12ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* GENERATED SOURCE. DO NOT MODIFY. */ 2f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// © 2016 and later: Unicode, Inc. and others. 3f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html#License 42ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* 52ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ******************************************************************************* 62ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Copyright (C) 2014, International Business Machines Corporation and * 72ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * others. All Rights Reserved. * 82ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ******************************************************************************* 92ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpackage android.icu.text; 112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.io.IOException; 132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.text.CharacterIterator; 142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.lang.UCharacter; 162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.lang.UProperty; 172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.lang.UScript; 182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerclass BurmeseBreakEngine extends DictionaryBreakEngine { 20f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert 212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Constants for BurmeseBreakIterator 222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // How many words in a row are "good enough"? 232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final byte BURMESE_LOOKAHEAD = 3; 242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Will not combine a non-word with a preceding dictionary word longer than this 252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final byte BURMESE_ROOT_COMBINE_THRESHOLD = 3; 262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Will not combine a non-word that shares at least this much prefix with a 272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // dictionary word with a preceding word 282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final byte BURMESE_PREFIX_COMBINE_THRESHOLD = 3; 292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Minimum word size 302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final byte BURMESE_MIN_WORD = 2; 31f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert 322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private DictionaryMatcher fDictionary; 332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static UnicodeSet fBurmeseWordSet; 342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static UnicodeSet fEndWordSet; 352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static UnicodeSet fBeginWordSet; 362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static UnicodeSet fMarkSet; 37f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert 382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller static { 392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Initialize UnicodeSets 402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fBurmeseWordSet = new UnicodeSet(); 412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fMarkSet = new UnicodeSet(); 422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fBeginWordSet = new UnicodeSet(); 432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fBurmeseWordSet.applyPattern("[[:Mymr:]&[:LineBreak=SA:]]"); 452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fBurmeseWordSet.compact(); 462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fMarkSet.applyPattern("[[:Mymr:]&[:LineBreak=SA:]&[:M:]]"); 482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fMarkSet.add(0x0020); 492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fEndWordSet = new UnicodeSet(fBurmeseWordSet); 502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fBeginWordSet.add(0x1000, 0x102A); // basic consonants and independent vowels 512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Compact for caching 532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fMarkSet.compact(); 542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fEndWordSet.compact(); 552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fBeginWordSet.compact(); 56f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert 572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Freeze the static UnicodeSet 582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fBurmeseWordSet.freeze(); 592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fMarkSet.freeze(); 602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fEndWordSet.freeze(); 612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fBeginWordSet.freeze(); 622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 63f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert 642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public BurmeseBreakEngine() throws IOException { 652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super(BreakIterator.KIND_WORD, BreakIterator.KIND_LINE); 662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller setCharacters(fBurmeseWordSet); 672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Initialize dictionary 682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fDictionary = DictionaryData.loadDictionaryFor("Mymr"); 692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 71f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert @Override 722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public boolean equals(Object obj) { 732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Normally is a singleton, but it's possible to have duplicates 742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // during initialization. All are equivalent. 752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return obj instanceof BurmeseBreakEngine; 762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 78f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert @Override 792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public int hashCode() { 802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return getClass().hashCode(); 812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 82f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert 83f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert @Override 842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public boolean handles(int c, int breakType) { 852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (breakType == BreakIterator.KIND_WORD || breakType == BreakIterator.KIND_LINE) { 862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int script = UCharacter.getIntPropertyValue(c, UProperty.SCRIPT); 872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return (script == UScript.MYANMAR); 882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return false; 902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 92f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert @Override 932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public int divideUpDictionaryRange(CharacterIterator fIter, int rangeStart, int rangeEnd, 942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller DequeI foundBreaks) { 95f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert 96f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert 972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if ((rangeEnd - rangeStart) < BURMESE_MIN_WORD) { 982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return 0; // Not enough characters for word 992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int wordsFound = 0; 1012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int wordLength; 1022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int current; 1032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller PossibleWord words[] = new PossibleWord[BURMESE_LOOKAHEAD]; 1042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller for (int i = 0; i < BURMESE_LOOKAHEAD; i++) { 1052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller words[i] = new PossibleWord(); 1062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int uc; 1082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fIter.setIndex(rangeStart); 1102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller while ((current = fIter.getIndex()) < rangeEnd) { 1112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordLength = 0; 1122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //Look for candidate words at the current position 1142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int candidates = words[wordsFound%BURMESE_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd); 1152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If we found exactly one, use that 1172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (candidates == 1) { 1182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordLength = words[wordsFound%BURMESE_LOOKAHEAD].acceptMarked(fIter); 1192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordsFound += 1; 1202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If there was more than one, see which one can take us forward the most words 1232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller else if (candidates > 1) { 1242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller boolean foundBest = false; 1252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If we're already at the end of the range, we're done 1262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (fIter.getIndex() < rangeEnd) { 1272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller do { 1282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int wordsMatched = 1; 1292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (words[(wordsFound+1)%BURMESE_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) > 0) { 1302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (wordsMatched < 2) { 1312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Followed by another dictionary word; mark first word as a good candidate 1322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller words[wordsFound%BURMESE_LOOKAHEAD].markCurrent(); 1332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordsMatched = 2; 1342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If we're already at the end of the range, we're done 1372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (fIter.getIndex() >= rangeEnd) { 1382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller break; 1392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // See if any of the possible second words is followed by a third word 1422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller do { 1432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If we find a third word, stop right away 1442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (words[(wordsFound+2)%BURMESE_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) > 0) { 1452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller words[wordsFound%BURMESE_LOOKAHEAD].markCurrent(); 1462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller foundBest = true; 1472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller break; 1482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } while (words[(wordsFound+1)%BURMESE_LOOKAHEAD].backUp(fIter)); 1502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } while (words[wordsFound%BURMESE_LOOKAHEAD].backUp(fIter) && !foundBest); 1522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordLength = words[wordsFound%BURMESE_LOOKAHEAD].acceptMarked(fIter); 1542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordsFound += 1; 1552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // We come here after having either found a word or not. We look ahead to the 1582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // next word. If it's not a dictionary word, we will combine it with the word we 1592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // just found (if there is one), but only if the preceding word does not exceed 1602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // the threshold. 1612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // The text iterator should now be positioned at the end of the word we found. 1622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (fIter.getIndex() < rangeEnd && wordLength < BURMESE_ROOT_COMBINE_THRESHOLD) { 1632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If it is a dictionary word, do nothing. If it isn't, then if there is 1642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // no preceding word, or the non-word shares less than the minimum threshold 1652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // of characters with a dictionary word, then scan to resynchronize 1662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (words[wordsFound%BURMESE_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) <= 0 && 167f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert (wordLength == 0 || 1682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller words[wordsFound%BURMESE_LOOKAHEAD].longestPrefix() < BURMESE_PREFIX_COMBINE_THRESHOLD)) { 1692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Look for a plausible word boundary 1702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int remaining = rangeEnd - (current + wordLength); 1712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int pc = fIter.current(); 1722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int chars = 0; 1732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller for (;;) { 1742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fIter.next(); 1752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller uc = fIter.current(); 1762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller chars += 1; 1772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (--remaining <= 0) { 1782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller break; 1792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (fEndWordSet.contains(pc) && fBeginWordSet.contains(uc)) { 1812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Maybe. See if it's in the dictionary. 1822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int candidate = words[(wordsFound + 1) %BURMESE_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd); 1832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fIter.setIndex(current + wordLength + chars); 1842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (candidate > 0) { 1852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller break; 1862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller pc = uc; 1892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Bump the word count if there wasn't already one 1922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (wordLength <= 0) { 1932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordsFound += 1; 1942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 1952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Update the length with the passed-over characters 1972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordLength += chars; 1982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } else { 1992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Backup to where we were for next iteration 2002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fIter.setIndex(current+wordLength); 2012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Never stop before a combining mark. 2052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int currPos; 2062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller while ((currPos = fIter.getIndex()) < rangeEnd && fMarkSet.contains(fIter.current())) { 2072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller fIter.next(); 2082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordLength += fIter.getIndex() - currPos; 2092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Look ahead for possible suffixes if a dictionary word does not follow. 2122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // We do this in code rather than using a rule so that the heuristic 213f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert // resynch continues to function. For example, one of the suffix characters 2142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // could be a typo in the middle of a word. 2152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // NOT CURRENTLY APPLICABLE TO BURMESE 2162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Did we find a word on this iteration? If so, push it on the break stack 2182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (wordLength > 0) { 2192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller foundBreaks.push(Integer.valueOf(current + wordLength)); 2202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Don't return a break for the end of the dictionary range if there is one there 2242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (foundBreaks.peek() >= rangeEnd) { 2252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller foundBreaks.pop(); 2262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wordsFound -= 1; 2272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return wordsFound; 2302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller} 233