Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added info about new flags and params for reorganize, massdeletion, update and importtmx

...

Updated for v0.6.75
To configure t5memory use it's commandline flags. To list all the flags start t5memory with help flag: ./t5memory --help. All flags related to t5memory and not libraries is under otmd.cpp section. Also you can send get request to t5memory_service/flags - it would print all the flags with description and current and default values. Here are those flags

just call t5memory_service/flags to have all info about flags, main flags are under otmd.cpp location

  Flags from /home/or/workspace/translate5/translate5-tm-service-source/source/otmd.cpp:
    -add_premade_socket (if set to true, socket instance would be created
      outside of proxygen and then binded, that made possible to add tcp backog
      event handler and use socket_backog option) type: bool default: false
      currently: true
    -allowLoadingMultipleTmsSimultaneously (If set to true, multiple tms could
      be loaded from the disk at the same time. ) type: bool default: false
    -allowedram (Sets amought RAM(in MB) allowed for service to use)
      type: int64 default: 5000
    -allowedtmdsize (Sets max size of tmd file(in MB) after which t5m would not
      allow to add new data to the tm) type: int64 default: 500
    -debug_sleep_in_request_run (If set, provide artificial delay in every
      request handling execution equal to provided num of microseconds)
      type: int64 default: 0 currently: 10000000
    -disable_aslr (If set to true, process personality would be set to
      ADDR_NO_RANDOMIZE) type: bool default: false currently: true
    -enable_newlines_in_logs ((not working)if set to true, would keep newline
      symbols in the logs, otherwise(by default) newlines would be removed and
      logs would be oneliners) type: bool default: false
    -flush_tm_at_shutdown (If set to true, flushes tm when shutting down the
      app not using shutdown request) type: bool default: false
    -flush_tm_to_disk_with_every_update (If set to true, flushes tm to disk
      with every successfull update request) type: bool default: false
    -forbiddeletefiles (Set to true to keep all files(including temporary and
      tm)) type: bool default: false
    -http_listen_backlog (Sets http options listen backog) type: int64
      default: 128 currently: 32
    -ignore_newer_target_exists_check (if set to true, check for newer already
      saved target would be skipped for saving segments) type: bool
      default: true
    -keep_tm_backups (if set to true, when saving tmd and tmi files, old copies
      would be saved with .old suffix) type: bool default: true
    -limit_num_of_active_requests (If set to true, it would be possible to
      handle only up to servicethreads-1 requests at the same time, the last
      thread would respond with 503 to eliminate creating queue of requests
      waiting to be handled.) type: bool default: false
    -logMutexes (if set to true you would see mutex logs) type: bool
      default: false
    -log_every_request_end (Sets log for every request end  with it's url,
      method etc...) type: bool default: false
    -log_every_request_start (Sets log for every request call with it's url,
      method etc...) type: bool default: false
    -log_memmove_in_compareputdata (if set to true, when saving segment and
      causing memmove in compareputdata functions, just before memmove, data
      would be logged - use this to debug btree crashes.) type: bool
      default: false
    -log_tcp_backog_events (if set to true, tcp backlog events would be
      logged(to enable, add_premade_socket flag should be set to true))
      type: bool default: false currently: true
    -port (What port to listen on) type: int32 default: 4080
    -servicename (Sets service name to use in url) type: string
      default: "t5memory"
    -servicethreads (Sets amought of worker threads for service) type: int32
      default: 5
    -socket_backlog (Sets proxygen socket listen backog(disabled, to enable set
      add_premade_socket=true)) type: int64 default: 1024 currently: 32
    -t5_ip (Which ip to use in t5memory(default is any). Should be in format
      '1.1.1.1', default is to listen to all available ip) type: string
      default: ""
    -t5loglevel (Sets t5memory log level threshold from DEVELOP(0) to
      TRANSACTION(6)) type: int32 default: 2 currently: 3
    -timeout (Sets timeout for service request handling) type: int32
      default: 180000
    -tmListLockDefaultTimeout (Sets tm mutex lock timeout(in ms) for TM
      list(which is used to open and close tms, and hold list of opened tms),
      after which operation would be canceled and mutex would return an error,
      if set to 0, mutex lock would be waited without timeout) type: int64
      default: 3000
    -tmLockDefaultTimeout (Sets tm mutex lock timeout(in ms) for TM after which
      operation would be canceled and mutex would return an error, if set to 0,
      mutex lock would be waited without timeout) type: int64 default: 3000
    -tmRequestLockDefaultTimeout (Sets tm mutex lock timeout(in ms) for part
      where request is requesting tm(which is used to open and close tms, and
      hold list of opened tms), after which operation would be canceled and
      mutex would return an error, if set to 0, mutex lock would be waited
      without timeout) type: int64 default: 3000
    -triplesthreshold (Sets threshold to pre fuzzy filtering based on hashes of
      neibour tokens) type: int32 default: 5
    -useTimedMutexesForReorganizeAndImport (If set to true, in reorganize or
      import thread would be used mutexes with timeouts, and reorganizee or
      import could be canceled, false(by default) - would be used non timed
      mutexes) type: bool default: false
    -wait_for_import_and_reorganize_requests (If set to true, waiting for all
      import and reorganize processes to be done at shutdown when not using
      shutdown request) type: bool default: true

