Directionality

Analyze directionality

Resolve the RTL/LTR structure of one string (text) or a whole record at once (fields, a map of name → string). Returns the base direction, whether the text mixes directions, the dominant language and script, and two run lists: runs exactly as the Unicode Bidirectional Algorithm resolves them, and display_runs that keep every left-to-right unit (a price, a range, a date, a model number) whole.

Quota. Deterministic, no model. Does not consume the character quota; counts toward the rate limit only.

Limits. Send exactly one of text or fields. Up to 100 fields and 20,000 characters in total. Idempotent: the same input always gives the same output.

post/v1/analyze

Request

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

Request body

textstring

A single string, up to 20,000 characters. Send this or fields.

fieldsobject

A map of field name → string, up to 100 fields and 20,000 characters in total. Send this or text.

base'auto' | 'ltr' | 'rtl'

Paragraph direction to resolve against. auto (default) uses the first strong letter.

Example request

{
  "text": "שלום world",
  "fields": {
    "title": "מסמך Q3 ready",
    "subtitle": "Read the summary"
  },
  "base": "auto"
}

Response

Directionality analysis

fieldsobject

Present when the request sent fields: one analysis per field name.

Example response

{
  "analysis": {
    "dir": "rtl",
    "mixed": true,
    "lang": "he",
    "script": "Hebr",
    "runs": [
      {
        "text": "שלום ",
        "dir": "rtl",
        "script": "Hebr",
        "lang": "he",
        "end": 5
      }
    ],
    "display_runs": [
      {
        "text": "שלום ",
        "dir": "rtl",
        "script": "Hebr",
        "lang": "he",
        "end": 5
      }
    ]
  }
}

Changes

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