An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

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'
}

----