Hints:

  • -debug_sleep_in_request_run would add delay to every requests
  • In theory you can restore tm with only tmd file using reorganize, but in case if there would be some issue during reorganize, tm in ram would be in instable state, so keep original tmd backed up anyway
  • you can set filter for requests using --t5loglevel from 0 to 6. --v could be set to 0 or 2. if set to 0 only errors would be logged and transaction log level would be mapped to info. 
  • keep_tm_backups in case of flushing to the disk, older version would be kept with .old suffix, enabled by default
  • triplesthreshold have big impact on fuzzy search speed, but if you set it to too big value, some good matches could be filtered out. in old opentm2 value was, I think, 33. 

...

Create TM

PurposeCreates TM with the provided name(tmd and tmi files in/MEM/ folder)
RequestPost /%service%/%tm_name%/
Params

Required: name, sourceLang


Code Block
languagejs
titleResponse
collapsetrue
Request example 
{    "name": "examle_tm",  // this name would be used as filename for .TMD and .TMI files   
   {  "sourceLang": "bg-BG"}  // should match lang in languages.xml
   {"data": "base64_encoded_archive_see_import_in_internal_format"}
   ["loggingThreshold": 0],


}
this endpoint could work in 2 ways, like creation of new tm (then sourceLang is required and data can be skipped) or importing archived .tm(then sourceLang can be skipped, but data is required)it's possible to add memDescription in this stage, but this should be explored more if needed

Response example:Success:{
"name": "examle_tm",
}
TM already exists: 
{
    "ReturnValue": 7272,
    "ErrorMsg": "::ERROR_MEM_NAME_EXISTS:: TM with this name already exists: examle_tm1; res = 0"
}


...

Import provided base64 encoded TMX file into TM

PurposeImport provided base64 encoded TMX file into TM. Starts another thead for import. For checking import status use status call
RequestPOST /%service%/%tm_name%/import
Params

{"tmxData": "base64EncodedTmxFile" }

  • additional:
    "framingTags":
       "saveAll" - default behaviour, do nothing
       "skipAll" - skip all enclosing tags, including standalone tags
       "skipPaired" - skip only paired enclosing tags 

TM must exist
It's async, so check status using status endpoint, like with reorganize in 0.5.x and up

Handling if framing tag situation differs from source to target - for skipAll or skipPaired

If framing tags situation is the same in source and target, both sides should be treated as described above.

If framing tags only exist in source, then still they should be treated as described above.

If they only exist in target, then  nothing should be removed.

