In the past, I've used character ranges in an attempt to identify the language of text. While this seemed to work for Russian, Chinese, Japanese, Turkish, Greek, Hebrew, Korean & Arabic, it was pretty useless when it came to Latin languages like French, German & Spanish.
How can I identify the sentence having other languages like Spanish?
Someone recommended polyglot and PYCLD2 python libraries and this started me on my quest for a Java solution. I found Apache OpenNLP, but it seemed overkill as I was only needed language detection. Lingua looked promising, but the library was 30mb and integration didn't seem very easy. On the Lingua page, the Optimaize Language Detector Java library was referenced. There was also a tag cloud at the top of the page and "language-detection" was listed. I followed it and filtered the language to "java" and received 23 public repositories. The kju2 language-detector library is a fork of Optimaize, seemed more ColdFusion-friendly in terms of integration & usage and the pre-compiled JAR file is only 1.2mb (versus 131mb for Lingua).
Installation
Copy the JAR file to your JAVA path.
Usage
Instantiate the languageDetector.cfc component.
varlanguageDetector=newlanguageDetector();
languageDetector.detect(text)
Returns a text string with the language detected.
languageDetector("Quel est votre nom?")// CATALAN (French?)languageDetector("Wie heißen Sie?")// GERMANlanguageDetector("¿Cuál es tu nombre?")// SPANISHlanguageDetector("Πως σε λένε?")// GREEK languageDetector("آپ کا نام کیا ہے؟ ")// URDUlanguageDetector("Как Вас зовут?")// BELARUSIAN (Russian)languageDetector("คุณชื่ออะไร?")// THAI
languageDetector("Quel est votre nom?")// CATALAN (French?)languageDetector("Wie heißen Sie?")// GERMANlanguageDetector("¿Cuál es tu nombre?")// SPANISHlanguageDetector("Πως σε λένε?")// GREEK languageDetector("آپ کا نام کیا ہے؟ ")// URDUlanguageDetector("Как Вас зовут?")// BELARUSIAN (Russian)languageDetector("คุณชื่ออะไร?")// THAI