The new Language Identification API: lang-4.0

We are happy to announce that we are rolling out a new Language Identification API. This new API is called lang-4.0 and will be published as a private beta for a short time. After that, it will be publicly available for all MeaningCloud users.

Language Identification (LID) is a key task in Natural Language Processing. It is commonly used in pre-classification or document selection. Traditional LID methods like Markov chains offer good results for long texts. However, the precision for short texts tends to be worse.

We have observed that the ratio of relatively short texts analyzed in MeaningCloud shows a growing trend. Because of this we decided to improve our n-gram based lang-2.0.

The new lang-4.0 API is based in a deep neural network capable of detecting more than 180 different languages. It offers a high precision for both long and short texts without sacrificing performance.

Using lang-4.0

The API endpoint is available at:

https://api.meaningcloud.com/lang-4.0/identification

To use it, send a POST form (with Content Type multipart/form-data) with the following form data:

  • key: your API Key
  • txt: the text to analyze

Sample code

import requests

url = "https://api.meaningcloud.com/lang-4.0/identification"

payload={
    'key': 'YOUR API KEY HERE',
    'txt': 'YOUR TEXT HERE'
}

response = requests.request("POST", url, data=payload)

print(response.text)

const formdata = new FormData();
formdata.append("key", "YOUR API KEY HERE");
formdata.append("txt", "YOUR TEXT HERE");

const requestOptions = {
  method: 'POST',
  body: formdata,
  redirect: 'follow'
};

const response = fetch("https://api.meaningcloud.com/lang-4.0/identification", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

curl 'https://api.meaningcloud.com/lang-4.0/identification' \
    --form 'key="YOUR API KEY HERE"' \
    --form 'txt="YOUR TEXT HERE"'

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.meaningcloud.com/lang-4.0/identification',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('key' => 'YOUR API KEY HERE','txt' => 'YOUR TEXT HERE'),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Help us improve!

If you find some issue with lang-4.0 please drop us a line at support@meaningcloud.com.