Code Block
languagejs
titleResponse
collapsetrue
Request example:{
   ["framingTags": "skipAll"["skipPaired", "saveAll"],]
   "tmxData":   "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHRteCB2ZXJzaW9uPSIxLjQiPgogIDxoZWFkZXIgY3JlYXRpb250b29sPSJTREwgTGFuZ3VhZ2UgUGxhdGZvcm0iIGNyZWF0aW9udG9vbHZlcnNpb249IjguMCIgby10bWY9IlNETCBUTTggRm9ybWF0IiBkYXRhdHlwZT0ieG1sIiBzZWd0eXBlPSJzZW50ZW5jZSIgYWRtaW5sYW5nPSJlbi1HQiIgc3JjbGFuZz0iYmctQkciIGNyZWF0aW9uZGF0ZT0iMjAxNTA4MjFUMDkyNjE0WiIgY3JlYXRpb25pZD0idGVzdCIvPgogIDxib2R5PgoJPHR1IGNyZWF0aW9uZGF0ZT0iMjAxODAyMTZUMTU1MTA1WiIgY3JlYXRpb25pZD0iREVTS1RPUC1SNTlCT0tCXFBDMiIgY2hhbmdlZGF0ZT0iMjAxODAyMTZUMTU1MTA4WiIgY2hhbmdlaWQ9IkRFU0tUT1AtUjU5Qk9LQlxQQzIiIGxhc3R1c2FnZWRhdGU9IjIwMTgwMjE2VDE2MTMwNVoiIHVzYWdlY291bnQ9IjEiPgogICAgICA8dHV2IHhtbDpsYW5nPSJiZy1CRyI+CiAgICAgICAgPHNlZz5UaGUgPHBoIC8+IGVuZDwvc2VnPgogICAgICA8L3R1dj4KICAgICAgPHR1diB4bWw6bGFuZz0iZW4tR0IiPgogICAgICAgIDxzZWc+RXRoIDxwaCAvPiBkbmU8L3NlZz4KICAgICAgPC90dXY+CiAgICA8L3R1PgogIDwvYm9keT4KPC90bXg+Cg=="
}Response example:Error in case of errorFrom v0_2_15
{ "%tm_name%":""} in case of success
Check status of import using status call
TMX import could be interrupted in case of invalid XML or TM reaching it's limit. For both cases check status request to have info about position in tmx file where it was interrupted. 



Multifuzzy

PurposeSends multiple fuzzysearches in the same tm in a row
RequestPOST /%service%/%tm_name%/multifuzzy
Params

"requests":[array of regular fuzzySearch bodies]
"customId":"you can provide optional customId to identify responses"


Code Block
languagejs
titleResponse
collapsetrue
Request example
{
        "requests": [
            {
                "source": "d\u00fcrfen.",
                "type": "Manual",
                "markupTable": "OTMXUXLF",
                "sourceLang": "de-DE",
                "targetLang": "en-US",
                "documentName": "Audioscript_Hybrides_Arbeiten.xlsx.sdlxliff",
                "author": "Project Manager",
                "context": "390"
            },
            {
                "source": "ändern",
                "type": "Automatic",
                "markupTable": "ABCD1234",
                "sourceLang": "de-de",
                "targetLang": "en-GB",
                "documentName": "translation.docx",
                "author": "Editor",
                "context": "200"
            }
        ]
}
response example:
{
  "responses": {
   "0": {
      "ReturnValue": 0,
      "ErrorMsg": "",
      "NumOfFoundProposals": 0,
      "searchedSrc": "dürfen.",
      "customId": "",
      "forceFuzzy": 0
    },
    "1": {
      "ReturnValue": 0,
      "ErrorMsg": "",
      "NumOfFoundProposals": 0,
      "searchedSrc": "ändern",
      "customId": "",
      "forceFuzzy": 0
    }
  }
}





Multiupdate

PurposeSend multiple updateEntry requests to the same tm with one call
RequestPOST /%service%/%tm_name%/multiupdate
Params

"requests":[array of regular updateEntry bodies]
"customId":"you can provide optional customId to identify responses"


Code Block
languagejs
titleResponse
collapsetrue
Request example:
{
"requests": [
{
    "source": "d\u00fcrfen.",
    "target": "Note",
    "customId": "123",
    "type": "Manual",
    "markupTable": "OTMXUXLF",
    "targetLang": "de-DE",
    "sourceLang": "de-De",
    "documentName": "Audioscript_Hybrides_Arbeiten.xlsx.sdlxliff",
    "author": "Project Manager",
    "context": "390"
   },
   {
    "source": "ändern",
    "target": "change",
    "customId" : "abc",
    "type": "Automatic",
    "markupTable": "ABCD1234",
    "targetLang": "fr-FR",
    "sourceLang": "de-DE",
    "documentName": "translation.docx",
     "author": "Editor",
     "context": "200"
    }
  ]
}

