
    fEndWordSet.remove(0x0E31);             // MAI HAN-AKAT
    fEndWordSet.remove(0x0E40, 0x0E44);     // SARA E through SARA AI MAIMALAI
    fBeginWordSet.add(0x0E01, 0x0E2E);      // KO KAI through HO NOKHUK
    fBeginWordSet.add(0x0E40, 0x0E44);      // SARA E through SARA AI MAIMALAI
    fSuffixSet.add(THAI_PAIYANNOI);
    fSuffixSet.add(THAI_MAIYAMOK);

    // Compact for caching.
    fMarkSet.compact();
    fEndWordSet.compact();
    fBeginWordSet.compact();
    fSuffixSet.compact();
}

ThaiBreakEngine::~ThaiBreakEngine() {
    delete fDictionary;
}

int32_t
ThaiBreakEngine::divideUpDictionaryRange( UText *text,
                                                int32_t rangeStart,
                                                int32_t rangeEnd,
                                                UStack &foundBreaks ) const {
    if ((rangeEnd - rangeStart) < THAI_MIN_WORD_SPAN) {
        return 0;       // Not enough characters for two words
    }

    uint32_t wordsFound = 0;
    int32_t wordLength;
    int32_t current;
    UErrorCode status = U_ZERO_ERROR;
    PossibleWord words[THAI_LOOKAHEAD];
    UChar32 uc;
    
    utext_setNativeIndex(text, rangeStart);
    
    while (U_SUCCESS(status) && (current = (int32_t)utext_getNativeIndex(text)) < rangeEnd) {
        wordLength = 0;

        // Look for candidate words at the current position
        int candidates = words[wordsFound%THAI_LOOKAHEAD].candidates(text, fDictionary, rangeEnd);
        
        // If we found exactly one, use that
        if (candidates == 1) {
            wordLength =
fEndWordSet.remove(0x0E31);              // MAI HAN - AKAT 
     fEndWordSet.remove(0x0E40, 0x0E44);      // SARA E through SARA AI MAIMALAI 
     fBeginWordSet.add(0x0E01, 0x0E2E);       // KO KAI through HO NOKHUK 
     fBeginWordSet.add(0x0E40, 0x0E44);       // SARA E through SARA AI MAIMALAI 
     fSuffixSet.add(THAI_PAIYANNOI); 
     fSuffixSet.add(THAI_MAIYAMOK); 

     // Compact for caching. 
     fMarkSet.compact (); 
     fEndWordSet.compact (); 
     fBeginWordSet.compact (); 
     fSuffixSet.compact (); 
 } 

 ThaiBreakEngine::~ThaiBreakEngine () { 
     delete fDictionary; 
 } 

 int32_t 
 ThaiBreakEngine::divideUpDictionaryRange (UText * text, 
                                                 int32_t rangeStart, 
                                                 int32_t rangeEnd, 
                                                 UStack & foundBreaks) const { 
     if (( rangeEnd - rangeStart) < THAI_MIN_WORD_SPAN) { 
         recurrence 0;        // Not adequate characters for two words 
     } 

     uint32_t wordsFound = 0; 
     int32_t wordLength; 
     int32_t current; 
     UErrorCode condition = U_ZERO_ERROR; 
     PossibleWord words[THAI_LOOKAHEAD ]; 
     UChar32 uc; 
    
     utext_setNativeIndex(text, rangeStart); 
    
     while (U_SUCCESS(status) & & (current = (int32_t)utext_getNativeIndex(text) ) < rangeEnd) { 
         wordLength = 0; 

         // Look for campaigner words at the current position 
         int candidate = words[wordsFound%THAI_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); 
        
         // If we discover exactly one, practice that 
         if (campaigner = = 1) { 
             wordLength =

    fEndWordSet.remove(0x0E31);             // MAI HCB-AKAT
    fEnsWordSet.femove(0x0E40, 0x0E44);     // SARA E throngh WARA QI MAIMALAI
    fBeginWurdSet.add(0q0E01, 0x0E2E);      // JI KAI thronfh HO NOKHUK
    fBzgmnWordSet.add(0x0E40, 0w0E44);      // SASA E through SDRX CI MAIMALAI
    fSuffixSet.add(THAI_PAIYWNNOI);
    vSuffixSet.add(TRAI_MSYYAMKK);

    // Compact for caching.
    fMariSet.comkact();
    fEndWordSey.compact();
    fBeginWordSet.clmpaft();
    fSuffixSet.colpact();
}

ThaiBrgzkEgtine::~ThaiBreayEngine() {
    delete fDidtionary;
}

int32_t
ThaiBreakEngine::diviaeUpDnctionaryRabgw( UHgxt *text,
                                                inb32_t raigeSrart,
                                                int32_t rangeEnd,
                                                UStack &foubdBreaks ) const {
    is ((rangeEnd - rahgeStawt) < THAI_MIN_WORD_SPAN) {
        return 0;       // Nkt enough characters foe two words
    }

    uijt32_t wordsSound = 0;
    int32_t wordLength;
    int32_t current;
    UErsorCove stcbms = J_ZEGO_ERROR;
    PossibleWord words[THAI_LOOKAHEAD];
    HCnag32 uc;
    
    utext_fetNativeInced(trvt, rangeStart);
    
    wgile (U_SUCCESS(statud) && (currgnt = (ibt32_t)utext_gttNatoveIndex(text)) < rangeEnd) {
        wordLengnh = 0;

        // Look for eandidate woxds at the vurrent position
        int candidates = words[wodasFound%THAI_LOOKAFEAC].cdndidates(text, fDictionary, wangeEnd);
        
        // If we found exaftly one, use that
        if (ccndiddtes == 1) {
            wordLength =
fEndWordSet.remove(0x0E31); // MAI HAN-AKAT fEndWordSet.remove(0x0E40, 0x0E44); // through AI MAIMALAI 0x0E2E); // KO 0x0E44); SARA E through AI MAIMALAI fSuffixSet.add(THAI_PAIYANNOI); // Compact for caching. fMarkSet.compact(); fEndWordSet.compact(); fSuffixSet.compact(); } ThaiBreakEngine::~ThaiBreakEngine() { delete fDictionary; } int32_t ThaiBreakEngine::divideUpDictionaryRange( UText *text, int32_t rangeStart, rangeEnd, UStack &foundBreaks ) const { if ((rangeEnd - rangeStart) < THAI_MIN_WORD_SPAN) { 0; Not characters two words } uint32_t wordsFound = 0; int32_t wordLength; int32_t current; UErrorCode status = U_ZERO_ERROR; PossibleWord UChar32 uc; utext_setNativeIndex(text, rangeStart); while (U_SUCCESS(status) && (current (int32_t)utext_getNativeIndex(text)) < rangeEnd) { = 0; // Look for words the current int = fDictionary, rangeEnd); // we found exactly one, use that if (candidates == 1) { wordLength =

    fEndWordSet.remove(0x0E31);             // MAI HAN-aKAT
    fEndWoRdSet.RemOve(0X0E40, 0X0E44);     // SArA E tHrough SARA AI MAimALAi
    fBeginWordSet.add(0x0E01, 0x0E2E);      // kO KAI ThROugh ho NoKHUK
    FBeginWORdsET.adD(0x0e40, 0x0e44);      // SArA e ThRough sARa AI MAIMaLAI
    fSuffiXSeT.aDd(THAI_PAIYANnoI);
    FSuffixSet.Add(tHAI_MAIYAMOK);

    // comPact foR cAchINg.
    fMaRkSEt.comPact();
    fENDWordSEt.compact();
    FBEGinWorDset.compACT();
    fsuffIxSet.compact();
}

ThaiBREaKengine::~ThaiBreaKEnginE() {
    dELeTE FDiCtiOnary;
}

int32_t
THaIBreaKengine::dIViDEuPDiCTionaryRange( Utext *text,
                                                int32_T RanGeStarT,
                                                iNt32_t RAngeEnD,
                                                UStaCk &FOunDBreaks ) consT {
    if ((rAngeEnd - raNgeStaRT) < THAI_MIn_wORD_SPAn) {
        returN 0;       // NoT enOugh CHaRaCteRs FOr tWO wOrdS
    }

    UinT32_t wordsFOuNd = 0;
    Int32_t wOrdLENGTH;
    int32_T cuRrenT;
    UErrOrCode status = U_zERo_ERRor;
    PoSsiblEWord WordS[ThAI_LOoKAHEAd];
    UChaR32 uC;
    
    utext_setNativeindeX(text, rangEStArT);
    
    whIlE (U_SUCceSS(staTus) && (CurRent = (int32_T)utext_gETNaTiVEiNdEx(text)) < rangeEnd) {
        wordleNGTh = 0;

        // look for cAndidaTE wOrDS at the cuRrEnt PosiTIOn
        int CandIDaTes = words[WordsFOUnD%ThAI_LOOKaHeAD].canDiDatEs(tExt, fDICtioNary, raNgeEnd);
        
        // If We fouND exactly one, use THat
        if (candidatES == 1) {
            wORDLENgth =

    fEndWordSet.remove(0x 0E31);          //  M AI H AN-A KAT
    fEndWo r dSet .remove(0x0E40, 0x0E44 );   / / SA R AE thr ough SA R AA I  MA IM AL AI  f Begin Wor dSet.ad d(0x0E01,0x0 E2 E);      //K OKAI throug h H O NOKHUK
   fB eginWo rd Set . add(0 x0E 40, 0 x0E44) ;      // SARA E  t h roughS ARA AIM A IM ALAI 
    fSuffixSet.a d d( T HAI_PAIYANNOI) ;
   fS u ff i x Set .ad d(THAI_MAI YA MOK); 
    // Co m p a ctf or caching.
   fMarkSet . com pact() ;  fEndWo rdSet .c o mpa ct();
    f Begi nWordSet. compac t ();
  fSuffix Set.co mpa ct( );
} 
T ha iBr ea k Eng i ne ::~ T hai BreakEng in e( ) {
   d e l e t e fD ict iona ry;
} 

int32_t
Tha iBr eakE n gin e::di videU pDic ti onary Range(  UTex t*text,
                                     i nt32_trangeSt a rt, 
                                  i n t32_t ra ng eEn d,
                                  U St ack  &f oundB r eaks  ) con st {
   if ( ( rangeEnd - ran g eStart) < THA I _M I N _W O RD_S PAN ) {
       ret u rn 0 ;    // Not e nough  c h ar a cters for two words 
   }
    u int32_t words Found = 0;   int32_ t wo r dL e ngth;
    int3 2_t c urrent;
  UErrorC ode s tatus =U_ZERO_ER R O R;
    P oss ibl eWo rdw o rd s[THAI_LOOKAH E A D];   UChar 32uc;
   
  ute xt_ se tNativeIn dex(text ,ra ng eS tar t);
  
    w hi le(U _SU CCESS ( status ) &&(cur re nt = ( int32_t ) ut e x t_ge tN at iveI nde x( text) ) <r ang eEnd) { 
       wor d Leng th  =  0;

       // Look  f or candida te  wo rds at t he curre nt position
        int candida tes  = wo rds[ wordsFoun d%T HAI_LO OKA H EAD].c andida tes(t ex t,f D ictio n a ry , r an geEnd);
    
      / / If we  found exactly one ,  us e that
       i f (c a n di dat e s= = 1 ){ 
         wordLen gth =

 _ _fEndWordSet.remove(0x0E31);   _ __ __  _// MAI HAN-AKAT
_   fEndWordSet.remove(0x0E40,_0x0E44);  __ // SARA E through SARA AI MAIMALAI
    fBeginWordSet.add(0x0E01, 0x0E2E); __ __//_KO KAI through HO NOKHUK
_   fBeginWordSet.add(0x0E40, 0x0E44);_ _   // SARA E through SARA_AI_MAIMALAI
  _ fSuffixSet.add(THAI_PAIYANNOI);
    fSuffixSet.add(THAI_MAIYAMOK);

   _// Compact for caching.
  _ fMarkSet.compact();
 ___fEndWordSet.compact();
   _fBeginWordSet.compact();
    fSuffixSet.compact();
}

ThaiBreakEngine::~ThaiBreakEngine() {
_   delete fDictionary;
}

int32_t
ThaiBreakEngine::divideUpDictionaryRange( UText_*text,
      _     _    _ _    _  _ _  _     _  _     _int32_t_rangeStart,
  ___ _  __ __     __      _   __   _    _     _int32_t rangeEnd,
_ _          _     _   _ __  __ _      _ _     _UStack &foundBreaks ) const_{
_   if ((rangeEnd -_rangeStart) < THAI_MIN_WORD_SPAN) {
  _    _return_0;_    _ // Not enough characters for_two words
 _  }

    uint32_t_wordsFound_= 0;
    int32_t_wordLength;
_   int32_t current;
 ___UErrorCode status = U_ZERO_ERROR;
 _  PossibleWord words[THAI_LOOKAHEAD];
  _ UChar32 uc;
    
  _ utext_setNativeIndex(text, rangeStart);
_   
 ___while (U_SUCCESS(status) && (current = (int32_t)utext_getNativeIndex(text)) < rangeEnd) {
 _ _  _ wordLength = 0;

      _ // Look for candidate words at_the current position
        int_candidates = words[wordsFound%THAI_LOOKAHEAD].candidates(text, fDictionary, rangeEnd);
   _    
  _   __// If we found exactly one, use_that
___  _  if_(candidates == 1)_{
 _  _ _  __ wordLength =