Re: PROBLEM with word iterator

Ruslan Zasukhin <[email protected]> Tue, 09 Nov 2004 20:50:27 +0200
Newsgroups gmane.comp.lib.icu.general
Message-ID <[email protected]>
On 11/9/04 7:55 PM, "Ruslan Zasukhin" <[email protected]> wrote:

I think I am wrong.
I have test more and I get the next results:

    aaa,bbb             aaa bbb
    aaa+bbb             aaa bbb
    aaa_bbb             aaa bbb

but
    aaa.bbb             aaa.bbb
    aaa. bbb            aaa bbb


Okay I see now that solution probably is to use RuleBaseIterator.


> Hi All,
> 
> I have made word iterator
> 
>     UErrorCode status = U_ZERO_ERROR;
>     mpIter = BreakIterator::createWordInstance( *pLocale, status );
> 
> 
> 
> And I do e.g. Counting of words:
> 
> ulong Index_String::CountWords( const UChar* inWords )
> {
>     ulong res = 0;
> 
>     mpIter->setText( inWords );
> 
>     long start = mpIter->first();
>     if( start == BreakIterator::DONE )
>         return res;
>     
>     while( true )
>     {
>         long next = mpIter->next();
>         
>         if( next == BreakIterator::DONE )
>             return res;
>         
>         if( u_isalnum(inWords[start]) )
>             ++res;
> 
>         start = next;
>     }
> 
>     // never reached.
>     return 0;    
> }
> 
> 
> --------------------------------
> PROBLEM IS:
> 
> If I send string "aa.dd bbb"
> 
> Then BreakIterator's next() return me the boundaries  0 and 5
> 
> In other words it consider "aa.dd" as single word.
> 
> Why is this ???
> 
> The same is for any punctuation characater  , / = - + *
> 
> I use ICU 3.0 btw.
> 
> 

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: [email protected]
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------