...
- import new openTM2-TMs
- delete openTM2-TMs
- create new empty openTM2-TM
- import TMX
- open TM and close TM: not possible see extra section in this document.
- query TM for Matches: one query per TM, not quering multiple TMs at once.
- query TM for concordance search
- save new entry to TM
- get some statistics about service
This can be achieved by the following specification of a RESTful HTTP Serive, the specification is given in the following form:
...
The transferred data in the requests is JSON and is directly done in the request body. It's should be pretty json and ends with '\n}" symbol, because of bug in proxygen that caused garbage after valid data.
URL Format:
In this document, the OpenTM2 is always assumed under http://opentm2/.
...
Endpoints overview | ||||
---|---|---|---|---|
1 | Get the list of TMs | Returns JSON list of TMs | GET | /%service%/ |
2 | Create TM | Creates TM with the provided name | POST | /%service%/ |
3 | Create/Import TM in internal format | Import and unpack base64 encoded archive of .TMD, .TMI, .MEM files. Rename it to provided name | POST | /%service%/ |
4 | Clone TM Localy | Makes clone of existing tm | POST | /%service%/%tm_name%/ |
5 | Reorganize TM | Reorganizing tm(replacing tm with new one and reimporting segments from tmd) - async | GET | /%service%/%tm_name%/reorganize |
5 | Delete TM | Deletes .TMD, .TMI , .MEM files | DELETE | /%service%/%tm_name%/ |
6 | Import TMX into TM | Import provided base64 encoded TMX file into TM - async | POST | /%service%/%tm_name%/import |
7 | Export TMX from TM | Creates TMX from tm. Encoded in base64 | GET | /%service%/%tm_name%/ |
8 | Export in Internal format | Creates and exports archive with .TMD, .TMI , .MEM files of TM | GET | /%service%/%tm_name%/ |
9 | Status of TM | Returns status\import status of TM | GET | /%service%/%tm_name%/status |
10 | Fuzzy search | Returns enrtiesentries\translations with small differences from requested | POST | /%service%/%tm_name%/fuzzysearch |
11 | Concordance search | Returns entries\translations that contain requested segment | POST | /%service%/%tm_name%/concordancesearch |
12 | Entry update | Updates entry\translation | POST | /%service%/%tm_name%/entry |
13 | Entry delete | Deletes entry\translation | POST | /%service%/%tm_name%/entrydelete |
14 | Save all TMs | Flushes all filebuffers(TMD, TMI files) into the filesystem | GET | /%service%_service/savetms |
15 | Shutdown service | Flushes all filebuffers into the filesystem and shutting down the service | GET | /%service%_service/shutdown |
16 | Test tag replacement call | For testing tag replacement | POST | /%service%_service/tagreplacement |
17 | Resources | Returns resources and service data | GET | /%service%_service/resources |
...
List of TMs | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Returns JSON list of TMs | |||||||||
Request | GET /%service%/ | |||||||||
Params | - | |||||||||
Returns list of open TMs and then list of available(excluding open) in the app.
|
Create TM
Required: name, sourceLang
language | js |
---|---|
title | Response |
collapse | true |
|
|
|
|
|
|
|
|
Create TM | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Creates TM with the provided name | |||||||||
Request | Post /%service%/%tm_name%/ | |||||||||
Params | Required: name, sourceLang | |||||||||
|
Create/Import TM in internal format | |
---|---|
Purpose | Import and unpack base64 encoded archive |
Create/Import TM in internal format | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Import and unpack base64 encoded archive of .TMD, .TMI, .MEM files. Rename it to provided name | |||||||||
Request | POST /%service%/%tm_name%/ | |||||||||
Params | { "name": "examle_tm", "sourceLang": "bg-BG" , "data":"base64EncodedArchive" } | |||||||||
|
...
Clone TM localy | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Creates TM with the provided name | |||||||||
Request | Post /%service%/%tm_name%/clone | |||||||||
Params | Required: name, sourceLang | |||||||||
|
Delete TM | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Purpose | Deletes .TMD, .TMI, .MEM files | ||||||||||||||||||
Request | Delete /%service%/%tm_name%/ | ||||||||||||||||||
Params | - | ||||||||||||||||||
|
Import provided base64 encoded TMX file into TM | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Import provided base64 encoded TMX file into TM. Starts another thead for import. For checking import status use status call | |||||||||
Request | POST /%service%/%tm_name%/import | |||||||||
Params | {"tmxData": "base64EncodedTmxFile" } | |||||||||
|
...
Export in internal format | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Creates and exports archive with .TMD, .TMI, .MEM files of TM | |||||||||
Request | GET /%service%/%tm_name%/ | |||||||||
Headers | application/zip | |||||||||
returns archive(.tm file) consists with .tmd and .tmi files
|
...
Get the status of TM | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | GET /%service%/%tm_name%/status | ||||||||||||||
Params | - | ||||||||||||||
Would return status of TM. It could be 'not found', 'available' if it's on the disk but not loaded into the RAM yet, and 'open' with additional info. In case if there was at least one try to import tmx or reorganize tm since it was loaded into the RAM, additional fields would appear and stay in the statistics till memory would be unloaded.
| |||||||||||||||
Fuzzy search | |||||||||||||||
Purpose | Returns enrties\translations with small differences from requested | ||||||||||||||
Request | POST /%service%/%tm_name%/fuzzysearch | ||||||||||||||
|
Fuzzy search | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Returns enrties\translations with small differences from requested | |||||||||
Request | POST /%service%/%tm_name%/fuzzysearch | |||||||||
Params | Required: source, sourceLang, targetLang iNumOfProposal - limit of found proposals - max is 20, if 0 → use default value '5' | |||||||||
| Params |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
Request example:
Request example:
{ "sourceLang":"en-GB", "targetLang":"de", "source":"For > 100 setups.", ["documentName":"OBJ_DCL-0000000845-004_pt-br.xml"], ["segmentNumber":""], ["markupTable":"OTMXUXLF"], ["context":"395_408"], ["numOfProposals":20], ["loggingThreshold": 0]}
Response example:
Success:
{
"ReturnValue": 0,
"ErrorMsg": "",
"NumOfFoundProposals": 1,
"results": [
{
"source": "For > 100 setups.",
"target": "Für > 100 Aufstellungen.",
"segmentNumber": 10906825,
"id": "",
"documentName": "none",
"documentShortName": "NONE",
"sourceLang": "en-GB",
"targetLang": "de-DE",
"type": "Manual",
"matchType": "Exact",
"author": "",
"timestamp": "20190401T084052Z",
"matchRate": 100,
"markupTable": "OTMXML",
"context": "",
"additionalInfo": ""
}
]
}
Not found:
{
"ReturnValue": 133,
"ErrorMsg": "OtmMemoryServiceWorker::concordanceSearch::"
}
|
Concordance search
Required: searchString - what we are looking for , searchType ["Source"|"Target"|"SourceAndTarget"] - where to look
iNumOfProposal - limit of found proposals - max is 20, if 0 → use default value '5'
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
Request example: { "searchString": "The", "searchType": "source", ["searchPosition": "",] ["numResults": 20,] ["msSearchAfterNumResults": 250,] ["loggingThreshold": 0] } Response example:Success: { "ReturnValue": 0, "NewSearchPosition": null, "results": [ { "source": "For > 100 setups.", "target": "Für > 100 Aufstellungen.", "segmentNumber": 10906825, "id": "", "documentName": "none", "documentShortName": "NONE", "sourceLang": "en-GB",← rfc5646 "targetLang": "de-DE",← rfc5646 "type": "Manual", "matchType": "undefinedExact", "author": "", "timestamp": "20190401T084052Z", "matchRate": 0100, "markupTable": "OTMXML", "context": "", "additionalInfo": "" } ], "ErrorMsg": "" } Success, but with NewSearchPosition - not all TM was checked, use this position to repeat search:Not found: { "ReturnValue": 0133, "NewSearchPositionErrorMsg": "OtmMemoryServiceWorker::concordanceSearch::" } |
Concordance search | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Returns entries\translations that contain requested segment | |||||||||
Request | POST /%service%/%tm_name%/concordancesearch | |||||||||
Params | Required: searchString - what we are looking for , searchType ["Source"|"Target"|"SourceAndTarget"] - where to look iNumOfProposal - limit of found proposals - max is 20, if 0 → use default value '5' | |||||||||
|
...
Save all TMs | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Flushes all filebuffers(TMD, TMI files) into the filesystem. Reset 'Modified' flags for file buffers. Filebuffer is a file instance of .TMD or .TMI loaded into RAM. It provides better speed and safety when working with files. | |||||||||
Request | GET /%service%_service/savetms | |||||||||
Params | - | |||||||||
|
Shutdown service | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Purpose | Safely shutting down the service with\without saving all loaded tm files to the disk | |||||||||
Request | GET /%service%_service/shutdown?dontsave=1 | |||||||||
Params | dontsave=1(optional in address) - skips saving tms, for now value doesn't matter, only presence | |||||||||
If try to save tms before closing, would check if there is still import process going on
|
...
Openning and closing TM | |
---|---|
In first concept it was planned to implement routines to open and close a TM. While concepting we found some problemes with this approach:
This leads to the following conclusion in implementation of opening and closing of TMs: OpenTM2 has to automatically load the requested TMs if requested. Also OpenTM2 has to close the TMs after a TM was not used for some time. That means that OpenTM2 has to track the timestamps when a TM was last requested.
http://opentm2/translationmemory/[TM_Name]/openHandle GET – Opens a memory for queries by OpenTM2 Note: This method is not required as memories are automatically opened when they are accessed for the first time. http://opentm2/translationmemory/[TM_Name]/openHandle DELETE – Closes a memory for queries by OpenTM2 Note: This method is not required as memories are automatically opened when they are accessed for the first time.
|
TM files structure and other related info | ||
---|---|---|
Info below is actual for version 0_5_x TM file is just archive with tmi and tmd files. |
TAG REPLACEMENT | ||
---|---|---|
Tag replacement
...