Skip to content

Latest commit

 

History

History
165 lines (129 loc) · 3.92 KB

ai.text.dictionary.md

File metadata and controls

165 lines (129 loc) · 3.92 KB

ai.text.dictionary

This is an intent to get meanings of text in selected language.

Basic usage

To dictionary a text, send a POST request to Intento API at https://api.inten.to/ai/text/dictionary. Specify the source text, source and target languages and the desired provider in JSON body of the request as in the following example:

curl -XPOST -H 'apikey: YOUR_API_KEY' 'https://api.inten.to/ai/text/dictionary' -d '{
 "context": {
  "text": "kick",
  "from": "en",
  "to": "ru"
 },
 "service": {
  "provider": "ai.text.dictionary.yandex.dictionary_api.1-0"
 }
}'

The response contains the dictionary results grouped by part of speech and a service information:

{
 "results": [{"noun": ["\u043f\u0438\u043d\u043e\u043a"], "verb": ["\u043f\u0438\u043d\u0430\u0442\u044c"]}],
 "meta": {},
 "service": {
  "provider": {
   "id": "ai.text.dictionary.yandex.dictionary_api.1-0",
   "name": "Yandex Dictionary API"
  }
 }
}

If the provider doesn't have capabilities (e.g. language pairs) to process request, 413 error will be returned:

{
    "error": {
        "code": 413,
        "message": "Provider ai.text.dictionary.yandex.dictionary_api.1-0 constraint(s) violated: from (Source language)"
    }
}

Getting available providers

To get a list of available Machine Translation providers, send a GET request to https://api.inten.to/ai/text/dictionary.

curl -H 'apikey: YOUR_INTENTO_KEY' 'https://api.inten.to/ai/text/dictionary'

The response contains a list of the providers available for given constraints with an information on pricing etc:

[
  {
    "id": "ai.text.dictionary.yandex.dictionary_api.1-0",
    "name": "Yandex dictionary API",
    "score": 0,
    "price": 0
  }
]

Advanced usage

The list of providers may be further constrained by adding desired parameter values to the GET request:

curl -H 'apikey: YOUR_INTENTO_KEY' 'https://api.inten.to/ai/text/dictionary?from=en&to=es'
[
  {
    "id": "ai.text.dictionary.yandex.dictionary_api.1-0",
    "name": "Yandex dictionary API",
    "score": 0,
    "price": 0
  }
]

Supported languages

Getting list of supported languages

Will return an array of supported languages, for each language:

  • iso name
  • localized name (if locale parameter is provided); if there is no localized name, null is returned
  • intento code
  • client code (if the client calling the method has its own codes)
curl -H 'apikey: YOUR_INTENTO_KEY' 'https://api.inten.to/ai/text/dictionary/languages?locale=ru'
[
  {
    "iso_name": "Hebrew (modern)",
    "name": "иврит",
    "intento_code": "he",
    "client_code": "hebr"
  }
]

Getting full information on the supported language

For a given language code (intento internal or client’s) will show full metadata:

  • iso name
  • localized name (if locale parameter is provided); if there is no localized name, null is returned
  • intento code
  • iso codes (ones which are applicable)
  • providers’ codes (which map to this internal code)
  • client code (if the client calling the method has its own codes)
curl -H 'apikey: YOUR_INTENTO_KEY' 'https://api.inten.to/ai/text/dictionary/languages/he?locale=ru'
{
  "iso_name": "Hebrew (modern)",
  "name": "иврит",
  "intento_code": "he",
  "iso_639_1_code": "he",
  "iso_639_2t_code": "heb",
  "iso_639_2b_code": "heb",
  "iso_639_3_code": "heb",
  "provider_codes": {
  },
  "client_code": "hebr"
}

Setting your own language codes

To define your aliases to language codes, send a POST request to Intento API at https://api.inten.to/settings/languages. After 60 seconds, you can start using them.

curl -H 'apikey: YOUR_INTENTO_KEY' 'https://api.inten.to/settings/languages' --data '{"aliasforen":"en"}'
{
    "aliasforen": "en"
}

Settings can be retrieved using the GET request

curl -H 'apikey: YOUR_INTENTO_KEY' 'https://api.inten.to/settings/languages'
{
    "aliasforen": "en"
}