Language Detection API Java Client
Java

README.md

Language Detection API Java Client

Detects language of given text. Returns detected language codes and scores.

Build Status

Installation

Maven

Add this dependency to your pom.xml:

<dependency>
    <groupId>com.detectlanguage</groupId>
    <artifactId>detectlanguage</artifactId>
    <version>1.0.5</version>
</dependency>

NOTE: the <version>XXX</version> can be out of date in this README.

Gradle

Add this dependency to your build.gradle:

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.detectlanguage:detectlanguage:1.0.5'
}

Usage

import com.detectlanguage.DetectLanguage;

Configuration

Before using Detect Language API client you have to setup your personal API key. You can get it by signing up at http://detectlanguage.com

DetectLanguage.apiKey = "YOURAPIKEY";

Language detection

List<Result> results = DetectLanguage.detect("Hello world");

Result result = results.get(0);

System.out.println("Language: " + result.language);
System.out.println("Is reliable: " + result.isReliable);
System.out.println("Confidence: " + result.confidence);

Simple detection

String language = DetectLanguage.simpleDetect("Hello world");

Batch detection

String[] texts = {
    "Hello world", 
    "Labas rytas"
};

List<List<Result>> results = DetectLanguage.detect(texts);  

SSL (optional)

If you are passing sensitive information to the Detect Language API you can enable SSL.

SSL usage adds data and processing overhead. Please use only if encryption is really necessary.

DetectLanguage.ssl = true;

Requirements

Which you can download to target/dependency using:

$ mvn dependency:copy-dependencies

Issues

Please use appropriately tagged github issues to request features or report bugs.

Testing

$ mvn test

Publishing

Sonatype OSS repository.

Snapshot

$ mvn clean deploy

Stage Release

$ mvn release:clean
$ mvn release:prepare
$ mvn release:perform

Release

Done using the Sonatype Nexus UI.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Write your code and tests
  4. Ensure all tests still pass
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new pull request