Directionality

Detect language

Detect the dominant language, script and base direction of a string, with one segment per language. Built for short, code-switched input such as chat messages, search queries and voice transcripts: a brand, product name or acronym inside a Hebrew or Russian sentence ("PayPal", "iPhone", "API") does not change the dominant language, and Hebrew prefixes joined by a hyphen ("ה-API") are split correctly. Links and email addresses are ignored. Latin script is tagged en.

Quota. Deterministic, no model. Does not consume the character quota.

Limits. text up to 20,000 characters. Idempotent.

post/v1/detect

Request

  • Base URL: https://hc.itsbaba.com
  • URL: https://hc.itsbaba.com/v1/detect
  • Auth: HTTP bearer

Request body

textstring required

Text to classify, up to 20,000 characters. Built for short, code-switched input.

Example request

{
  "text": "Можно оплатить через PayPal сегодня?"
}

Response

Detection

langstring required

Dominant language (BCP 47). Latin script is tagged en.

scriptstring required

Dominant ISO 15924 script.

dir'ltr' | 'rtl' required

Base direction of the dominant language.

confidencenumber required

Share of letters in the dominant language, 0 to 1.

Example response

{
  "lang": "ru",
  "script": "Cyrl",
  "dir": "ltr",
  "confidence": 0.941,
  "segments": [
    {
      "text": "PayPal ",
      "start": 21,
      "end": 28,
      "script": "Latn",
      "lang": "en"
    }
  ],
  "languages": [
    {
      "lang": "ru",
      "share": 0.941
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.