Open GoogleCodeExporter opened 9 years ago
Hello Emmanuel,
I think that 'What is WORD?' is different for each application, so langdetect
don't provide such utility methods.
But very thanks.
I might write the same function like the following (but this code is not tested
:P)
public static int wordCount(String line) {
int cnt = 0;
boolean pre_is_letter = false;
for (int idx=0;idx<line.length();idx++) {
boolean is_letter = Character.isLetter(line.charAt(idx));
if (!pre_is_letter && is_letter) cnt++;
pre_is_letter = is_letter;
}
return cnt;
}
Original comment by nakatani.shuyo
on 30 Aug 2011 at 3:43
Thanks for the review of the method. I have tested it. It works. But I have not
calculated the performances gain even if I think there is one. The first
version has 2 loops with one 'continue' (worst thing that can append). The
second has only one 'classical' loop.
Original comment by zygolech...@gmail.com
on 30 Aug 2011 at 8:11
Original issue reported on code.google.com by
zygolech...@gmail.com
on 29 Aug 2011 at 9:25