From 10d858f62f72f181ed5a3b1b22759b45b82b48cf Mon Sep 17 00:00:00 2001 From: Marat Fatekhov Date: Wed, 19 Apr 2023 13:58:17 +0300 Subject: [PATCH 1/2] document gender control --- ai.text.translate.md | 112 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/ai.text.translate.md b/ai.text.translate.md index 304f50c..06c0c4c 100644 --- a/ai.text.translate.md +++ b/ai.text.translate.md @@ -32,6 +32,10 @@ This is an intent to translate text from one language to another. - [Memsource version of the XLIFF](#memsource-version-of-the-xliff) - [List of providers supporting a specified format](#list-of-providers-supporting-a-specified-format) - [Content processing](#content-processing) + - [Gender control processing](#gender-control-processing) + - [Basic usage](#basic-usage) + - [Supported languages](#supported-languages) + - [Custom injects](#custom-injects) @@ -964,3 +968,111 @@ More information about sets and rules can be found at `https://api.inten.to/sett } } ``` +## Gender control processing + +Some languages are sensitive to gender. Gender may depend on who is speaking and on who is the recipient of the phrase. +Machine translation providers cannot catch this content, and it results in heavy post-editing efforts. Gender control processing +provides the capabilities to specify the gender of speaker and audience. To use this processing one should specify the following API: + +### Basic usage + +```sh +curl -XPOST -H 'apikey: YOUR_API_KEY' 'https://api.inten.to/ai/text/translate' -d '{ + "context": { + "from": "en", + "to": "ru", + "text": "I have made something for you. Did you make anything for me?" + }, + "service": { + "async": false, + "trace": false, + "processing": { + "pre": ["gender_control"], + "config": { + "gender_control": { + "speaker": "female", + "audience": "male" + } + } + } + } +}' +``` + +Available values for `speaker` and `audience` are: +- `female` +- `male` +- `any` + +The response contains the following result: + +```json +{ + "results": [ + "Я приготовил для тебя кое-что. Ты приготовила для меня что-нибудь?" + ], + "meta": { + ... + "gender_control": { + "used": true, + "speaker": "male", + "audience": "female" + } + }, + ... +} +``` + +### Supported languages +Gender control currently supports translations from English(`en`) and Dutch(`nl`) languages. Target language selection is not limited. + + +### Custom injects +`Gender control` API provides the ability to specify `custom injects`, `prefixes` and `suffixes`, +that will be injected to the text before translation, and removed after. +Inject, suffix and prefix are not exposed to the user. + + +```json +{ + "context": { + "from": "en", + "to": "ru", + "text": "I have made something for you. Did you make anything for me?" + }, + "service": { + "async": false, + "trace": false, + "processing": { + "pre": ["gender_control"], + "config": { + "gender_control": { + "custom_inject": "boy says to a girl:" + } + } + } + } +} +``` +In case if `"custom_inject"` is specified, `speaker` and `audience` parameters are redundant. + +One can also provide custom `prefix` and `suffix` parameters: + +```json +{ + ... + "service": { + .. + "processing": { + "pre": ["gender_control"], + "config": { + "gender_control": { + ... + "prefix": "[[custom_gc_suffix[[" + "suffix": "]]custom_gc_suffix]]" + } + } + } + } +} +``` \ No newline at end of file From 9a0daf1fe8a72d32db4bbb7061d9965891ea01a0 Mon Sep 17 00:00:00 2001 From: Marat Fatekhov Date: Wed, 19 Apr 2023 14:11:15 +0300 Subject: [PATCH 2/2] format json --- ai.text.translate.md | 106 ++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/ai.text.translate.md b/ai.text.translate.md index 06c0c4c..66e76c0 100644 --- a/ai.text.translate.md +++ b/ai.text.translate.md @@ -971,7 +971,7 @@ More information about sets and rules can be found at `https://api.inten.to/sett ## Gender control processing Some languages are sensitive to gender. Gender may depend on who is speaking and on who is the recipient of the phrase. -Machine translation providers cannot catch this content, and it results in heavy post-editing efforts. Gender control processing +Machine translation providers cannot catch this content, and it results to heavy post-editing efforts. Gender control processing provides the capabilities to specify the gender of speaker and audience. To use this processing one should specify the following API: ### Basic usage @@ -986,15 +986,15 @@ curl -XPOST -H 'apikey: YOUR_API_KEY' 'https://api.inten.to/ai/text/translate' - "service": { "async": false, "trace": false, - "processing": { - "pre": ["gender_control"], - "config": { - "gender_control": { - "speaker": "female", - "audience": "male" - } - } - } + "processing": { + "pre": ["gender_control"], + "config": { + "gender_control": { + "speaker": "female", + "audience": "male" + } + } + } } }' ``` @@ -1008,17 +1008,17 @@ The response contains the following result: ```json { - "results": [ - "Я приготовил для тебя кое-что. Ты приготовила для меня что-нибудь?" - ], - "meta": { - ... - "gender_control": { - "used": true, - "speaker": "male", - "audience": "female" - } - }, + "results": [ + "Я приготовил для тебя кое-что. Ты приготовила для меня что-нибудь?" + ], + "meta": { + ... + "gender_control": { + "used": true, + "speaker": "male", + "audience": "female" + } + }, ... } ``` @@ -1035,44 +1035,48 @@ Inject, suffix and prefix are not exposed to the user. ```json { - "context": { - "from": "en", - "to": "ru", - "text": "I have made something for you. Did you make anything for me?" - }, - "service": { - "async": false, - "trace": false, - "processing": { - "pre": ["gender_control"], - "config": { - "gender_control": { - "custom_inject": "boy says to a girl:" - } - } + "context": { + "from": "en", + "to": "ru", + "text": "I have made something for you. Did you make anything for me?" + }, + "service": { + "async": false, + "trace": false, + "processing": { + "pre": [ + "gender_control" + ], + "config": { + "gender_control": { + "custom_inject": "boy says to a girl:" } - } + } + } + } } ``` -In case if `"custom_inject"` is specified, `speaker` and `audience` parameters are redundant. +In case when `"custom_inject"` is specified, `speaker` and `audience` parameters are redundant. One can also provide custom `prefix` and `suffix` parameters: ```json { - ... - "service": { - .. - "processing": { - "pre": ["gender_control"], - "config": { - "gender_control": { - ... - "prefix": "[[custom_gc_suffix[[" - "suffix": "]]custom_gc_suffix]]" - } - } + ... + "service": { + .. + "processing": { + "pre": [ + "gender_control" + ], + "config": { + "gender_control": { + ... + "prefix": "[[custom_gc_suffix[[", + "suffix": "]]custom_gc_suffix]]" } - } + } + } + } } ``` \ No newline at end of file