https://github.com/melix/jlangdetect
A language detection library for the JVM
https://github.com/melix/jlangdetect
Last synced: 12 months ago
JSON representation
A language detection library for the JVM
- Host: GitHub
- URL: https://github.com/melix/jlangdetect
- Owner: melix
- License: apache-2.0
- Created: 2014-01-22T17:56:15.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2023-08-21T09:39:08.000Z (over 2 years ago)
- Last Synced: 2025-03-18T00:46:12.574Z (about 1 year ago)
- Language: Java
- Size: 1.15 MB
- Stars: 36
- Watchers: 8
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.adoc
- Changelog: changelog/CHANGELOG.txt
- License: LICENSE
Awesome Lists containing this project
- awesome-java - JLangDetect
README
== JLangDetect
image:https://github.com/melix/jlangdetect/workflows/Main/badge.svg["Build Status", link="https://github.com/melix/jlangdetect/actions?query=workflow%3AMain"]
WARNING: This library has been republished to Maven Central for convenience, but it not maintained. It is provided "as is".
A language detection library for the JVM.
== How to use it ?
The simplest way to use JLangDetect is to use the _UberLanguageDetector_ singleton, available in the _jlangdetect-extra_ module :
[source]
----
import me.champeau.ld.UberLanguageDetector;
UberLanguageDetector detector = UberLanguageDetector.getInstance();
// ..
String language = detector.detectLang("ceci est un petit texte en français");
----
Alternatively, if you don’t need to detect russian, chinese, japanese or korean languages, you can use the _EuroparlDetector_ available in the _jlangdetect-europarl_ module. Note that you can still create your own language detector and register custom languages using the core module.
Keep in mind that this package requires SLF4J to be referenced.
== Maven integration
JLangDetect is now available on Maven Central.
Then use the following dependency :
[source,xml]
----
me.champeau.jlangdetect
jlangdetect-extra
0.6
----
or with Gradle:
[source,groovy]
----
dependencies {
implementation("me.champeau.jlangdetect:jlangdetect:0.6")
}
----
== Use from Groovy
As a last integration example, here is how to use it from Groovy, through a simple script :
[source]
----
@Grab('me.champeau.jlangdetect:jlangdetect-extra:0.6')
import me.champeau.ld.UberLanguageDetector as ULD
ULD.instance.with {
assert detectLang('ceci est un petit texte en français') == 'fr'
assert detectLang('this is a text in english') == 'en'
}
----