Dialect and orthography hints

Available in the API
Tell the engine which spelling convention your clients expect. A hint changes which spelling ranks first. It never changes which spellings are possible, and the gateway never re-ranks what the engine returns.

Available in the API on POST /v1/transliterate and in transliterate batches. /v1/variants accepts and reports the same hints but does not pass them to the engine yet, so they do not change its ranking.

What it is for

One Arabic name has several correct Latin spellings. Kassem reads naturally in Beirut, Qasim in the Gulf, and an Egyptian reader expects Gamal where a Levantine one writes Jamal. If you know where your clients are, say so, and spellings in their convention move up the list.

Hints rank Arabic to Latin output. They do nothing for Latin to Arabic, where the gateway sends no hint at all.

Request fields

FieldTypeMeaning
country_hintstringISO 3166-1 alpha-2 in upper case, for example LB. Sets the dialect and orthography defaults for that country.
dialect_hintstringauto, levantine, gulf, egyptian, maghrebi, msa. Default auto.
orthographystringauto, english, french. Default auto. Whether Latin spellings follow English or French habits (Shehadeh or Chehade).
hints.sexstringmale, female. Transliterate only. Optional; see the sex hint.

Examples

The same name with a country hint and with a dialect hint. The third spelling changes from Jamale Kasem to Gamal Kassem; the set of spellings the engine can produce stays the same.

A country hint: Lebanon

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":5,"country_hint":"LB"}'
Response 200
{
  "id": "tr_example",
  "object": "transliteration",
  "source_script": "arab",
  "target_script": "latn",
  "results": [
    {
      "text": "Jamale Kassem",
      "rank": 1
    },
    {
      "text": "Jamal Kassem",
      "rank": 2
    },
    {
      "text": "Jamale Kasem",
      "rank": 3
    },
    {
      "text": "Jamal Kasem",
      "rank": 4
    },
    {
      "text": "Jmal Kassem",
      "rank": 5
    }
  ],
  "tokens": null,
  "hints": {
    "dialect": "levantine",
    "orthography": "french",
    "source": "country",
    "applied": "engine",
    "convention": "lb-fr"
  },
  "warnings": [],
  "engine_version": "1.0.0",
  "band": "medium",
  "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.

A dialect hint: Egyptian

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":5,"dialect_hint":"egyptian"}'
Response 200
{
  "id": "tr_example",
  "object": "transliteration",
  "source_script": "arab",
  "target_script": "latn",
  "results": [
    {
      "text": "Jamale Kassem",
      "rank": 1
    },
    {
      "text": "Jamal Kassem",
      "rank": 2
    },
    {
      "text": "Gamal Kassem",
      "rank": 3
    },
    {
      "text": "Jamale Kasem",
      "rank": 4
    },
    {
      "text": "Gmal Kassem",
      "rank": 5
    }
  ],
  "tokens": null,
  "hints": {
    "dialect": "egyptian",
    "orthography": "auto",
    "source": "request",
    "applied": "engine",
    "convention": "eg-en"
  },
  "warnings": [],
  "engine_version": "1.0.0",
  "band": "medium",
  "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.

Reading hints in a response

Every transliterate and variants response has a hints object: what the gateway resolved, and whether the engine used it.

FieldTypeMeaning
dialect, orthographystringThe values in effect after defaults. From the request when you set either, else from the country, else auto.
sourcestringrequest, country or default: where those values came from.
appliedstringengine when the engine says it ranked with a convention resolved from your hint or country; none otherwise. rerank is reserved and never returned.
conventionstringPresent only when applied is engine: the engine's convention code, for example lb-fr.
sexstringPresent only when you sent hints.sex: your value, echoed.

Read applied, not source, to know whether a hint changed anything. applied: none means the ranking is the one you get with no hint.

How hints reach the engine

The gateway sends the engine at most one thing: a country, or one convention code.

  1. Latin to Arabic (target_script: "arab", Latin input with no target, or Arabizi input): nothing is sent. applied is none.
  2. Dialect and orthography both auto: the country hint alone is sent, and the engine maps it (Lebanon to lb-fr, then lb-en).
  3. msa: nothing is sent. Modern Standard Arabic has no convention code.
  4. A country whose default dialect is the one you asked for (or you left the dialect on auto): that country's code with your orthography, or its own orthography when yours is auto. levantine with LB gives lb-fr; english with LB gives lb-en.
  5. Otherwise the dialect's own code, from the table below.
  6. A pair with no code sends nothing, not even the country: gulf or egyptian with french, maghrebi with english, or an orthography alone without a country that has it.
DialectEnglishFrench
levantinelevant-enlb-fr
gulfgulf-ennone
egyptianeg-ennone
maghrebinonema-fr
msanonenone

Countries and conventions

Countries with defaults. A country_hint outside this table resolves to msa and english with source: country; the engine has no convention for it, so applied stays none.

CountryCodeDefault dialectDefault orthographyEngine conventions
LebanonLBlevantinefrenchlb-fr, then lb-en
SyriaSYlevantineenglishlevant-en
JordanJOlevantineenglishlevant-en
Palestinian TerritoriesPSlevantineenglishlevant-en
Saudi ArabiaSAgulfenglishgulf-en
United Arab EmiratesAEgulfenglishgulf-en
KuwaitKWgulfenglishgulf-en
QatarQAgulfenglishgulf-en
BahrainBHgulfenglishgulf-en
OmanOMgulfenglishgulf-en
YemenYEgulfenglishye-en
IraqIQgulfenglishiq-en
EgyptEGegyptianenglisheg-en
SudanSDegyptianenglishsd-en
MoroccoMAmaghrebifrenchma-fr
AlgeriaDZmaghrebifrenchdz-fr, then ma-fr
TunisiaTNmaghrebifrenchtn-fr, then ma-fr
LibyaLYmaghrebienglishly-en
MauritaniaMRmaghrebifrenchmr-fr, then ma-fr

The sex hint

Some given names are spelled differently for men and women in Latin script. If your record already holds the person's sex, pass it and the engine can prefer the matching dictionary entry for an ambiguous given name, Arabic to Latin.

  • Client-supplied only. The API never infers, stores or returns a sex of its own. Leave the field out when you do not know.
  • It ranks spellings; it is not a statement about anyone, and the response only echoes your value in hints.sex.
  • Any value other than male or female, or another key inside hints, is a validation_error.

A sex hint the client already holds

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,"hints":{"sex":"male"}}'
Response 200
{
  "id": "tr_example",
  "object": "transliteration",
  "source_script": "arab",
  "target_script": "latn",
  "results": [
    {
      "text": "Hussein",
      "rank": 1
    },
    {
      "text": "Hussain",
      "rank": 2
    }
  ],
  "tokens": null,
  "hints": {
    "dialect": "auto",
    "orthography": "auto",
    "source": "default",
    "applied": "none",
    "sex": "male"
  },
  "warnings": [],
  "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.

Edge cases

  • Hints in a batch work per item, or once for all items in defaults.
  • Variants report hints with applied: none: the hints are not forwarded to the engine on that endpoint yet. Normalise accepts country_hint and does not use it today.
  • A hint never adds or removes a spelling, so a spelling you need can still appear lower in the list. Ask for more results with max_results rather than relying on rank 1.
  • GET /v1/meta lists the accepted dialect, orthography and sex values.

Errors

An unknown dialect or orthography, a lower-case or three-letter country code, or an unknown hints key is 422 validation_error with param naming the field. See the errors guide for the rest.

Limits and units

Hints are free: a call costs the same units with or without them (one per transliteration).