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.
Today, a question was asked on StackOverflow:
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.
var languageDetector = new languageDetector();
languageDetector.detect(text)
Returns a text string with the language detected.
languageDetector("Quel est votre nom?") // CATALAN (French?)
languageDetector("Wie heißen Sie?") // GERMAN
languageDetector("¿Cuál es tu nombre?") // SPANISH
languageDetector("Πως σε λένε?") // GREEK
languageDetector("آپ کا نام کیا ہے؟ ") // URDU
languageDetector("Как Вас зовут?") // BELARUSIAN (Russian)
languageDetector("คุณชื่ออะไร?") // THAI
Source
Download it from Github.
JamoCA / cf-language-detector
ColdFusion wrapper for kju2 forked "Language Detection Library for Java"
cf-language-detect
ColdFusion wrapper for kju2-forked "Language Detection Library for Java".
Installation
Install the JAR file to your existing JAVA path and restart the ColdFusion server.
- Download and build JAR file manually from https://github.com/kju2/language-detector
- Download pre-compiled JAR from MvnRepository. https://mvnrepository.com/artifact/io.github.kju2.languagedetector/language-detector/1.0.5
- Use included JAR file (v1.0.5)
Usage
Instantiate the component:
var languageDetector = new languageDetector();
languageDetector.detect(text)
Returns a text string with the language detected.
languageDetector("Quel est votre nom?") // CATALAN (French?)
languageDetector("Wie heißen Sie?") // GERMAN
languageDetector("¿Cuál es tu nombre?") // SPANISH
languageDetector("Πως σε λένε?") // GREEK
languageDetector("آپ کا نام کیا ہے؟ ") // URDU
languageDetector("Как Вас зовут?") // BELARUSIAN (Russian)
languageDetector("คุณชื่ออะไร?") // THAI
Language Support
68 Built-in Language Profiles
- AFRIKAANS (af)
- ALBANIAN (sq)
- ARABIC (ar)
- ARAGONESE (an)
- BASQUE (eu)
- BELARUSIAN (be)
- BENGALI (bn)
- BRETON (br)
- BULGARIAN…
Top comments (0)