Response example:
{
    "responses": {
        "123": {
            "source": "dürfen.",
            "sourceNPRepl": "dürfen.",
            "sourceNorm": "dürfen.",
            "target": "Note",
            "segmentId": 519740,
            "customId": "123",
            "documentName": "Audioscript_Hybrides_Arbeiten.xlsx.sdlxliff",
            "sourceLang": "DE-DE",
            "targetLang": "DE-DE",
            "type": "Manual",
            "author": "PROJECT MANAGER",
            "timestamp": "20250724T131742Z",
            "markupTable": "OTMXUXLF",
            "context": "390",
            "additionalInfo": "",
            "internalKey": "447145:1"
        },
        "abc": {
            "ReturnValue": 6044,
            "ErrorMsg": "EqfMemory::putProposal result is an error;"
        }
    },
    "save2disk": "0"
}


Code Block
languagejs
titleResponse
collapsetrue
Response example:
{
    "responses": {
        "123": {
            "ReturnValue": 6044,
            "ErrorMsg": "EqfMemory::putProposal result is an error;"
        },
        "abc": {
            "ReturnValue": 14002,
            "ErrorMsg": "Error: Missing target language"
        }
    },
    "save2disk": "0"
}




Tables

PurposeGet author, lang, langGroup(virtual- created in runtime and not saved on the disk), tagtable(deprecated - only one record), document(long filename, long filename caseignore-virtual, short filename- part deprecated)
RequestGET /%service%/%tm_name%/tables
Params

-

tables are provided in format - name(internal key): "position) idInTable:value;"
When adding new entry, for new Id t5memory uses basicaly size of the table before adding+1, so Id should start from id=1. 
When doing fuzzy search, some field could also be saved to the table, to generate then id(or find matching) to compare with saved data.
There are 2 types of entries- older, fixed size, and long filename. For older, every entry has the same size, 39 bytes+endOfLine. You can have up to 389 entries saved in that way in each of the tables. Longname table manage size dynamically, so it's not clear what's the maximum size, but for filenames there are duplicates in old style docname table and in longname(which are used only for this type of data). For filename search, first used longname table, then generated on tm loading caseignore longname table, then short name table. Usually entries in tables are caseignore. 

In the record t5memory saves only id to the table. Maybe it make sense to implement endpoint to edit that table, if something is missing or corrupted. Exception for saving id are context and additional info, some data, that could be saved as int(segId, time), and source and target.
To clear or fix tag tables, you need to do reorganize, but if some entry is missing from the table, you would not restore it on export or segment exctraction via id. So tables could be used to check health of the tm. And for some ways for concordance search or some other checks. 


Code Block
languagejs
titleResponse
collapsetrue
Response example:
{
    "tableName(additional info)(INTERNAL_KEY_OF_THE_TABLE)": "position)idInTable: value;",
    "tagTablesTable(4)": "0)0: \"\"; ",
    "langTable(1)": "0)2: \"DE-DE\"; 1)1: \"FR-FR\"; 2)0: \"\"; ",
    "langGroupTable(virtual)(8)":"0)1: \"F\"; 1)2: \"G\", "authors(3)": "0)36: \"ALINA GEDGAUDIENE\"; 1)7: \"ANAIS KLUCZKA\"; 2)4: \"ANNA MAYER\"; 3)17: \"ARTHUR LE PIVERT\"; 4)35: \"CHARLOTTE FOGLIA\"; 5)10: \"CLAUDIA RICHLING\"; 6)18: \"DANIEL THURSFIELD\"; 7)39: \"DANIELA BARSCH\"; 8)8: \"DANIELA NOEBEL\"; 9)15: \"DUYGU ZORBA\"; 10)48: \"EDITA KAZLAUSKAITE\"; 11)40: \"FRANK ERVEN\"; 12)1: \"FRéDéRIC MOULIN\"; 13)14: \"GIL DéNIEL (DE6U3268)\"; 14)31: \"HEIDRUN LUDOLF\"; 15)55: \"HEIKE REINER\"; 16)30: \"INDRE BARTKIENE\"; 17)23: \"ISABELLE OUELLET\"; 18)19: \"JP COSTEROUSSE (DE6U3269)\"; 19)41: \"JüRGEN KUKLINSKI\"; 20)46: \"LINA PAULAUSKIENE\"; 21)53: \"LINDA PORRECA HEIMROTH\"; 22)58: \"LUCIE BOYN\"; 23)26: \"MARIUS EITMINAVICIUS\"; 24)50: \"MARLIES VAN DEN HURK\"; 25)43: \"MARTIN HOLTMANN\"; 26)54: \"NADINE SCHAELE\"; 27)22: \"NELSON RUSK\"; 28)49: \"RAIMONDA JAZUKEVICIENE\"; 29)25: \"RITA DANZè\"; 30)6: \"UNBEKANNT\"; 31)13: \"UNBEKANNT 1\"; 32)33: \"UNKNOWN 1\"; 33)38: \"VILMA JURGELIONYTE\"; 34)32: \"VILMA JURGELIONYTE2\"; 35)12: \"VINCENT HENRY\"; 36)47: \"VOLKER ZEYER\"; 37)29: \"VéLINA GABROVSKA\"; 38)28: \"W W\"; 39)11: \"[AMPLEXOR]\"; 40)42: \"[BUEHLER, IHRE ABTEILUNG (AUF VS-BUEHLE\"; 41)57: \"[BüHLER AG, TECHNISCHE DOKUMENTATION (\"; 42)24: \"[CLS]\"; 43)56: \"[ERVEN.BIZ - TRAINING, CONSULTING & SUP\"; 44)44: \"[ERVEN]\"; 45)20: \"[EUROSCRIPT DEUTSCHLAND GMBH, IHRE ABTE\"; 46)2: \"[ITL]\"; 47)51: \"[KAVO DENTAL GMBH, IT (AUF DENBIBSVAC00\"; 48)45: \"[LIONBRIDGE]\"; 49)9: \"[OLD - EUROSCRIPT]\"; 50)16: \"[OLD_AMPLEXOR]\"; 51)21: \"[RAPTRAD IMAGINE]\"; 52)37: \"[STO SE & CO.KGAA, (ON DEWEAT06)]\"; 53)52: \"[STOQUART SA, (ON THERIVER)]\"; 54)3: \"[TRANSLINE EUROPE, (ON TEU-SERVER)]\"; 55)5: \"[TRANSLINE]\"; 56)27: \"[WEINOR, MARKETING (AUF NTS-ACROSS)]\"; 57)34: \"[WIENERS]\"; 58)0: \"\"; ",
"filenames(long)(5)": "0)1: \"none\"; 1)0: \"\"; ",
"filenames(long, caseign, virtual)(5)": "0)1: \"NONE\"; 1)0: \"\"; ",
"filenames(short)(2)": "0)1: \"none\"; 1)0: \"\"; "}



   

Table of Contents

Overview and API introduction

...

Import binary TMX file into TM

PurposeImport provided base64 encoded TMX file into TM. Starts another thead for import. For checking import status use status call
RequestPOST /%service%/%tm_name%/importtmx
Params

Request has a file attached and a body as an option,

Implemented in 0.6.19
here are curl command to test:

curl -X POST \ -H "Content-Type: application/json" \ -F "file=@/path/to/12434615271d732fvd7te3.tmx;filename=myfile.tmx" \ -F "json_data={\"framingTags\": \"value\", \"timeout\": 1500}" \ http://t5memory:4045/t5memory/{memory_name}/importtmx

Body should be provided in multiform under json_data key
Body(optional): 

{

 ["framingTags": "saveAll"],  // framing tags behaviour 

  ["newEntryIfOnlyContextAndTimestampDifferent"]: 0,

     ["saveDifferentTargetsForSameSource"]: 0,

 [timeout: 100] // timeout in sec after which import stops, even if it doesn't reach end of tmx yet

}

  • additional:
    "framingTags":
       "saveAll" - default behaviour, do nothing
       "skipAll" - skip all enclosing tags, including standalone tags
       "skipPaired" - skip only paired enclosing tags 

    both newEntryIfOnlyContextAndTimestampDifferent and saveDifferentTargetsForSameSource impact how similar translation would be saved. In case if source and other field(doc, author, lang) are the same, but target different, and newEntryIfOnlyContextAndTimestampDifferent is set to true, you would have 2 translation, otherwise you would have 1 translation saved - with higher updateTime. but if you have different attributes, like document, you would have 2 translation anyway. 
    newEntryIfOnlyContextAndTimestampDifferent would also increase number of saved segments. If values was not provided, default values from flags would be used.

TM must exist
It's async, so check status using status endpoint

TMX import could be interrupted in case of invalid XML or TM reaching it's limit or timeout. For both cases check status request to have info about position in tmx file where it was interrupted. 

Handling if framing tag situation differs from source to target - for skipAll or skipPaired

If framing tags situation is the same in source and target, both sides should be treated as described above.

If framing tags only exist in source, then still they should be treated as described above.

If they only exist in target, then  nothing should be removed.


...

Reorganize TM

PurposeReorganizes tm and fixing issues.
RequestGET /%service%/%tm_name%/reorganize
Headers

Accept - applicaton/xml

up to v0.4.x reorganize is sync, so t5memory 
starting from 0.5.x is async, so you can check status of reorganize similar to how you can check status for importTMX

Under the hood it creates new tm with $Org- prefix, then reimport all segments one-by-one, and then deletes original TM and rename reorganized TM to replace original. 
This request should flush tm(from RAM to the disk) before reorganizing


reorganize would check this condition

if (fValidXmlInSrc && fValidXmlInTrg && (pProposal->getSourceLen() != 0) && (pProposal->getTargetLen() != 0) &&
(szTargetLanguage[0] != EOS) && (szTagTable[0] != EOS) )

, and in case if this condition is true and then it passes segment to putProposal function, which is also used by UpdateRequest and ImportTmx request, so other 
issues could be connected to updating new tm.


In 0.4.48 reorganize responce would look like this

{
"too_long_reorg_0_4":"reorganized",
"time":"37 sec",
"reorganizedSegmentCount":"9424",
"invalidSegmentCount":"0"
}
so if there is invalid segments, inspect t5memory log

in 0.7 you can provide body to the request(optional)
Body(optional): 

{

  ["newEntryIfOnlyContextAndTimestampDifferent"]: 0,

     ["saveDifferentTargetsForSameSource"]: 0,

}


  • both newEntryIfOnlyContextAndTimestampDifferent and saveDifferentTargetsForSameSource impact how similar translation would be saved. In case if source and other field(doc, author, lang) are the same, but target different, and newEntryIfOnlyContextAndTimestampDifferent is set to true, you would have 2 translation, otherwise you would have 1 translation saved - with higher updateTime. but if you have different attributes, like document, you would have 2 translation anyway. 
    newEntryIfOnlyContextAndTimestampDifferent would also increase number of saved segments. If values was not provided, defaule values from flags would be used.







Export TMX from TM - old

PurposeCreates TMX from tm.
RequestGET /%service%/%tm_name%/
Headers

Accept - applicaton/xml


This endpoint should flush tm before execution

Code Block
languagejs
titleResponse
collapsetrue
Response example:<?xml version="1.0" encoding="UTF-8" ?>
<tmx version="1.4">
<header creationtoolversion="0.

Export TMX from TM - old

PurposeCreates TMX from tm.
RequestGET /%service%/%tm_name%/
Headers

Accept - applicaton/xml

This endpoint should flush tm before execution
Code Block
languagejs
titleResponse
collapsetrue
Response example:<?xml version="1.0" encoding="UTF-8" ?>
<tmx version="1.4">
<header creationtoolversion="0.2.14" gitCommit="60784cf * refactoring and cleanup" segtype="sentence" adminlang="en-us" srclang="en-GB" o-tmf="t5memory" creationtool="t5memory" datatype="xml" />
<body>
  <tu tuid="1" datatype="xml" creationdate="20190401T084052Z">
     <prop type="tmgr:segNum">10906825</prop>
     <prop type="tmgr:markup">OTMXML</prop>
     <prop type="tmgr:docname">none</prop>
     <tuv xml:lang="en-GB">
          <prop type="tmgr:language">English(U.K.)</prop>
          <seg>For > 100 setups.</seg>
     </tuv>
     <tuv xml:lang="de-DE">
          <prop type="tmgr:language">GERMAN(REFORM)</prop>
     <seg>Für > 100 Aufstellungen.</seg>
     </tuv>
     </tu>
   </body>
</tmx>


...

Update entry

PurposeUpdates entry\translation 
RequestPOST /%service%/%tm_name%/entry
Params

Only sourceLang, targetLang, source and target are required


This request would made changes only in the filebuffer(so files on disk would not be changed)
To write it to the disk just call request which would flush tm to the disk as part of execution(exportTMX, exportTM, cloneTM) or using SaveAllTms request 

Code Block
languagejs
titleResponse
collapsetrue
Request example:
{
    "source": "The end",
    "target": "The target",
    "sourceLang": "en", // langs would be checked with languages.xml
    "targetLang": "de", 
//additional field
    ["documentName": "Translate5 Demo Text-en-de.xlf"],
    ["segmentNumber": 8,]
    ["author": "Thomas Lauria"],
    ["timeStamp": "20210621T071042Z"], // if there is no timestamp, current time would be used
    ["context": "2_2"], // context and addInfo would be saved in TM in the same field
    ["addInfo": "2_2"], 
    ["type": "Manual"], // could be GlobalMemory, GlobalMemoryStar, MachineTranslation, Manual, by default Undefined         
    ["markupTable": "OTMXUXLF"], //if there is no markup, default OTMXUXLF would be used. 
								 //Markup tables should be located inside ~/.t5memory/TABLE/%markup$.TBL
    ["loggingThreshold": 0],
(in 0.7)  ["newEntryIfOnlyContextAndTimestampDifferent"]: 0,
(in 0.7)["saveDifferentTargetsForSameSource"]: 0, 
	["save2disk": 0]   // flag if we need to flush tm to disk after update. by default is true
}

here are data struct used for search, so you can see max numbers of 




both newEntryIfOnlyContextAndTimestampDifferent and saveDifferentTargetsForSameSource impact how similar translation would be saved. In case if source and other field(doc, author, lang) are the same, but target different, and newEntryIfOnlyContextAndTimestampDifferent is set to true, you would have 2 translation, otherwise you would have 1 translation saved - with higher updateTime. but if you have different attributes, like document, you would have 2 translation anyway. 
newEntryIfOnlyContextAndTimestampDifferent would also increase number of saved segments. If values was not provided, defaule values from flags would be used.
here are data struct used for search, so you can see max numbers of symbols
typedef struct _LOOKUPINMEMORYDATA
{
  char szMemory[260];
  wchar_t szSource[2050];
  wchar_t szTarget[2050];
  char szIsoSourceLang[40];
  char szIsoTargetLang[40];
  int lSegmentNum;
  char szDocName[260];
  char szMarkup[128];
  wchar_t szContext[2050];
  wchar_t szAddInfo[2050];
  wchar_t szError[512];
  char szType[256];
  char szAuthor[80];
  char szDateTime[40];
  char szSearchMode[40]; // only for concordance search
  char szSearchPos[80]; // only for concordance search
  int iNumOfProposals;
  int iSearchTime;
  wchar_t szSearchString[2050];
} LOOKUPINMEMORYDATA, *PLOOKUPINMEMORYDATA;

Response example:success:
example_new{
  "source": "The end",
  "sourceNPRepl": "The end",
  "sourceNorm": "The end",
  "target": "The target",
  "segmentNumber": 0,
  "id": "",
  "documentName": "Te2.xlf",
  "sourceLang": "DE-DE",
  "targetLang": "EN-GB",
  "type": "Manual",
  "author": "THOMAS LAURIA",
  "timestamp": "",
  "markupTable": "OTMXUXLF",
  "context": "2_3",
  "additionalInfo": "addInfo2",
  "internalKey": "8:1"
}

example_old
{
"sourceLang": "de-DE",
"targetLang": "en-GB",
"source": "The end",
"target": "The target",
"documentName": "Translate5 Demo Text-en-de.xlf",
"segmentNumber": 222,
"markupTable": "OTMXUXLF",
"timeStamp": "20210621T071042Z",
"author": "Thomas Lauria"
}

in case if similar record exists, t5memory comparing source text, 
if it's the same, t5memory would compare docName, 
if it's the same,t5memory would compare timestamps and would leave only newer one

in case if TM is alreade reached it's limit, you would get 
{
"ReturnValue": 5034,
"ErrorMsg": ""
}or{
"ReturnValue": 5035,
"ErrorMsg": ""
}




Code Block
languagejs
titleUpdateEntry Pseudo code
collapsetrue
Update entry pseudo code:update segment/import
{
  if we have triples equal match (candidate for exact match)
  {
    UpdateTmRecord
    if(updateFailed)
      AddToTMAsNewKey
      if(added) UpdateTmIndex
  }else{
    AddToTMAsNewKey
    if(added) UpdateTmIndex
  }
}

