pemistahl / lingua

The most accurate natural language detection library for Java and the JVM, suitable for long and short text alike
Apache License 2.0
689 stars 61 forks source link

Why am I forced to specify 2 languages for the detection to work with? #160

Closed DavidTheExplorer closed 1 year ago

DavidTheExplorer commented 1 year ago

I have a project where players can choose their language, and then only messages in their language would be sent to their chat. This is impossible(or unreliable) to implement because this code is illegal:

String message = ...;
Language playerLanguage = ...;

//don't send the message if it's not in the player's language
if(!LanguageDetectorBuilder.fromLanguages(playerLanguage).build().detectLanguageOf(message) != playerLanguage)
    return;