Systran Pure Neural Server Rest API
Systran Pure Neural Server Rest API
v9.1.1
2019-01-11
1. Overview .....................................................................................................................................10
2. New in v9.1.1 ...............................................................................................................................10
SYSTRAN.io and Classic REST API Changes for SPNS versus SES ................................................................ 10
Multimodal Speech Recognition API ........................................................................................................... 10
3. REST API Basics ...........................................................................................................................10
Server ......................................................................................................................................................... 10
Translation Resource (TR) ........................................................................................................................... 11
API Version ................................................................................................................................................. 12
HTTP and HTTPS ........................................................................................................................................ 12
REST........................................................................................................................................................... 12
REST from JavaScript ................................................................................................................................. 12
Cross Domain (CORS) ................................................................................................................................. 12
Silverlight Client Access Policy File ............................................................................................................. 13
Adobe Flash Cross-domain Policy File ......................................................................................................... 13
SPNS Data Format...................................................................................................................................... 13
Input and Output Text ................................................................................................................................ 14
JSONP Support ........................................................................................................................................... 14
Profile Selection ......................................................................................................................................... 14
Provided Examples ..................................................................................................................................... 15
4. SPNS REST API ........................................................................................................................... 16
Translation API Version................................................................................................................................17
Translation API Version Calling Style ...................................................................................................... 18
Translation API Version Request Parameters.......................................................................................... 18
Request with Query String Parameters .................................................................................................. 18
Response................................................................................................................................................ 18
Examples ............................................................................................................................................... 18
Translation Text Translate .......................................................................................................................... 19
Translation Text Translate Calling Style ................................................................................................. 19
Translation Text Translate Request Parameters ..................................................................................... 19
Request with Query String Parameters .................................................................................................. 21
Response................................................................................................................................................ 21
Examples ............................................................................................................................................... 21
Translation File Translate ............................................................................................................................ 24
Translation File Translate Calling Style ................................................................................................... 25
Translation File Translate Request Parameters ....................................................................................... 25
Request with Query String Parameters .................................................................................................. 26
Response................................................................................................................................................ 27
Examples ............................................................................................................................................... 29
Translation File Status ................................................................................................................................ 30
Translation File Status Calling Style........................................................................................................ 30
Translation File Status Request Parameters ........................................................................................... 31
Request with Query String Parameters .................................................................................................. 31
Response................................................................................................................................................ 31
Examples ............................................................................................................................................... 32
Translation File Result................................................................................................................................. 33
Translation File Result Calling Style ........................................................................................................ 33
Translation File Result Request Parameters............................................................................................ 33
2. New in v9.1.1
This describes the main REST API changes for this new release of SPNS.
SYSTRAN.io and Classic REST API Changes for SPNS versus SES
In SPNS 9.1.1, what was previously known as the SYSTRAN.io REST API is now known as the SPNS REST API. The
Classic REST API (also known a SYSTRAN REST V1 API) is still available for the present time, but is deprecated. It
is recommended that you consider updating your existing applications to use the SPNS REST API. For information
on the Classic REST API refer to the SES 8.6.2 REST API documentation.
Important!
Nuance Transcription Engine does not support /multimodal/speech/segment or
/multimodal/speech/align services.
After obtaining an API key, your application can append the request parameter key=yourAPIKey to all request
URLs. The API key is safe for embedding in URLs and does not require any encoding.
API Version
The SPNS REST API provides an API to query the version of an API. With SPNS, several API groups are supported:
Translation REST API (or /translation), Resources Corpus REST API (or /resources/corpus), Resources Dictionary
REST API (or /resources/dictionary), Language Detection REST API (or /nlp/lid) and Multimodal REST API (or
/multimodal). Each group has its own API version. Prior to SES 8.5, the API version was “1.0.0” for all. With the
release of SPNS 9.1.1, the version is now “2.1.1” for the Translation REST API, “2.0.0” for the Multimodal REST
API, and “1.0.0” for the other API groups.
REST
You can use the SPNS with the REST (see reference [1]) calling style. Access the SPNS REST API service endpoint
using the REST HTTP verb, and pass the details of all service requests as request parameters. The typical
response when the request succeeds is the HTTP status code “200”. The other status codes are as follows.
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-
policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
JSONP Support
All APIs support JSONP by providing a callback function name parameter. This will encapsulate the response body
this way:
For example, for a /translation/supportedLanguages call with the callback set to supportedLanguagesCallback the
response body will be similar to the following:
supportedLanguagesCallback({
"warning": "", /* Warning at request level */
"error": "", /* Error at request level */
"languagePairs": [
{
"source": "en", /* source language */
"target": "fr", /* source language */
"profiles": [
{
"id": "2abed45f-5cd2-46fd-9962-11db4ac53309",
"private": true
}
]
}
]
});
Profile Selection
In SES 8.4.2 and prior releases, profiles were selected by an integer profile identifier or ID (0..n). The profile ID
was assigned by the user through the SES console and different translators for different language pairs could
share the same profile ID. With newer SES releases (SES 8.5 and later), translators are automatically assigned
unique profile IDs that are UUIDs (Universally Unique Identifiers are complex values, for example, “9321408e-
2574-4408-afa3-8f970131d57a”). A translator (TR) can be selected by its UUID, but the recommended method is
to choose a translator using “selectors”. The available selectors are “owner”, “domain” and “size”. The “owner” is
the profile creator and the “domain” is the main topic covered by the translator, such as “IT”, “Medical” or a
general-purpose domain such called “Generic”. The “size” refers to the computing resource required by a
translator in terms of disk space and memory, but is also related to the quality of the translation. A small size
(called “S”) uses less computing resources and translates quicker, while sacrificing some quality. A medium size
(called “M”) uses more computing resources though it translates slower, while generating better translations.
Those not frequently used, there is also a large size (called “L”). With the advent of SYSTRAN’s PNMT (neural
network-based translators), these typically are “M” size like SPE or SMT translators. When the SPNS translation
API services are provided with selectors, it will choose the closest matching translator based on the selector
values. The default size is “M” if none is specified and the default domain is “Generic”.
Below are some examples illustrating how selectors work in identifying a TR.
Example 1:
• Wanted route: TR for EN/FR (English-to-French) owner: Self, domain: IT, size: L
• Order of checked routes (from first to last):
- TR for EN/FR, Self | IT | L
- TR for EN/FR, Self | IT | M
- TR for EN/FR, Self | IT | S
- TR for EN/FR, Self | Generic | L
- TR for EN/FR, Self | Generic | M
- TR for EN/FR, Self | Generic | S
- TR for EN/FR, Systran | IT | L
- TR for EN/FR, Systran | IT | M
- TR for EN/FR, Systran | IT | S
- TR for EN/FR, Systran | Generic | L
- TR for EN/FR, Systran | Generic | M
- TR for EN/FR, Systran | Generic | S
Example 2:
• Wanted route: TR for EN/FR (English-to-French) owner: Self, domain: IT, size: S
• Order of checked routes (from first to last):
- TR for EN/FR, Self | IT | S
- TR for EN/FR, Self | Generic | S
- TR for EN/FR, Systran | IT | S
- TR for EN/FR, Systran | Generic | S
Example 3:
Note that if none of the TRs for a language pair include a domain of “Generic” (must be exactly this term – the
match is case sensitive), then a TR may not be identified when using selectors that include a non-Generic domain.
In this case, SPNS will return an error regarding no matching routes (“Route not found” or “No Queue defined for
Route”).
Provided Examples
All the examples provided use httpie [6] for better readability. This tool requires Python (see
https://www.python.org) and pip (installation depends on the platform). These examples will work on Linux and
Windows platforms.
The REST API services supported by the SPNS REST API are listed in the table below.
• All API services are executed using the HTTP GET and POST methods as noted.
• It is recommended that the API key should always be the “Android”, “iOS” or “server” – depending on the
application platform. Do not use the “Browser” or untyped API keys. For translations, add the parameter
“bundleId” (with your application bundle identifier) for iOS API keys, or add the parameters
“packageName” (with your application package name) and “certFingerprint” (with your application
certificate fingerprint) for Android API keys.
• Language codes are generally ISO 639-1 two-letter codes, with a few SYSTRAN-specific exceptions.
These are listed in Section 6. For the Multimodal Speech REST APIs, the language code returned are ISO
639-2/B three-letter codes also listed in Section 6. The language codes must be lower case.
• Parameter value case is important.
• Almost all service parameters are specified as query key/value data. The exceptions to this are noted.
Note
The JSON output in all the provided examples is formatted for readability.
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"version": "2.1.1"
}
Examples
Get API version for Translation REST API
http -v GET <SES Gateway URL>/translation/apiVersion key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 19
Content-Type: application/json; charset=utf-8
Date: Fri, 16 Nov 2018 22:41:23 GMT
Vary: Accept-Encoding
{
"version": "2.1.1"
}
• key
• input
• target
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "An error occurred",
"info": {
"statusCode": 500,
"message": "Internal Error"
}
},
"requestId": "55b753d87f2d682a607b8be1",
"outputs": [
{
"error": "Internal error",
"detectedLanguage": "en",
"detectedLanguageConfidence": 0.9260174036026001,
"output": "le chien",
"backTranslation": "the dog",
"source": "the dog"
}
]
}
Examples
Text translation with information
http -v POST <SPNS Gateway URL>/translation/text/translate key==<API key> target==fr
withInfo==true input=="Hello and have a good day"
POST /translation/text/translate?key=<API
key>&target=fr&withInfo=true&input=Hello+and+have+a+good+day HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Thu, 20 Dec 2018 00:09:04 GMT
Transfer-Encoding: chunked
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"outputs": [
{
"info": {
"lid": {
"confidence": 0.788307785987854,
"language": "en"
},
"selected_routes": [
{
"routes": [
{
"profileId": "e00bfc3c-b36c-453c-ad34-43f0b191ea1d",
"queue": "575cec93-7581-4fee-a315-6808e77ef99c",
"service": "Filter",
"version": "2.0"
}
],
"stepName": "filter-import"
},
{
"routes": [
{
"profileId": "12450906-5560-4bb1-aed6-1d938a8f3c26",
"queue": "flow",
"selectors": {
"domain": "Generic",
"owner": "Systran",
"size": "M",
"tech": {
"name": "Docker-OpenNMT-ctranslate",
"type": "NMT"
}
},
"service": "Translate_en_fr",
"version": "2.0"
},
{
"profileId": "b5cabe50-43d5-4cc9-8bf7-06ecb63f38d2",
"queue": "b8efe929-c7ab-48bb-a5e2-98075ef99031",
"selectors": {
"domain": "Generic",
"owner": "Systran",
"size": "M",
"tech": {
{
"input": [
"Hello and have a good!",
"Once in a blue moon"
],
"key": "<API key>"
}
HTTP/1.1 200 OK
{
"outputs": [
{
"output": "Bonjour et bon !"
},
{
"output": "Une fois dans une lune bleue"
}
]
}
• Plain text
• HTML
• TMX
• XLIFF
• Microsoft Word DOC and DOCX
• Microsoft PowerPoint PPTX
• Microsoft Excel XLSX
• Adobe PDF (translated to DOCX format)
• Rich Text Format (RTF)
• OpenDocument Text ODT
• OpenDocument Spreadsheet ODS
• OpenDocument Presentation ODP
This supports translation synchronously or asynchronously. When a synchronous translation request is made, the
calling application waits until the translation is complete. When an asynchronous translation request is made, the
call is immediately returned with a request identifier (ID). The calling application must follow up or poll with
status checks providing the request ID. Upon completion of the translation, the translation results are retrieved.
Important!
It is generally recommended to use the asynchronous pattern for performing file translations.
Since translations may be quick or lengthy (depending on the quantity of text to translate and
the language pair translator selected), this provides better use of the calling application
resources as well as those of SPNS.
• key
• input
• target
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object in asynchronous mode. In synchronous mode, the response will be
either the translated document directly, or if the withSource is or withInfo parameter is specified a multipart
response.
For asynchronous:
{
"requestId": "54a3d860e62ea467b136eddb" /* Request identifier to use to get the status,
the result of the request and to cancel it */
"error": {
"message": "" /* Error at request level */
"info": {}
}
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 1294
Content-Type: multipart/mixed; boundary="1b28b5eb13ca11dc3238ef1f0a46d90a5a13fdd5"
Date: Thu, 20 Dec 2018 00:28:06 GMT
Vary: X-HTTP-Method-Override
--1b28b5eb13ca11dc3238ef1f0a46d90a5a13fdd5
part-name: info
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
C'est un chien <b>noir</b>.</html>
--1b28b5eb13ca11dc3238ef1f0a46d90a5a13fdd5--
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 1350
Content-Type: multipart/mixed; boundary="c4840f2ba76f8d1afa0d82dab194fedc0a212461"
Date: Thu, 20 Dec 2018 00:18:07 GMT
Vary: X-HTTP-Method-Override
--c4840f2ba76f8d1afa0d82dab194fedc0a212461
part-name: info
{"lid":{"confidence":0.7557401657104492,"language":"en"},"selected_routes":[{"routes":[{"profi
leId":"e00bfc3c-b36c-453c-ad34-43f0b191ea1d","queue":"575cec93-7581-4fee-a315-
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
C'est un chien <b>noir</b>.</html>
--c4840f2ba76f8d1afa0d82dab194fedc0a212461--
Examples
Synchronous HTML file translation (auto->French) with information
more example.html
<html>This is a <b>black</b> dog.</html>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 1350
Content-Type: multipart/mixed; boundary="184b3cd7fd5e3640f8f3e00cf76e1039199203d5"
Date: Thu, 20 Dec 2018 00:30:07 GMT
Vary: X-HTTP-Method-Override
--184b3cd7fd5e3640f8f3e00cf76e1039199203d5
part-name: info
{"lid":{"confidence":0.7557401657104492,"language":"en"},"selected_routes":[{"routes":[{"profi
leId":"e00bfc3c-b36c-453c-ad34-43f0b191ea1d","queue":"575cec93-7581-4fee-a315-
6808e77ef99c","service":"Filter","version":"2.0"}],"stepName":"filter-
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
C'est un chien <b>noir</b>.</html>
--184b3cd7fd5e3640f8f3e00cf76e1039199203d5--
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 41
Date: Thu, 20 Dec 2018 18:23:18 GMT
Vary: X-HTTP-Method-Override
{"requestId":"5c1bde165d634ab2e5c331ea"}
• key
• requestId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "An error occured",
"info": {
"statusCode": 500,
"message": "Internal Error"
}
},
"batchId": "54a3d860e62ea467b136eddb",
"cancelled": true,
"createdAt": 1242234432,
"description": "success",
"expireAt": 1242234900,
"finishedAt": 0,
"finishedSteps": 3,
• registered
• import
• started
• export
• finished
• error
The import status refers to the initial processing within the Filter translator resource (TR) to put the incoming text
or document in a standardized form (a specialized XML format). The started status refers to the translation by a
language-pair-specific TR (for example, RU/EN). The export status refers to the post-translation step of
converting the translate results from the intermediate standardized form (XML), back to the original source form
(Word DOCX, Excel XLSX, HTML, plain text, and so forth). The translation result is available when the value of the
status field is finished. The translation request is unsuccessful when the value of the status field is error.
Examples
Check asynchronous file translation status
http -v GET <SPNS Gateway URL>/translation/file/status key==<API key> requestId==<request
identifier>
{
"requestId": "5c1bde165d634ab2e5c331ea"
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 278
Content-Type: application/json; charset=utf-8
Date: Thu, 20 Dec 2018 18:31:43 GMT
Vary: Accept-Encoding
{
"cancelled": false,
"createdAt": 1545330198944,
"description": "",
"expireAt": 1545348199096,
"failedSteps": 0,
"finishedAt": 1545330199096,
"finishedSteps": 1,
• key
• requestId
Response
HTTP Status Code
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
C'est un chien <b>noir</b>.</html>
Examples
Retrieve asynchronous file translation results
http -v GET <SPNS Gateway URL>/translation/file/result key==<API key> requestId==<request
identifier>
{
"requestId": "5c1bde165d634ab2e5c331ea"
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 110
Date: Thu, 20 Dec 2018 18:32:56 GMT
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
C'est un chien <b>noir</b>.</html>
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "An error occured",
"info": {
"statusCode": 500,
"message": "Internal Error"
}
}
}
Examples
Cancel asynchronous file translation
http -v GET <SPNS Gateway URL>}/translation/file/cancel key==<API key> requestId==<request
identifier>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 15
Content-Type: application/json; charset=utf-8
Date: Thu, 20 Dec 2018 18:37:05 GMT
Vary: Accept-Encoding
{
"cancel": true
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"batchId": "54a3d860e62ea467b136eddb",
"error": {
"message": "An error occured",
"info": {
"statusCode": 500,
"message": "Internal Error"
}
}
}
Examples
Create translation batch
http -v POST <SPNS Gateway URL>/translation/file/batch/create key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 39
Content-Type: application/json; charset=utf-8
Date: Thu, 20 Dec 2018 18:52:32 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"batchId": "5c1be4f05d634ab2e5c331ee"
}
• key
• batchId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"cancelled": false,
"closed": false,
"createdAt": 1242234432,
"expireAt": 1242234900,
"finishedAt": 1242234700,
"requests": [
{
"id": "54a3d860e62ea467b136eddb",
"status": "pending"
}
],
Examples
Check file batch status after associating asynchronous file translation
http -v GET <SPNS Gateway URL>/translation/file/batch/status key==<API key>
batchId==5c1be4f05d634ab2e5c331ee
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 111
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 18:12:37 GMT
Vary: Accept-Encoding
{
"cancelled": false,
"closed": false,
"createdAt": 1545331952442.0,
"expireAt": null,
"finishedAt": null,
"requests": []
}
• key
• batchId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"status": "finished",
"error": {
"message": "An error occurred",
"info": {
"statusCode": 500,
"message": "Internal Error"
}
}
}
Examples
Close translation file batch
http -v GET <SPNS Gateway URL>/translation/file/batch/close key==<API key>
batchId==5c1be4f05d634ab2e5c331ee
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 16
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 18:13:31 GMT
Vary: Accept-Encoding
{
"status": "ok"
}
• key
• batchId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"status": "cancelled",
"error": {
"message": "An error occurred",
"info": {
"statusCode": 500,
"message": "Internal Error"
}
}
}
Examples
Cancel translation file batch
http -v POST <SPNS Gateway URL>/translation/file/batch/cancel key==<API key>
batchId==5c2668387fdd33aa3c943c1c
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 16
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 18:15:41 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"status": "ok"
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "An error occurred",
"info": {
"statusCode": 500,
"message": "Internal Error"
}
},
"languagePairs": [
{
"source": "en",
"target": "fr",
Examples
List all supported languages
http -v GET <SPNS Gateway URL>/translation/supportedLanguages key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:19:12 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
{
"languagePairs": [
{
"profiles": [
{
"id": "470179ac-fec2-4f1e-8572-2ee0724bd517",
"private": false
}
],
"source": "zh-Hant",
"target": "en"
},
{
"profiles": [
{
"id": "18822479-2691-44e2-8936-b5e93f1f69c5",
"private": false
}
],
"source": "ko",
"target": "en"
},
{
"profiles": [
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 186
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:22:24 GMT
Vary: Accept-Encoding
{
"languagePairs": [
{
"profiles": [
{
"id": "925f5cfa-2238-4431-835c-572dc6249e62",
"private": false
},
{
"id": "3f842316-17a2-43c8-8951-091236a21c19",
"private": false
}
],
"source": "fr",
"target": "en"
}
]
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"formats": [
{
"mimetypes": {
"input": "text/bitext",
"output": "text/bitext"
},
"name": "bitext"
}
]
}
Examples
List supported formats
http -v GET <SPNS Gateway URL>/translation/supportedFormats key==<API key>
{
"formats": [
{
"mimetypes": {
"input": "application/vnd.android.string-resource+xml",
"output": "application/vnd.android.string-resource+xml"
},
"name": "android"
},
{
"mimetypes": {
"input": "text/bitext",
"output": "text/bitext"
},
"name": "bitext"
},
{
"mimetypes": {
"input": "application/vnd.systran.document+boost",
"output": "application/vnd.systran.document+boost"
},
"name": "systran document (serialized boost)"
},
{
"mimetypes": {
"input": "text/html-old",
"output": "text/html-old"
},
"name": "old html"
},
{
"mimetypes": {
"input": "text/html",
"output": "text/html"
},
"name": "html"
},
{
"mimetypes": {
"input": "application/xhtml+xml",
"output": "application/xhtml+xml"
},
"name": "xhtml"
},
{
"mimetypes": {
"input": "application/vnd.jquery.globalize+json",
"output": "application/vnd.jquery.globalize+json"
Translation Profiles
Profiles are settings for translation that specify language pairs (source and target languages), domains and other
translation settings.
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "An error occurred",
"info": {
"statusCode": 500,
"message": "Internal Error"
}
},
"profiles": [
{
"id": 4,
"localization": {},
"name": "My Profile",
"source": "en",
Examples
List all translation profiles
http -v GET <SPNS Gateway URL>/translation/profiles key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:24:14 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
{
"profiles": [
{
"deactivated": false,
"id": "0240310b-a657-4ca0-8916-a6bd779de7c5",
"localization": {},
"name": "Translator DEEN Generic (S)",
"selectors": {
"domain": "Generic",
"owner": "Systran",
"size": "S"
},
"source": "de",
"target": "en"
},
{
"deactivated": false,
"id": "12450906-5560-4bb1-aed6-1d938a8f3c26",
"localization": {},
"name": "Translator NMT Generic (M) - ENFR",
"selectors": {
"domain": "Generic",
"owner": "Systran",
"size": "M"
},
"source": "en",
"target": "fr"
},
{
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 442
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:25:05 GMT
Vary: Accept-Encoding
{
"profiles": [
{
"deactivated": false,
"id": "3f842316-17a2-43c8-8951-091236a21c19",
"localization": {},
"name": "Translator NMT Generic (M) - FREN",
"selectors": {
"domain": "Generic",
"owner": "Systran",
"size": "M"
},
"source": "fr",
"target": "en"
},
{
"deactivated": false,
"id": "925f5cfa-2238-4431-835c-572dc6249e62",
"localization": {},
"name": "Translator FREN Generic (S)",
• key
• sourceText
• targetText
• target
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": { /* Error at request level */
"message": "string", /* Readable description of the error */
"statusCode": "integer",
"info": { /* Additional information about the error */
}
},
"feedbackId": "string" /* Feedback identifier */
}
Examples
Translation feedback add
http -v POST <SPNS Gateway URL>/translation/feedback/add key==<API key> source==en target==fr
sourceText=="Sample source text" targetText=="Exemple de texte source" status==new
problemServerity==minor suggesedTranslation=="Exemple texte source" comment=="Example comment"
POST /translation/feedback/add?key=<API
key>&source=en&target=fr&sourceText=Sample+source+text&targetText=Exemple+de+texte+source&stat
us=new&problemServerity=minor&suggesedTranslation=Exemple+texte+source&comment=Example+comment
HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: ssi-pnmt-benchmark-01.systran.us:8904
User-Agent: HTTPie/0.9.2
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
{
"feedbackId": "5c2ea597bb71e1148e5ef7d9"
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"version": "1.0.0"
Examples
Get API version for Language Detection REST API
http -v GET <SPNS Gateway URL>/nlp/lid/apiVersion key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 19
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:26:02 GMT
Vary: Accept-Encoding
{
"version": "1.0.0"
}
• key
• input
Caution
A parameter cannot be defined more than once. For example, if the source parameter is defined
in the Request Body it cannot be defined in the URL (and vice-versa).
Request Header
Content-Type: application/json
Request Body
Request with the document to analyze in body of the request (rawBody mode)
You can call the SPNS REST API by passing all the parameters except input parameters in the query string format.
If you use the rawBody=true option, you can send the document to analyze in the body of the request directly.
If you use the withSource=true option, the response will be a multipart document, with the first part for the
source document, and the second part for the translated document.
Request with the document to analyze in body of the request (form data mode)
You can call the SPNS REST API by passing all the parameters except input parameters in the query string format.
The input data may be included as form data.
If you use the withSource=true option, the response will be a multipart document, with the first part for the
source document, and the second part for the translated document.
Restrictions
• The requested URL, including parameters, must be less than 2K bytes.
• An element of the input array in the request body must be less than 5K bytes.
• The input arrays must have less than 1000 elements.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": "", /* Error at request level */
"detectedLanguages": [
{
"lang": "en",
"confidence": 0.8728542923927307
},
{
"lang": "nl",
"confidence": 0.06847826391458511
},
Examples
Language detection of text
http -v POST <SPNS Gateway URL>/nlp/lid/detectLanguage/document key==<API key> input=="Hello
and good day to you"
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 69
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:47:42 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"detectedLanguages": [
{
"confidence": 0.7850329279899597,
"lang": "en"
}
]
}
+-----------------------------------------+
| NOTE: binary data not shown in terminal |
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 69
Date: Fri, 28 Dec 2018 19:48:40 GMT
Vary: X-HTTP-Method-Override
{"detectedLanguages":[{"lang":"en","confidence":0.7557401657104492}]}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 69
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:50:35 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"detectedLanguages": [
{
"confidence": 0.7557401657104492,
"lang": "en"
}
]
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"formats": [
{
"mimetypes": {
"input": "text/bitext",
"output": "text/bitext"
},
"name": "bitext"
}
]
}
Examples
List supported formats
http -v GET <SPNS Gateway URL>/nlp/lid/supportedFormats key==<API key>
HTTP/1.1 200 OK
{
"formats": [
{
"mimetype": "application/vnd.android.string-resource+xml",
"name": "Android string-resource xml"
},
{
"mimetype": "text/bitext",
"name": "Bitext"
},
{
"mimetype": "application/vnd.openxmlformats-
officedocument.wordprocessingml.document",
"name": "Word document (docx xml)"
},
{
"mimetype": "text/html",
"name": "HTML"
},
{
"mimetype": "application/xhtml+xml",
"name": "XHTML"
},
{
"mimetype": "application/vnd.jquery.globalize+json",
"name": "JQuery globalize"
},
{
"mimetype": "application/vnd.systran.document+json",
"name": "SYSTRAN document (json)"
},
{
"mimetype": "application/vnd.systran.i18n+json",
"name": "JSON i18n"
},
{
"mimetype": "application/x-gettext",
"name": "Gettext po"
},
{
"mimetype": "text/x-java-properties",
"name": "Java properties"
},
{
"mimetype": "application/vnd.microsoft.net.resx+xml",
"name": "Resx"
},
{
"mimetype": "text/rtf",
"name": "RTF"
},
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"version": "1.0.0"
}
Examples
Get API version for Resources Dictionary REST API
http -v GET <SPNS Gateway URL>/resources/dictionary/apiVersion key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 19
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:58:26 GMT
Vary: Accept-Encoding
• key
The dictionary filters provide control over the dictionary information returned in the list. A sample filter (always in
JSON form) is shown below. The aspects of the filter are as follows.
• Overall
• Sort
• Match
{
"skip": 1,
"limit": 3,
"sort": {
"nbEntries": 1,
"comments": -1,
"name": 1,
"sourceLang": -1,
"targetLangs": 1
},
"match": {
"inSourceLang": [
In the following tables are the parameters for each filter aspect. All of the parameters are optional.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "Internal error",
"info": {}
},
"totalNoLimit": 3,
Examples
List dictionaries
http -v GET <SPNS Gateway URL>/resources/dictionary/list key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 19
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 19:58:26 GMT
Vary: Accept-Encoding
{
"version": "1.0.0"
}
@: ~/tests/spns-and-ses-tests/test15-httpie/9.1.1/spsn
[jordan@sdtrn01]$ ./xresources-dictionary-list
GET /resources/dictionary/list?key=<API key> HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: <SPNS Gateway URL>
User-Agent: HTTPie/0.9.2
{
"dictionaries": [
{
"id": "altmeaning-",
"name": "SYSTRAN Alternative Dictionary",
"sourceLang": "*",
"targetLangs": "*",
"type": "MAIN"
},
{
"comments": "SYSTRAN General Domain Dictionary",
"id": "[main_0]",
"name": "SYSTRAN Main Dictionary",
"sourceLang": "*",
"targetLangs": "*",
"type": "MAIN"
},
{
"comments": "The SYSTRAN Industries Terminology Dictionary describes the
Automotive Technology, Aviation/Space, Naval and Maritime, Metallurgy, and Military domains.",
"id": "[main_1]",
"name": "SYSTRAN Industries Dictionary",
"sourceLang": "*",
"targetLangs": "*",
"type": "MAIN"
},
{
"comments": "The SYSTRAN Business & News Terminology Dictionary describes the
Economics/Business, Legal and Political Science domains.",
"id": "[main_2]",
"name": "SYSTRAN Business Dictionary",
"sourceLang": "*",
"targetLangs": "*",
"type": "MAIN"
},
{
"comments": "The SYSTRAN Life Sciences Terminology Dictionary describes the Earth
Science, Medicine and Food Science domains.",
"id": "[main_3]",
"name": "SYSTRAN Life Sciences Dictionary",
"sourceLang": "*",
"targetLangs": "*",
"type": "MAIN"
},
{
"comments": "The SYSTRAN Colloquial Terminology Dictionary describes the
Colloquial (conversational) domain.",
"id": "[main_4]",
• key
• input
{
"dictionary": {
"sourceLang": "en",
"name": "My Dictionary",
"targetLangs": "fr",
In the following table are the parameters for dictionary information. All of the parameters are optional except for
sourceLang and type.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "Internal error",
"info": {}
},
"added": {
"comments": "My new dictionary enfr",
"id": "5649b6e55a3227a4df900a89",
"name": "My Dictionary",
"sourceLang": "en",
"targetLangs": "fr",
"type": "UD"
}
}
Examples
Add a new dictionary
{
"dictionary": {
"comments": "My new dictionary enfr",
"name": "dict-example",
"sourceLang": "en",
"targetLangs": "fr",
"type": "UD"
}
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 150
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 21:49:43 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"added": {
"comments": "My new dictionary enfr",
"id": "5c269a77f046e6adea661333",
"name": "dict-example",
"sourceLang": "en",
"targetLangs": "fr",
"type": "UD"
}
}
• key
• dictionaryId
• input
{
"name": "My Dictionary",
"sourceLang": "en",
"targetLangs": "fr,es",
"comments": "My Dictionary with new settings"
}
In the following table are the parameters for dictionary information. All of the parameters are optional.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "Internal error",
"info": {}
},
"updated": {
"comments": "My Dictionary with new settings",
"name": "My Dictionary",
"sourceLang": "en",
"targetLangs": "fr,es"
}
}
Examples
Update an existing dictionary
more dict-example-update.json
{
"dictionary": {
"sourceLang": "en",
"name": "dict-1",
"targetLangs": "fr",
"comments": "My updated dictionary enfr",
"type": "UD"
}
}
{
"dictionary": {
"comments": "My updated dictionary enfr",
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 112
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 21:50:21 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"updated": {
"comments": "My updated dictionary enfr",
"name": "dict-example",
"sourceLang": "en",
"targetLangs": "fr"
}
}
• key
• dictionaryId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be the exported dictionary in text form:
#ENCODING=UTF-8
#MULTI
#EN FR PRIORITY_FR COMMENTS_FR
cat chat ami 9
dog chien ami 9 Dog comment
Examples
Export an existing dictionary with its contents
http -v POST <SPNS Gateway URL>/resources/dictionary/export key==<API key>
dictionaryId==<dictionary identifier>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 139
Content-Type: text/bitext
Date: Fri, 28 Dec 2018 21:52:36 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
#ENCODING=UTF-8
#SUMMARY=dict-example
#DESCRIPTION=My updated dictionary enfr
#MULTI
#EN UPOS FR PRIORITY_FR COMMENTS_FR
dog noun chien 9
• key
• dictionaryId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
There is no response body.
Examples
Delete custom dictionary
http -v POST <SPNS Gateway URL>/resources/dictionary/delete key==<API key>
dictionaryId==<dictionary identifier>
{}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
Examples
List supported languages by dictionaries
http -v GET <SPNS Gateway URL>/resources/dictionary/supportedLanguages key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 250
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 22:18:37 GMT
Vary: Accept-Encoding
{
"languages": [
"ar",
"bg",
"bn",
"cs",
"cy",
"da",
"de",
"dr",
"el",
"en",
"es",
"et",
"fa",
"fi",
"fr",
"he",
"hi",
"hr",
• key
• input
• source
• target
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"warning": "string",
"error": {
"message": "Internal error",
"info": {}
},
"outputs": [
{
"output": {
"matches": [
{
"auto_complete": false,
"model_name": "mono-enfr.mod",
"other_expressions": [
{
"context": "",
"source": "borax dog",
"target": "borax chez le chien"
},
{
"context": "",
"source": "lucky dog",
"target": "veinard"
Examples
Look up entry “dog” in dictionary with English source and French target
http -v GET <SPNS Gateway URL>/resources/dictionary/lookup key==<API key> source==en
target==fr input==dog
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 22:31:15 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
{
"outputs": [
{
"output": {
"matches": [
{
"auto_complete": false,
"model_name": "mono-enfr.mod",
"other_expressions": [
{
"context": "",
"source": "hot dog",
"target": "hot dogs"
},
{
"context": "",
"source": "dog sled",
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "Internal error",
"info": {}
},
"languagePairs": [
{
"source": "en",
"target": "fr"
},
{
"source": "en",
Examples
List all supported languages for dictionary lookup
http -v GET <SPNS Gateway URL>/resources/dictionary/lookup/supportedLanguages key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 22:19:21 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
{
"languagePairs": [
{
"source": "ar",
"target": "en"
},
{
"source": "ar",
"target": "fr"
},
{
"source": "bg",
"target": "en"
},
{
"source": "cs",
"target": "en"
},
{
"source": "de",
"target": "en"
• key
• dictionaryId
The dictionary emtry filters provide control over the dictionary information returned in the list. A sample filter
(always in JSON form) is shown below. The aspects of the filter are as follows.
{
"skip": 0,
"limit": 3,
"sort": {
"targetLang": 1,
"targetConfidence": 1,
"sourceConfidence": 1,
"comments": 1,
"priority": 1,
"partOfSpeech": 1,
"target": 1,
"source": 1
},
"match": {
"ninTargetConfidence": [
75
],
"inTargetConfidence": [
100
],
"maxTargetConfidence": 100,
"minTargetConfidence": 0,
"ninSourceConfidence": [
75
],
"inSourceConfidence": [
100
],
"maxSourceConfidence": 100,
"minSourceConfidence": 0,
"ninPriority": [
3
],
"inPriority": [
0,
10,
9
],
"maxPriority": 10,
"minPriority": 0,
"ninTargetLang": [
"es"
],
"inTargetLang": [
"fr"
],
"regexComments": "",
"ninPartOfSpeech": [
"adj"
],
"inPartOfSpeech": [
"noun"
],
"regexTarget": "ba",
In the following tables are the parameters for each filter aspect. All of the parameters are optional.
{
"entries": [
{
"source": "boat",
"target": "bateau",
"partOfSpeech": "noun",
"priority": 9,
"comments": "",
"sourceConfidence": 100,
"targetConfidence": 100,
"sourceLang": "en",
"targetLang": "fr",
"sourceId": "5649f12e5a3227a4df900aee",
"targetId": "5649f12e5a3227a4df900aed"
}
],
"totalNoLimit": 1
}
Examples
List all dictionary entries
http -v POST <SPNS Gateway URL>/resources/dictionary/entry/list key==<API key>
dictionaryId==<dictionary identifier>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 271
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 22:36:56 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"entries": [
{
"comments": "",
"partOfSpeech": "noun",
• key
• dictionaryId
• input
{
"entry": {
"sourceLang": "en",
"targetLang": "fr",
"source": "dog",
"target": "chien",
"type": "translation",
"sourcePos": "noun",
"priority": "9"
In the following table are the parameters for dictionary information. All of the parameters are optional, except for
sourceLang, targetLang, and source.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "Internal error",
"info": {}
},
"entry": {
"confidence": "60.0000038",
"pos": "noun",
"status": "ok",
"type": "translation",
"sourceId": "5649e5ec5a3227a4df900ae3",
"targetId": "5649e5ec5a3227a4df900ae2",
"targetPos": "noun",
"source": "dog",
"target": "chien"
}
}
{
"entry": {
"priority": "9",
"source": "dog",
"sourceLang": "en",
"sourcePos": "noun",
"target": "chien",
"targetLang": "fr",
"type": "translation"
}
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 195
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Dec 2018 21:51:57 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"confidence": "100",
"pos": "noun",
"source": "dog",
"sourceId": "5c269afdf046e6adea661335",
"status": "ok",
• key
• dictionaryId
• input
{
"sourceId": "5649fad7d335da43344cc9bf",
"targetId": "5649fad7d335da43344cc9be",
"update": {
"sourceLang": "en",
"targetLang": "fr",
"source": "bug",
"target": "insecte",
"type": "translation",
"sourcePos": "noun",
"targetPos": "noun",
"priority": 3
}
}
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"confidence": "100",
"source": "bug",
"sourceId": "5649fb48d335da43344cc9c0",
"target": "insecte",
"targetId": "5649fad7d335da43344cc9be"
}
Examples
Update a dictionary entry
more dict-entry-cat-update.json
{
"sourceId": "5851a1e926d26127d163eb38",
"targetId": "5851948726d26127d163eb35",
"update": {
"sourceLang": "en",
"targetLang": "fr",
"source": "cat",
{
"sourceId": "5c2d1a9cf046e6adea66133b",
"targetId": "5c2d1a9cf046e6adea66133a",
"update": {
"priority": 4,
"source": "cat",
"sourceLang": "en",
"sourcePos": "noun",
"target": "chat",
"targetLang": "fr",
"targetPos": "noun",
"type": "translation"
}
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 127
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 21:30:08 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"confidence": "100",
"source": "cat",
"sourceId": "5c2d2a7bf046e6adea66133d",
"target": "chat",
"targetId": "5c2d1a9cf046e6adea66133a"
}
• key
• dictionaryId
• sourceLang
• inputFile
The inputFile entry data information is a tab-delimited text file. A sample is shown below. Note that the “<tab>”
value should be replaced with a tab character.
#ENCODING=UTF-8
#SUMMARY=Sample dictionary entries
#MULTI
#EN<tab>FR
black cat<tab>chat noir
cat<tab>chat
cats<tab>chats
white cat<tab>chat blanc
kitten<tab>chaton
{
"duplicates": 1,
"inserted": 95,
"total": 96
}
Examples
Import entries into existing dictionary (entries are tab-delimited)
more dict-entries.txt
#ENCODING=UTF-8
#SUMMARY=Sample dictionary entries
#MULTI
#EN FR
president président
presidents présidents
black cat chat noir
cat chat
cats chats
white cat chat blanc
kitten chaton
POST /resources/dictionary/entry/import?key=<API
key>&dictionaryId=5c2d1a64f046e6adea661339&sourceLang=en HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 230
Content-Type: application/json
Host: <SPNS Gateway URL>
User-Agent: HTTPie/0.9.2
{
"inputFile": "#ENCODING=UTF-8\n#SUMMARY=Sample dictionary
entries\n#MULTI\n#EN\tFR\npresident\tprésident\npresidents\tprésidents\nblack cat\tchat
noir\ncat\tchat\ncats\tchats\nwhite cat\tchat blanc\nkitten\tchaton\n\n"
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 39
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 21:34:44 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
• key
• dictionaryId
• input
The input entry is a JSON specifying the identifiers for the source or target. The source identifier is required,
while the target identifier is optional. A sample is shown below.
{
"entry": {
"sourceId": "5649e5ec5a3227a4df900ae3",
"targetId": "5649e5ec5a3227a4df900ae2"
}
}
The source and target identifiers can be determined from an entry listing (see Resources Dictionary Entry List).
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"status": "entry deleted with success"
}
Examples
Asynchronous file translation status check
more dict-entry-to-delete.json
{
"entry": {
"sourceId": "5c2d2e74f046e6adea661349",
"targetId": "5c2d2e74f046e6adea661348"
}
}
{
"entry": {
"sourceId": "5c2d2e74f046e6adea661349",
"targetId": "5c2d2e74f046e6adea661348"
}
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 39
Content-Type: application/json; charset=utf-8
{
"status": "entry deleted with success"
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"version": "1.0.0"
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 19
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 21:41:00 GMT
Vary: Accept-Encoding
{
"version": "1.0.0"
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"directories": [
"/MyProject/Technical",
"/MyProject/Administration"
],
"files": [
{
"id": "55af580d4cf4c7f74e7c8d1c",
"name": "/MyProject/gears.txt",
"createdAt": "Wed Jul 22 10:45:01 2015",
"format": "text/bitext",
"nbSegments": 5993,
"sourceLang": "fr",
"targetLangs": [
"en"
],
"status": "ok"
},
{
"id": "56af580d4cf4c8f74e7c9e9a",
"name": "/MyProject/balloon.tmx",
"createdAt": "Wed Jul 22 10:47:04 2015",
"format": "application/x-tmx+xml",
"nbSegments": 2496,
"sourceLang": "en",
"targetLangs": [
"fr",
"es"
],
Examples
List available corpora
http -v GET <SPNS Gateway URL>/resources/corpus/list key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 197
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 21:49:28 GMT
Vary: Accept-Encoding
{
"files": [
{
"createdAt": "Wed Jan 2 21:46:55 2019",
"format": "text/bitext",
"id": "5c2d314ff705707c0a8c3ecf",
"name": "/corpus_demo",
"nbSegments": 3,
"sourceLang": "en",
"status": "ok",
"targetLangs": [
"fr"
]
}
]
• key
• corpusId
• name
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"updated": true
}
Examples
Add a new tag to an existing corpus
http -v GET <SPNS Gateway URL>}/resources/corpus/update key==<API key> corpusId===<corpus
identifier> name==corpus_demo tag==animals
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 16
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 22:58:30 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"updated": true
}
• key
• corpusId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"id": "55af580d4cf4c7f74e7c8d1c",
"name": "/MyProject/gears.txt",
"createdAt": "Wed Jul 22 10:45:01 2015",
"format": "text/bitext",
"nbSegments": 5993,
"sourceLang": "fr",
"targetLangs": [
"en"
],
"status": "ok"
}
Examples
Retrieve details about specified corpus
http -v GET <SPNS Gateway URL>/resources/corpus/details key==<API key> corpusId==<corpus
identifier>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 201
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 22:07:03 GMT
Vary: Accept-Encoding
{
"corpus": {
"createdAt": "Wed Jan 2 22:05:02 2019",
"format": "text/bitext",
"id": "<corpus identifier>",
"name": "/corpus_demo",
"nbSegments": 3,
• key
• name
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
Examples
Asynchronous file translation status check
http -v GET <SPNS Gateway URL>/resources/corpus/exists key==<API key> name==corpus_demo
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 15
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 22:08:42 GMT
Vary: Accept-Encoding
{
"exists": true
}
• key
• name
• format
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"corpus": {
"id": "55af580d4cf4c7f74e7c8d1c"
}
}
Examples
Import a corpus text/bitext file into a corpus
more corpus_demo.txt
#TM
#EN FR
Why do cats purr? Pourquoi les chats ronronnent-ils?
When do dogs bark? Quand les chiens aboient?
The cat and dog are sleeping. Le chat et le chien dorment.
POST /resources/corpus/import?key=<API
key>&name=corpus_demo&format=text%2Fbitext&tag=cats&tag=dogs HTTP/1.1
{
"inputFile": "#TM\n#EN\tFR\nWhy do cats purr?\tPourquoi les chats ronronnent-ils?\nWhen do
dogs bark?\tQuand les chiens aboient?\nThe cat and dog are sleeping.\tLe chat et le chien
dorment.\n"
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 44
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 21:46:55 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"corpus": {
"id": "5c2d314ff705707c0a8c3ecf"
}
}
• key
• corpusId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be the exported corpus if successful, or if not a JSON body:
{
"error": {
"info": {
"code": 400
},
"message": "{\"error\":\"Corpus Not Found\"}\n",
"statusCode": 400
}
}
Examples
Export corpus to “application/x-tmx+xml” format
http -v GET <SPNS Gateway URL>/resources/corpus/export key==<API key> corpusId==<corpus
identifier>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 15
{
"exists": true
}
@: ~/tests/spns-and-ses-tests/test15-httpie/9.1.1/spsn
[jordan@sdtrn01]$ vi xresources-corpus-export
@: ~/tests/spns-and-ses-tests/test15-httpie/9.1.1/spsn
[jordan@sdtrn01]$ ./xresources-corpus-export "<corpus identifier>"
GET /resources/corpus/export?key=<API key>&corpusId=<corpus identifier> HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: <SPNS Gateway URL>
User-Agent: HTTPie/0.9.2
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/x-tmx+xml
Date: Wed, 02 Jan 2019 22:10:17 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
<?xml version="1.0"?>
<tmx version="1.4">
<header adminlang="en_US" creationtool="systran-corpus-manager" creationtoolversion="1.0"
datatype="unknown" o-tmf="" segtype="sentence" srclang="en" />
<body>
<tu>
<tuv xml:lang="en">
<seg>Why do cats purr?</seg>
</tuv>
<tuv xml:lang="fr">
<seg>Pourquoi les chats ronronnent-ils?</seg>
</tuv>
</tu>
<tu>
<tuv xml:lang="en">
<seg>When do dogs bark?</seg>
</tuv>
<tuv xml:lang="fr">
<seg>Quand les chiens aboient?</seg>
</tuv>
</tu>
<tu>
<tuv xml:lang="en">
<seg>The cat and dog are sleeping.</seg>
</tuv>
<tuv xml:lang="fr">
<seg>Le chat et le chien dorment.</seg>
</tuv>
</tu>
• key
• corpusId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"files": [
{
"id": "55af70344cf4c7f74e7cbbf0"
Examples
Delete a corpus
http -v GET <SPNS Gateway URL>/resources/corpus/delete key==<API key> corpusId== <corpus
identifier>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 45
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 23:02:01 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"files": [
{
"id": "<corpus identifier>"
}
]
}
• key
• corpusId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"matches": [
{
"form": "1er samestre (1136 Kb)",
"matches": [
{
"penalty": 0.1428571492433548,
"score": 0.8571428656578064,
"source": "1er semestre (1136 Kb)",
"target": "First half (1 Kb)"
}
]
},
{
Examples
Find “fuzzy” match in corpus
http -v GET <SPNS Gateway URL>/resources/corpus/match key==<API key> corpusId==<corpus
identifier> input=="The cat and dog are eating." sourceLang==en targetLang==fr
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 186
Content-Type: application/json; charset=utf-8
Date: Wed, 02 Jan 2019 23:00:20 GMT
Vary: Accept-Encoding
{
"matches": [
{
"form": "The cat and dog are eating.",
"matches": [
{
"penalty": 0,
"score": 0.8571428656578064,
"source": "The cat and dog are sleeping.",
"target": "Le chat et le chien dorment."
}
]
}
]
• key
• corpusId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"segments": [
Examples
List all segments in a corpus
http -v GET <SPNS Gateway URL>/resources/corpus/segment/list key==<API key> corpusId==<corpus
identifier>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 20:32:24 GMT
Transfer-Encoding: chunked
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"segments": [
{
"id": "5c2d4568f705707c0a8c3ee0.5c2d4568f705707c0a8c3ee2",
"lang": "en",
"source": "Why do cats purr?",
"targets": [
{
"id": "5c2d4568f705707c0a8c3ee3",
"lang": "fr",
"target": "Pourquoi les chats ronronnent-ils?"
}
• key
• body
The body parameter is added to the body of the request. A sample body (always in JSON form) is show below.
{
"corpusId": "55afbc9e17fb5791ef7a54ff",
"segments": [
{
"lang": "fr",
"source": "Exemple de traduction",
"targets": [
{
"lang": "en",
"target": "Translation example"
},
{
"lang": "en",
"target": "Example of translation"
}
]
}
]
}
In the following tables are the parameters for the body parameter. All of the parameters are required.
Body Parameters
Parameter Description
corpusId Corpus identifier.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"segments": [
"55afbc9e17fb5791ef7a54fe.55b65d8c6b457345fd2e3473",
"55afbc9e17fb5791ef7a54fe.55b65d9c6c457345fd1f5a8b"
]
}
Examples
Add segments to an existing corpus
more corpus_segs_to_add.json
{
"corpusId": "5c2d4568f705707c0a8c3ee1",
"segments": [
{
"lang": "en",
"source": "This cat is white.",
"targets": [
{
"lang": "fr",
"target": "Ce chat est blanc."
}
]
},
{
"lang": "en",
"source": "The dog has a long tail.",
"targets": [
{
"lang": "fr",
"target": "Le chien a une longue queue."
}
{
"corpusId": "5c2d4568f705707c0a8c3ee1",
"segments": [
{
"lang": "en",
"source": "This cat is white.",
"targets": [
{
"lang": "fr",
"target": "Ce chat est blanc."
}
]
},
{
"lang": "en",
"source": "The dog has a long tail.",
"targets": [
{
"lang": "fr",
"target": "Le chien a une longue queue."
}
]
}
]
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 118
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 20:30:56 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"segments": [
"5c2d4568f705707c0a8c3ee0.5c2e7100e19b11ae515dff01",
"5c2d4568f705707c0a8c3ee0.5c2e7100e19b11ae515dff03"
]
}
• key
• corpusId
• segId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
Examples
Delete a corpus segment
http -v GET <SPNS Gateway URL>/resources/corpus/segment/delete key==<API key>
corpusId==<corpus identifier> segId=="<segment identifier>"
POST /resources/corpus/segment/target/delete?key=<API
key>&corpusId=5c2d4568f705707c0a8c3ee1&segId=5c2d4568f705707c0a8c3ee0.5c2d4568f705707c0a8c3ee2
&targetId=5c2d4568f705707c0a8c3ee3 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: <SPNS Gateway URL>
User-Agent: HTTPie/0.9.2
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 16
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 21:04:32 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"deleted": true
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": {
"message": "Internal error",
"info": {}
},
"updated": true
}
Examples
Update a corpus segment
http -v GET <SPNS Gateway URL>/resources/corpus/segment/update key==<API key>
corpusId==<corpus identifier> segId=="<segment identifier>" source=="Why do cats knead?"
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 16
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 20:34:21 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"updated": true
}
• key
• body
The body parameter is added to the body of the request. A sample body (always in JSON form) is show below.
{
"corpusId": "55afbc9e17fb5791ef7a54ff",
"segId": "55afbc9e17fb5791ef7a54fe.55b69c8d6b457345fd2e347f",
"targets": [
{
"lang": "en",
"target": "added segment one"
},
{
"lang": "en",
"target": "added segment two"
}
]
}
In the following tables are the parameters for the body parameter. All of the parameters are required.
Body Parameters
Parameter Description
corpusId Corpus identifier.
segId Segment identifier.
targets List of segment targets to add.
lang Language code of segment target.
target Segment target text.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"added": true
}
{
"corpusId": "5c2d4568f705707c0a8c3ee1",
"segId": "5c2d4568f705707c0a8c3ee0.5c2d4568f705707c0a8c3ee2",
"targets": [
{
"lang": "de",
"target": "Warum machen Katzen schnurren?"
},
{
"lang": "de",
"target": "Warum kneten Katzen?"
}
]
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 14
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 20:38:13 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"added": true
• key
• corpusId
• segId
• targetId
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
Examples
Delete target from a corpus segment
http -v GET <SPNS Gateway URL>/resources/corpus/segment/target/delete key==<API key>
corpusId==<corpus identifier> segId=="<segment identifier>" targetId==<target identifier>
POST /resources/corpus/segment/target/delete?key=<API
key>&corpusId=5c2d4568f705707c0a8c3ee1&segId=5c2d4568f705707c0a8c3ee0.5c2d4568f705707c0a8c3ee2
&targetId=5c2e72b5e19b11ae515dff05 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: <SPNS Gateway URL>
User-Agent: HTTPie/0.9.2
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 16
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 20:45:17 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"deleted": true
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"version": "2.0.0"
}
Examples
Get API version for Multimodal Speech REST API
http -v GET <SPNS Gateway URL>/multimodal/speech/apiVersion key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 19
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 00:14:03 GMT
Vary: Accept-Encoding
{
"version": "2.0.0"
}
• key
• audioFile
• lang
Restrictions
• Maximum size of an audi0 file is limited to 100 MB or 2 hours.
• The requested URL, including parameters, must be less than 2K bytes.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": "", /* Error at request level */
"channels": [
{
"id": "1",
"signalDuration": "12.41",
"speechDuration": "10.64",
"nbWords": "24",
"textConfidence": "0.95"
}
],
"speakers": [
{
"gender": "female",
"channel": "1",
"duration": "10.64",
"id": "FS1",
"nbWords": "24",
"textConfidence": "0.95",
"langConfidence": "1.00",
"lang": "eng-usa"
}
],
"segments": [
{
"channel": "1",
"speechConfidence": "1.00",
"start": "0.42",
"end": "11.06",
"speaker": "FS1",
"lang": "eng-usa",
"langConfidence": "1.00",
"words": [
{
"start": "0.72",
"duration": "0.25",
"confidence": "0.975",
Examples
Audio transcription from file
http --form POST <SPNS Gateway URL>/multimodal/speech/transcribe lang==en sampling==high
key==<API key> [email protected]
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 21:55:26 GMT
Transfer-Encoding: chunked
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"channels": [
{
"id": "1",
"nbWords": 5,
"signalDuration": 1.04,
"speechDuration": 1.02,
"textConfidence": 1
}
],
"segments": [
{
"channel": "1",
"end": 1.03,
"lang": "eng-usa",
"langConfidence": 1,
"speaker": {
"gender": "male",
"id": "1"
},
"speechConfidence": 1,
"start": 0.01,
"words": [
• key
• audioFile
• textFile
• lang
Request to analyze the audio file in body of the request (form data mode)
You can call the SPNS REST API by passing all the parameters except the audio and text file parameters in the
query string format. The audio and text files should be included as form data.
Restrictions
• Maximum size of an audi0 file is limited to 100 MB or 2 hours.
• The requested URL, including parameters, must be less than 2K bytes.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": "", /* Error at request level */
"channels": [
{
"id": "1",
"signalDuration": "10.99",
"speechDuration": "10.28",
"nbWords": "25",
"textConfidence": "0.95"
}
],
"segments": [
{
"channel": "1",
"start": "0.71",
"end": "10.99",
"lang": "eng",
"textConfidence": "0.95",
"words": [
{
"id": "1",
"start": "0.71",
"duration": "0.32",
"confidence": "0.990",
"text": " Okay "
},
{
"id": "2",
"start": "1.03",
"duration": "0.00",
"confidence": "0.100",
"text": " , "
}
]
}
]
}
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 21:56:52 GMT
Transfer-Encoding: chunked
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"channels": [
{
"id": "1",
"nbWords": 5,
"signalDuration": 1,
"speechDuration": 0.82,
"textConfidence": 0.98
}
],
"segments": [
{
"channel": "1",
"end": 1,
"lang": "eng-usa",
"start": 0.18,
"textConfidence": 0.98,
"words": [
{
"confidence": 0.99,
"duration": 0.19,
"id": "1",
"nextStart": 0.37,
"start": 0.18,
"text": "This"
},
{
"confidence": 0.99,
"duration": 0.15,
"id": "2",
"nextStart": 0.52,
"start": 0.37,
"text": "is"
},
{
"confidence": 0.99,
"duration": 0.06,
"id": "3",
"nextStart": 0.58,
"start": 0.52,
• key
• audioFile
Request to analyze the audio file in body of the request (form data mode)
You can call the SPNS REST API by passing all the parameters except the audio file parameter in the query string
format. The audio file should be included as form data.
Restrictions
• Maximum size of an audi0 file is limited to 100 MB or 2 hours.
• The requested URL, including parameters, must be less than 2K bytes.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": "", /* Error at request level */
"channels": [
{
"id": "1",
"signalDuration": "12.41",
"speechDuration": "11.06"
}
],
"speakers": [
{
"gender": "female",
"channel": "1",
"duration": "11.06",
"id": "FS1"
}
],
"segments": [
{
"channel": "1",
"speechConfidence": "1.00",
"start": "0.01",
"end": "11.07",
"speaker": "FS1"
Examples
Speech segmentation of audio file
http --form POST <SPNS Gateway URL>/multimodal/speech/segment key==<API key> audioFile@test-
en-generic.mp3
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 250
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 21:57:49 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"channels": [
{
"id": "1",
"signalDuration": 1.04,
"speechDuration": 1.02
}
],
"segments": [
{
"channel": "1",
"end": 1.03,
"speaker": {
"gender": "male",
"id": "1"
},
"speechConfidence": 1,
"start": 0.01
}
],
"speakers": [
{
"channel": "1",
"duration": 1.02,
"gender": "male",
"id": "1"
}
]
}
• key
• audioFile
Request to analyze the audio file in body of the request (form data mode)
You can call the SPNS REST API by passing all the parameters except the audio file parameter in the query string
format. The audio file should be included as form data.
Restrictions
• Maximum size of an audi0 file is limited to 100 MB or 2 hours.
• The requested URL, including parameters, must be less than 2K bytes.
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
Examples
Language detection of audio file
http --form POST <SPNS Gateway URL>/multimodal/speech/detectLanguage key==<API key>
[email protected]
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 56
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 22:02:11 GMT
Vary: X-HTTP-Method-Override, Accept-Encoding
{
"languages": [
{
"confidence": 0.99,
"languageCode": "fre"
}
]
}
• key
Response
HTTP Status Code
If the request succeeds, the HTTP Status Code will be 200 OK.
Response body
The response body will be a JSON object:
{
"error": "", /* Error at request level */
"languages": [
"ar",
"nl",
"en",
"fi",
"fr",
"de",
"el",
"it",
"lt",
"zh",
"pl",
"pt",
"ro",
"ru",
"es",
"tr"
]
}
Examples
List all supported languages
http -v GET <SPNS Gateway URL>/multimodal/speech/supportedLanguages key==<API key>
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 95
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 21:58:27 GMT
Vary: Accept-Encoding
{
"languages": [
"ar",
"nl",
"en",
"fi",
"fr",
"de",
"el",
"it",
"lt",
"zh",
"pl",
"pt",
"ro",
"ru",
"es",
"tr"
]
}
5. Usage Tips
General Guidance for Performing Translations
The SPNS REST API offers several ways to perform translations such as using text or files, and with a synchronous
or asynchronous pattern. These choices offer flexibility; however, it is important to understand the advantages
and disdavantages of the different approaches.
For quick translation of a small amount text (from a single sentence to a few sentences), the use of the text
approach (/translation/text/translate service) might be best. The source text may be specified as part of the URL
or referenced in a SYSTRAN-specific JSON (see “Text translation with JSON object” example). This JSON may
include other translation parameters. Th /translation/text/translate service only supports the synchronous
pattern, which relies upon a quick response from SPNS since it is limited by time-outs – both within the client
making the translation request as well as the SPNS system. Performing many such translation requests
simultaneously, or within a short amount of time may impact translation throughput depending on the
capabilities of the host system for SPNS.
Note!
The /translation/file/translate service provides the translated output from the PDF format in
the Microsoft Word/DOCX format. This provides the ability to edit and update the translated
results (for example, update of embedded images). All other file formats are provided in the
same format as the source data.
In terms of translation throughput, files with at least 100-200 sentences will work best. Larger files will obvioiusly
take longer to process than shorter ones, but the throughput (in terms of characters translated per second) will be
about the same. However, as mentioned with /translation/text/translate service, if a significant number of
translation requests are being performed simultaneously, or within a short amount of time, the throughput can be
affected. A best practice recommendation is to translate files using an asynchronous patterm. This means using
the /translation/file/translate service with the async parameter set “true”, followed by periodic checks using the
/translation/file/status service. Once the translation is complete, the translation results are obtained with the
/translation/file/results service. The frequency of the periodic checks depends on the application, the number of
pending translation requests and how quick the results must be obtained. We would recommend at least a 500-
millisecond delay between checks for a single translation request.
If it is important to keep a connection between the source and translated text, consider using the XLIFF format,
which is described elsewhere in this section. In XLIFF, each sentence is kept in a single “translation unit”, and may
include specialized tags. For example, it is possible to encode HTML snippets within a translation unit, or other
formats. Some industry tools do just this, using XLIFF as the basis for translation (either machine/automated or
human) after converting Microsoft Office, HTML and other formats to XLIFF.
The corpus API services within the Resources REST API allow you to build a list of translation memories (or TMs).
A translation memory are exact matches of source text segments that will be replace the corresponding target
text segment defined in a corpus. This matching will override any attempt to translate to the source text. To use
one or more corpora in translation, you specify the corpus identifiers in the withCorpus parameter that is
available in the Translation REST API services. You can search specific segments with a corpus using the corpus
match API. The search can find exact matches and fuzzy (inexact) matches.
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: <SPNS Gateway URL>
User-Agent: HTTPie/0.9.2
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Thu, 08 Dec 2016 18:11:46 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
{
"outputs": [
{
"output": "<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\">\n<body><span class=\"systran_seg\" id=\"Sp1.s1.1_o\"><span
class=\"systran_token_word\" value=\"*\" id=\"p1.t1.1_0\">Le</span> <span
class=\"systran_token_word\" value=\"1010/noun:common\" id=\"p1.t1.1_2\">ciel</span> <span
class=\"systran_token_word\" value=\"4004/aux:plain\" id=\"p1.t1.1_3\">est</span> <span
class=\"systran_token_word\" value=\"2020/adj:base\" id=\"p1.t1.1_4\">bleu</span><span
class=\"systran_token_punctuation\" id=\"p1.t1.1_5\">.</span></span></body></html>",
"source": "<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\">\n<body><span class=\"systran_seg\" id=\"Sp1.s1.1_o\"><span
class=\"systran_lemma\" value=\"the\" id=\"p1.t1.1_1\"><span class=\"systran_token_word\"
value=\"3c3d/det\" id=\"p1.t1.1_1\">The</span></span> <span class=\"systran_lemma\"
value=\"sky\" id=\"p1.t1.1_2\"><span class=\"systran_token_word\" value=\"1010/noun:common\"
id=\"p1.t1.1_2\">sky</span></span> <span class=\"systran_lemma\" value=\"be\"
id=\"p1.t1.1_3\"><span class=\"systran_token_word\" value=\"4004/aux:plain\"
id=\"p1.t1.1_3\">is</span></span> <span class=\"systran_amb_adjective/noun\"
value=\"<reference>blue</reference><choice value='adjective'
default='yes'/><choice value='noun'/>\" id=\"p1.t1.1_1\"><span
class=\"systran_lemma\" value=\"blue\" id=\"p1.t1.1_4\"><span class=\"systran_token_word\"
value=\"2020/adj:base\" id=\"p1.t1.1_4\">blue</span></span></span><span
class=\"systran_lemma\" value=\".\" id=\"p1.t1.1_5\"><span class=\"systran_token_punctuation\"
value=\"cccc/punct\" id=\"p1.t1.1_5\">.</span></span></span></body></html>"
}
]
}
• Plain text
• Microsoft Word DOCX
• Microsoft PowerPoint PPTX
• Microsoft Excel XLSX
• Adobe PDF
• Rich Text Format
• OpenDocument Text ODT
• OpenDocument Spreadsheet ODS
• OpenDocument Presentation ODP
more test-dnt.txt
The quick brown fox jumps over the lazy dog.
The quick brown <dnt_entity POS="noun">fox</dnt_entity> jumps over the lazy dog.
The quick brown <dnt_entity POS="noun">fox</dnt_entity> jumps over the lazy dog.
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type,X-HTTP-METHOD-OVERRIDE,X-User-
Agent
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 139
Date: Thu, 03 Jan 2019 23:18:49 GMT
Vary: X-HTTP-Method-Override
If it is necessary to ensure a connection between source and translated text sentence-by-sentence, XLIFF is the
recommended format choice.
Examples
XLIFF Source Example
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" original="dummy.xml" datatype="mimetype" mimetype="text/xml">
<body>
<trans-unit id="0">
<source>A sample sentence to be translated.</source>
<seg-source>
<mrk id="1" type="seg" mtype="seg">A sample sentence to be translated.</mrk>
</seg-source>
</trans-unit>
<trans-unit id="1">
<source>Another sample sentence to be translated.</source>
<seg-source>
<mrk id="1" type="seg" mtype="seg">Another sample sentence to be translated. </mrk>
</seg-source>
</trans-unit>
</body>
</file>
Important!
XLIFF translation units may include inline tags (<bpt>, <ept> and <ph>). The SPNS REST API
does not guarantee that all tags within the <source> element are also present in the <target>
element, or that these tags are in the proper order. It is the responsibility of the calling
application to verify this.
For the Multimodal Speech APIs, the language codes used as input are also the same two-letter codes defined in
the previous table, but limited to the languages specified in the list of ISO 639-2/B three-letter language codes in
the following table. The languages returned by the Multimodal Speech APIs are the three-letter language codes.
7. Domain Values
Domains are translation rules and terms specific to a topic such as automotive, construction or medical. The
SPNS domains will depend on those translation resources (TRs) that are installed. The most common domain is
“Generic”.
8. Terminology
This provides a list of terms often used with language translation, including some SYSTRAN specific terms.
Term List
Term Meaning
Homograph A word or phrase that can be more than one part-of-
speech or meaning. For example, the word “advocate”
may be a noun or a verb.
HT Human Translation.
9. References
REST:
[1] http://en.wikipedia.org/wiki/Representational_state_transfer
CORS:
[3] http://www.w3.org/TR/cors/
JSON:
[4] http://en.wikipedia.org/wiki/JSON
[5] http://json.org
HTTPIE:
[6] https://github.com/jakubroztocil/httpie
10. Releases
This provides information based on SPNS releases and is divided between the APIs. Any “breaking change” (a
change that requires an application code change) is noted.
12. Copyright
Copyright © 2016-2019 SYSTRAN. All Rights Reserved.
Information in this document is subject to change without notice. The software described in this document is
furnished under a license agreement or a nondisclosure agreement. The software may be used or copied only in
accordance with the terms of those agreements. No part of this publication may be reproduced, stored in a
retrieval system, or transmitted by any means, electronic or mechanical, including photocopying and recording,
for any purchaser’s personal use without the written permission of SYSTRAN.