Skip to content
Permalink
Browse files

Fix missing language filtering in rule-based engine (#23)

  • Loading branch information
pemistahl committed Feb 6, 2020
1 parent cc6c9ce commit b9ca94c06417a53644786a5ca9f0a71217e4ff26
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/main/kotlin/com/github/pemistahl/lingua/api/LanguageDetector.kt
@@ -229,10 +229,13 @@ class LanguageDetector internal constructor(
.filter { it.value >= minimalRequiredCharCount }
.count() > 0

return if (languagesWithMinimumRequiredCharCountExist)
languageCharCounts.toList().maxBy { it.second }!!.first
else
return if (languagesWithMinimumRequiredCharCountExist) {
val language = languageCharCounts.toList().maxBy { it.second }!!.first
if (language in languages) language else UNKNOWN
}
else {
UNKNOWN
}
}

internal fun filterLanguagesByRules(words: List<String>): Sequence<Language> {

0 comments on commit b9ca94c

Please sign in to comment.
You can’t perform that action at this time.