Unicode

Available in the API
Before the engine sees a name, the gateway refuses what cannot be a name, removes what is invisible, maps look-alike characters and splits the name into tokens. The same rules run on every endpoint and on every batch item.

Available in the API on /v1/transliterate, /v1/variants, /v1/normalise and batches. Arabizi input is accepted on transliterate only.

What a name may hold

  • Arabic letters and marks, and Latin letters with their accents.
  • Spaces between tokens, and inside a token the apostrophes ' ’ ‘ ʿ ʾ `, the full stop, the comma and the hyphen.
  • No digits, unless you opt in to Arabizi. No symbols or emoji.
  • Letters of any other script are refused with unsupported_script.
  • The body itself must be UTF-8 JSON sent as application/json.

What the gateway cleans

In this order:

  1. Tabs and line breaks become spaces.
  2. Control characters, lone surrogates, private use and unassigned code points are refused, with their code point positions.
  3. Bidirectional controls, zero-width characters and tatweel (ـ) are removed.
  4. Arabic presentation forms and fullwidth Latin letters become their base letters.
  5. The Persian letters ی ک ۀ ے become the Arabic ي ك ة ي.
  6. Runs of spaces, including no-break spaces, collapse to one; the ends are trimmed; the result is put in Unicode NFC.
  7. In a token that is mostly Latin, Cyrillic and Greek look-alikes (for example Cyrillic а, о, р) become the Latin letters they imitate.

A cleaned input carries a warning

curl https://api.arabinames.assentify.com/v1/transliterate \
  -H "Authorization: Bearer $ARABINAMES_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"محـمد","target_script":"latn","max_results":2}'
Response 200
{
  "id": "tr_example",
  "object": "transliteration",
  "source_script": "arab",
  "target_script": "latn",
  "results": [
    {
      "text": "Mohamad",
      "rank": 1
    },
    {
      "text": "Mohammed",
      "rank": 2
    }
  ],
  "tokens": null,
  "hints": {
    "dialect": "auto",
    "orthography": "auto",
    "source": "default",
    "applied": "none"
  },
  "warnings": [
    "TATWEEL_REMOVED"
  ],
  "engine_version": "mock-1",
  "units": 1
}

Fixture spellings (engine_version mock-1), which is what a test key returns. A live key returns the engine's spellings in the same fields and bills the units shown; a test key bills 0.

Warnings

Cleaning never fails silently. Each change adds a code to warnings in the response:

WarningMeaning
BIDI_CONTROL_REMOVEDBidirectional control characters were removed.
ZERO_WIDTH_REMOVEDZero-width spaces, joiners or the byte order mark were removed.
TATWEEL_REMOVEDTatweel was removed.
PERSIAN_LETTER_MAPPEDA Persian letter form was mapped to its Arabic letter.
CONFUSABLE_MAPPEDA Cyrillic or Greek look-alike was mapped to Latin.
MIXED_SCRIPT_INPUTSome tokens are Arabic and some Latin.

Endpoints add their own warnings, such as SAME_SCRIPT_VARIANTS_UNAVAILABLE on variants or NAME_PARTS_UNAVAILABLE on normalise. New warning codes may appear within v1; log them rather than fail on them.

Tokens and scripts

  • Tokens are split on spaces. Each token's script is the one that holds at least 60% of its letters.
  • A token that mixes both scripts is split once where one script ends and the other begins, if both halves are clean. Otherwise it is refused with mixed_script_token.
  • A name whose tokens are in different scripts is accepted, with MIXED_SCRIPT_INPUT.

Arabizi input

Arabizi is Arabic typed in Latin letters and digits, such as 7asan. On /v1/transliterate, send input_format: "arabizi" and the digits 2, 3, 5, 6, 7, 8 and 9 are accepted inside a token that has a Latin letter and no Arabic letter. 0, 1 and 4, digit-only tokens and digits in Arabic tokens stay refused. Arabizi converts to Arabic: leave target_script out or set it to arab; latn is a validation_error.

Arabizi input, opted in

curl https://api.arabinames.assentify.com/v1/transliterate \
  -H "Authorization: Bearer $ARABINAMES_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"7asan 3abdallah","input_format":"arabizi","max_results":5}'
Response 200
{
  "id": "tr_example",
  "object": "transliteration",
  "source_script": "latn",
  "target_script": "arab",
  "results": [
    {
      "text": "حسن عبدالله",
      "rank": 1
    },
    {
      "text": "حصن عبدالله",
      "rank": 2
    },
    {
      "text": "حسان عبدالله",
      "rank": 3
    },
    {
      "text": "حاسن عبدالله",
      "rank": 4
    },
    {
      "text": "حصان عبدالله",
      "rank": 5
    }
  ],
  "tokens": null,
  "hints": {
    "dialect": "auto",
    "orthography": "auto",
    "source": "default",
    "applied": "none"
  },
  "warnings": [],
  "engine_version": "1.0.0",
  "band": "low",
  "abstained": false,
  "abstain_reasons": [],
  "units": 1
}

Engine output through /v1, as recorded on the examples page. Per-result provenance and versions are left out here for length.

Without the opt-in, a digit is refused:

A digit in a plain name

curl https://api.arabinames.assentify.com/v1/transliterate \
  -H "Authorization: Bearer $ARABINAMES_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Rami 2","target_script":"arab"}'
Response 422
{
  "type": "https://arabinames.assentify.com/docs/errors#invalid_name_characters",
  "title": "Invalid name characters",
  "status": 422,
  "code": "invalid_name_characters",
  "detail": "Disallowed characters at positions 0 of a token.",
  "param": "text",
  "request_id": "req_example",
  "doc_url": "https://arabinames.assentify.com/docs/errors#invalid_name_characters",
  "positions": [
    0
  ]
}

The gateway's answer, with its request id replaced. Errors bill zero units.

For a digit or symbol, positions counts from the start of the token that holds it; for a control character, from the start of the input.

Output checks

The rules run the other way too. Every spelling the engine returns is checked as a well-formed name in the target script (letters of that script, marks, spaces, hyphens, apostrophes and, in Latin, full stops; at most 200 characters, no doubled or edge spaces). A spelling that fails is dropped from the response. If none is left, the call fails with 502 engine_output_invalid and bills nothing.

What is left to the engine

The gateway only makes input safe and consistent. Folding spellings for comparison (alef forms, hamza, ta marbuta, diacritics) and recognising titles are the engine's work, so normalise returns محمد and مُحَمَّد as typed, each cleaned.

Errors

CodeWhen
invalid_name_charactersA control character, a digit, a symbol or another refused character. positions says where.
unsupported_scriptLetters outside Arabic and Latin script.
mixed_script_tokenA token mixes scripts and cannot be split cleanly.
empty_after_normalisationNothing left after cleaning.
name_too_longOver 200 characters after cleaning.
too_many_tokensOver 12 tokens after cleaning.
invalid_encodingThe body is not UTF-8.

All are 422 except invalid_encoding (400), all carry param: "text" where a name is at fault, and none is billed.

Limits

  • 200 characters (Unicode code points) per name, counted after cleaning.
  • 12 tokens per name.
  • 64 KB per request body, 2 MB for a batch.