Fixed detect method
@@ -83,7 +83,7 @@ public class ChineseDetector {
* @param string input string to convert
* @return language
*/
- public Language detectLanguage(String string) {
+ public Language detect(String string) {
int simplifiedCount = 0, traditionalCount = 0;
PrimitiveIterator.OfInt stream = string.codePoints().iterator();
@@ -97,13 +97,12 @@ public class ChineseDetector {
}
}
- if (simplifiedCount > traditionalCount) {
+ if (simplifiedCount == traditionalCount)
+ return Language.CHINESE;
+ else if (simplifiedCount > traditionalCount)
return Language.CHINESE_SIMPLIFIED;
- } else if (traditionalCount > 0) {
+ else // (traditionalCount > simplifiedCount)
return Language.CHINESE_TRADITIONAL;
- } else {
- return Language.CHINESE;
- }
}
}
