detectlanguage-java
detectlanguage-java copied to clipboard
Detect Language API Java Client
Detect Language API Java Client
Detects language of the given text. Returns detected language codes and scores.
Installation
Maven
Add this dependency to your pom.xml:
<dependency>
<groupId>com.detectlanguage</groupId>
<artifactId>detectlanguage</artifactId>
<version>1.1.0</version>
</dependency>
Gradle
Add this dependency to your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.detectlanguage:detectlanguage:1.1.0'
}
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 https://detectlanguage.com
DetectLanguage.apiKey = "YOURAPIKEY";
// Enable secure mode (SSL) if passing sensitive information
// DetectLanguage.ssl = true;
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);
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
Snapshot
mvn clean deploy
Stage Release
mvn release:clean
mvn release:prepare
mvn release:perform
Release
Done using the Sonatype Nexus UI.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Write your code and tests
- Ensure all tests still pass
- Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new pull request