Re: Word count and nextWordFromIndex:forward: - not good?
Re: Word count and nextWordFromIndex:forward: - not good?
- Subject: Re: Word count and nextWordFromIndex:forward: - not good?
- From: Keith Blount <email@hidden>
- Date: Tue, 9 Aug 2005 11:14:44 -0700 (PDT)
Dear Aki,
Many thanks for your reply, much appreciated. I was
using NSString's -stringByTrimmingCharactersInSet: to
get rid of all whitespace and punctuation around words
found by -nextWordFromIndex:forward: (and thus
avoiding counting whitespace), which seemed to work
well. (I would have to do something similar with
-doubleClickAtIndex: anyway to avoid counting spaces.)
-doubleClickAtIndex: seems to need more work (to make
sure it doesn't go out of bounds) so I need to do more
testing, but both methods get results that are fine
for my purposes at the moment. Thank you for taking
the time to explain the comment in the docs - this is
the part that I was most concerned about, and your
explanation clarifies things and means I don't have to
worry about "breaking" anything.
Many thanks again and all the best,
Keith
--- Aki Inoue <email@hidden> wrote:
> Oops, sorry sent out pre-maturely.
>
> The difference between the two methods is
> -doubleClickAtIndex:
> separates punctuantions/whitespaces from base words
> whereas -
> nextWordFromIndex:forward: coaleces them.
>
> >> "This method is intended for moving the insertion
> >> point during editing, not for linguistic analysis
> or
> >> parsing of text."
> The NSAttributedString methods don't perform
> morphological analysis.
> That means, the result produced by the methods is
> not necessarily
> correct grammatically for languages like
> Japanese/Chinese.
> Still, it should be sufficient for majority of
> usages.
>
> Aki
>
> > Keith,
> >
> > For counting words, I'd suggest
> -doubleClickAtIndex: instead.
> >
> >
> >> Sorry to reply to my own message, but does
> anybody
> >> have any advice on/knowledge about this? I have
> gone
> >> ahead and changed my word count to be based on
> >> -nextWordFromIndex:forward, and everything seems
> to be
> >> working nicely (and it seems more accurate). But
> I do
> >> want to be positive, given the documentation's
> warning
> >> that this method is not intended for "linguistic
> >> analysis", that I'm not going to be breaking
> anything
> >> here... Hopefully not, seeing as, as I mentioned,
> an
> >> Apple text expert suggested this method elswhere
> -
> >>
> >>
>
http://www.cocoabuilder.com/archive/message/2004/6/10/109459
> >>
> >> - but like I say, I would like to be sure.
> >>
> >> Many thanks,
> >> Keith
> >>
> >> --- ORIGINAL MESSAGE ---
> >>
> >> Hello,
> >>
> >> I have a word count feature in my text editing
> app
> >> which is based on parsing whitespace. This works
> well,
> >> but it has been brought to my attention that this
> will
> >> not work for languages like Japanese. Although I
> >> probably won't be localising any time soon, I
> don't
> >> want to limit my app to certain languages.
> >>
> >> NSAttributedString's -nextWordFromIndex:forward:
> >> method looks like the perfect solution for this.
> >> However, the docs seem to suggest that this
> method
> >> should *not* be used for word counts:
> >>
> >> "This method is intended for moving the insertion
> >> point during editing, not for linguistic analysis
> or
> >> parsing of text."
> >>
> >> On the other hand, I found a previous post on
> this
> >> list asking about word counts, and Douglas
> Davidson,
> >> the Apple text system guru, suggesting this
> method for
> >> precisely this purpose.
> >>
> >> Does anybody have a solution/answer to this? Is
> it
> >> okay to use -nextWordFromIndex:forward: for a
> word
> >> count (and a live word count at that)? If not,
> what
> >> problems does this cause? And also if not, does
> >> anybody have a word count solution that isn't
> limited
> >> to certain languages (which would presumably need
> to
> >> come from Appkit language analysis methods...).
> >>
> >> Many thanks for any advice,
> >> Keith
> >>
> >>
> __________________________________________________
> >> Do You Yahoo!?
> >> Tired of spam? Yahoo! Mail has the best spam
> protection around
> >> http://mail.yahoo.com
> >> _______________________________________________
> >> Do not post admin requests to the list. They will
> be ignored.
> >> Cocoa-dev mailing list
> (email@hidden)
> >> Help/Unsubscribe/Update your Subscription:
> >>
>
> >>
> >> This email sent to email@hidden
> >>
> >>
> >
> >
>
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden