Language Detection API

                Smart Techie

                When I was reading some article, I found some other language words appeared in that article. I was fascinated to know for what language those words belongs to and searched for an API to detect the language based on the content which we are providing. I found a simple API to do the job here. Follow the steps to work with this API.

  • Register here to get the API key.
  • Create maven project and add the below dependency to pom.xml
<dependency>
     <groupId>com.detectlanguage</groupId>
     <artifactId>detectlanguage</artifactId>
     <version>1.0.0</version>
</dependency>

Write  simple java code by using API to detect the language of context. The code is provided below.

package org.smarttechie;

import java.util.List;

import com.detectlanguage.DetectLanguage;
import com.detectlanguage.Result;
import com.detectlanguage.errors.APIError;

public class LanguageDetector {

/**
* @param args
* @throws APIError
*/
public static void main(String[] args) throws APIError {
DetectLanguage.apiKey = "[YOUR API KEY]";
List<Result> results = DetectLanguage.detect("ಕನ್ನಡ ಲಿಪಿ");

Result result = results.get(0);

System.out.println("Language: " + result.language);
}

}

Once you run the above code, it will detect the language code as “KN” [KANNADA].

The source code is available here.

Advertisements

I am Siva Prasad Rao Janapati. Working as a software developer. Has hands on experience on ATG Commerce(DAS/DPS/DCS), Mozu commerce, Broadleaf Commerce, Java, JEE, Spring, Play, JPA, Hibernate, Velocity, JMS, Jboss, Weblogic,Tomcat, Jetty, Apache, Apache Solr, Spring Batch, JQuery, NodeJS, SOAP, REST, MySQL, Oracle, Mongo DB, Memcached, HazelCast, Git, SVN, CVS, Ant, Maven, Gradle, Amazon Web services, Rackspace, Quartz, JMeter, Junit, Open NLP, Facebook Graph,Twitter4J, YouTube Gdata, Bazzarvoice,Yotpo, 4-Tell, Alatest, Shopzilla, Linkshare. I have hands on experience on open sources and commercial technologies.

Tagged with: , ,
Posted in Natural Language Processing
One comment on “Language Detection API
  1. Anonymous says:

    Hi there,I checked your article named “Language Detection API”. Your writing style is nice, keep doing what you`re doing!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

DZone

DZone MVB

Java Code Geeks
Java Code Geeks
%d bloggers like this: