forked from Archives/Athou_commafeed
@@ -30,7 +30,7 @@ class EstimateDirection {
|
|||||||
static boolean isRTL(String str) {
|
static boolean isRTL(String str) {
|
||||||
int rtlCount = 0;
|
int rtlCount = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
String[] tokens = WORD_SEPARATOR_RE.split(str);
|
String[] tokens = WORD_SEPARATOR_RE.split(str, 20); // limit splits to 20, usually enough
|
||||||
for (int i = 0; i < tokens.length; i++) {
|
for (int i = 0; i < tokens.length; i++) {
|
||||||
String token = tokens[i];
|
String token = tokens[i];
|
||||||
if (startsWithRtl(token)) {
|
if (startsWithRtl(token)) {
|
||||||
@@ -41,11 +41,6 @@ class EstimateDirection {
|
|||||||
} else if (hasAnyLtr(token)) {
|
} else if (hasAnyLtr(token)) {
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// only checking 20 first words is usually enough
|
|
||||||
if (i == 20) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return total == 0 ? false : ((float) rtlCount / total > RTL_DETECTION_THRESHOLD ? true : false);
|
return total == 0 ? false : ((float) rtlCount / total > RTL_DETECTION_THRESHOLD ? true : false);
|
||||||
|
|||||||
Reference in New Issue
Block a user