Detect Language - Detect Language

The API returns the detected language and a numeric score between 0 and 1.
Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported.

POST {Endpoint}/text/analytics/v2.0/languages

URI Parameters

Name In Required Type Description
Endpoint
path True
  • string

Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).

Request Body

Name Type Description
documents

Responses

Name Type Description
200 OK

A successful call results in the detected language with the highest probability for each valid document

Other Status Codes

Error Response

Security

Ocp-Apim-Subscription-Key

Type: apiKey
In: header

Examples

Successful Detect Language request

Sample Request

POST {Endpoint}/text/analytics/v2.0/languages
{
  "documents": [
    {
      "id": "1",
      "text": "If this demo doesn't work I will be super sad"
    },
    {
      "id": "2",
      "text": "Español es muy difícil de aprender"
    },
    {
      "id": "3",
      "text": "I really really love machine learning"
    },
    {
      "id": "4",
      "text": "Le soleil se lève à l'Est"
    }
  ]
}

Sample Response

{
  "documents": [
    {
      "id": "1",
      "detectedLanguages": [
        {
          "name": "English",
          "iso6391Name": "en",
          "score": 1
        }
      ]
    },
    {
      "id": "2",
      "detectedLanguages": [
        {
          "name": "Spanish",
          "iso6391Name": "es",
          "score": 1
        }
      ]
    },
    {
      "id": "3",
      "detectedLanguages": [
        {
          "name": "English",
          "iso6391Name": "en",
          "score": 1
        }
      ]
    },
    {
      "id": "4",
      "detectedLanguages": [
        {
          "name": "French",
          "iso6391Name": "fr",
          "score": 1
        }
      ]
    }
  ],
  "errors": []
}

Definitions

BatchInput
DetectedLanguage
ErrorRecord
ErrorResponse
Input
InternalError
LanguageBatchResult
LanguageBatchResultItem

BatchInput

Name Type Description
documents

DetectedLanguage

Name Type Description
iso6391Name
  • string

A two letter representation of the detected language according to the ISO 639-1 standard (e.g. en, fr).

name
  • string

Long name of a detected language (e.g. English, French).

score
  • number

A confidence score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true.

ErrorRecord

Name Type Description
id
  • string

Input document unique identifier the error refers to.

message
  • string

Error message.

ErrorResponse

Name Type Description
code
  • string
innerError
message
  • string
target
  • string

Input

Name Type Description
id
  • string

Unique, non-empty document identifier.

text
  • string

InternalError

Name Type Description
code
  • string
innerError
message
  • string

LanguageBatchResult

Name Type Description
documents
errors

LanguageBatchResultItem

Name Type Description
detectedLanguages

A list of extracted languages.

id
  • string

Unique document identifier.