UpdateTmRecord{
  getListOfDataKeysFromIndexRecord
  sortThemByTriplesMatchesWithProposal(first have biggest match)

  foreach key untill fStop==true{
    readTmRecord // tm record is 16kB block in file, first number in "7:1"

    //compare tm record data with data passed in the get in structure
    CompareAndModifyPutData
    if(NO_ERROR) set fStop = true;
  }
}

CompareAndModifyPutData{
  if source strings are equal
    Delete old entry - with TMLoopAndDelTargetClb
  if fNewerTargetExists -> fStop = TRUE
  Loop thru target records
    loop over all target CLBs or until fStop
      if segment+file id found (exact-exact-found!)
        update time field in control block
        set fUpdate= fStop=TRUE
        update context info
      if not fStop
        goto next CLB
    endloop
    if no matching CLB has been found (if not fStop)
      add new CLB (ids, context, timestamp etc. )
    endloop
  endloop

  if fupdated, update TM record
  if !fStop (all target record have been tried & none matches )
    add new target record to end of tm record
  else
    return source_string_error // errcode for UpdateTmRecord to go to the next TM record in prepared list
}

TMLoopAndDelTargetClb{
  loop through all target records in tm record checking
    loop over all target CLBs or until fStop
      if lang + segment+file id found (exact-exact-found!)
        if entry is older
          delete it, fDel = TRUE
        else set fNewerTargetExists=TRUE(would be used in CompareAndModifyPutData)
          goon with search in next tgt CLB (control block)
      else
        goon with search in next tgt CLB (control block)
        endloop
      endif
    if not fDel
      position at next target record
  endloop
}


...

Delete entries / mass deletion

PurposeDeletes entries\translation 
RequestPOST /%service%/%tm_name%/entriesdelete
Params

This would start reorganize process which would remove like reorganize bad segments and also would remove segments that gives true when checking with provided filters combined with logical AND. So if you provide timestamps and addInfo, only segments within provided timestamp and with that addInfo would not be imported to new TM(check reorganize process). 
Every parameter is optional, so empty json would just start reorganize async process.
If you provide one of timestamps you would get error - please provide both. 
To add parameter you should set it's SearchMode to be EXACT|CONCORDANCE(non case sensetive)
If only searched string provided, but not search mode - you would get error.



Code Block
languagejs
titleResponse
collapsetrue
Request example: 
{
["addInfo": "ADD_INFO"],
["addInfoSearchMode" : "EXACT"],
["context": "CONTEXT"],
["contextSearchMode": "concordance"],
["author": "AUTHOR"],
["authorSearchMode": "exact"],
["document":"document"],
["documentSearchMode":"CONCORDANCE"],
["timestampSpanStart": "20000121T115234Z"],
["timestampSpanEnd": "20240121T115234Z"],
(in 0.7.x)
  ["newEntryIfOnlyContextAndTimestampDifferent"]: 0,
     ["saveDifferentTargetsForSameSource"]: 0, 
}
Responce example:
{
  "fileFlushed": 0,
  "results": {
     "source": "The tar",
     "target": "The target",
     "segmentNumber": 0,
     "id": "",
     "documentName": "Te2.xlf",
     "sourceLang": "de-DE",
     "targetLang": "EN-GB",
     "type": "Manual",
     "author": "THOMAS LAURIA",
     "timestamp": "20231229T125701Z",
     "markupTable": "OTMXUXLF",
     "context": "2_3",
    "additionalInfo": "",
    "internalKey": "7:1"
  }
}


both newEntryIfOnlyContextAndTimestampDifferent and saveDifferentTargetsForSameSource impact how similar translation would be saved. In case if source and other field(doc, author, lang) are the same, but target different, and newEntryIfOnlyContextAndTimestampDifferent is set to true, you would have 2 translation, otherwise you would have 1 translation saved - with higher updateTime. but if you have different attributes, like document, you would have 2 translation anyway. 
newEntryIfOnlyContextAndTimestampDifferent would also increase number of saved segments. If values was not provided, defaule values from flags would be used.




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.

RequestGET /%service%_service/savetms
Params

-


Code Block
languagejs
titleResponse
collapsetrue
Response example:{
   'saved 4 files': '/home/or/.t5memory/MEM/mem2.TMD, /home/or/.t5memory/MEM/mem2.TMI, /home/or/.t5memory/MEM/newBtree3.TMD, /home/or/.t5memory/MEM/newBtree3.TMI'
} List of saved files


...