Skip to content

melix/jlangdetect

Repository files navigation

JLangDetect

Build Status

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 :

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 :

<dependency>
  <groupId>me.champeau.jlangdetect</groupId>
  <artifactId>jlangdetect-extra</artifactId>
  <version>0.6</version>
</dependency>

or with Gradle:

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 :

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

About

A language detection library for the JVM

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •