Manage Translation Memories
Translation memory Management
Translation Memories are tools that save previously translated text segments, such as sentences or paragraphs. Each saved segment includes the 'source' text and its translated 'target' text, forming pairs known as translation units (TUs). These translation memories connect with Lara via specific APIs, and you can find instructions on how to add and update them in this section of the API documentation. Lara's adaptive version significantly outperforms the static version, ensuring more effective and efficient translations.
All memories functionalities can be accessed via the same Translator (lara in the example) object created to translate.
Memory object
Field | Type | Description |
---|---|---|
id | String | Unique ID of the memory. Format: mem_xyz123 |
secret | String | Unique Secret of the memory, used for sharing feature |
name | String | Custom name of the memory, it can be any string including spaces and special characters and non-latin alphabets. Max length: 250 characters. |
created_at | DateTime | When the memory is created |
updated_at | DateTime | When the memory is last updated (equal to created_at with no updates) |
owner_id | String | User who owns the memory. Format: acc_123xyz |
shared_at | DateTime | When the memory is last shared (equal to created_at if never shared) |
collaborators_count | Integer | Number of users who can access this memory to retrieve TU |
List Memories
Lists all memories available to the user
# List all memories available to the user
memories = lara.memories.list()
// List all memories available to the user
const memories = await lara.memories.list();
// List all memories available to the user
List<Memory> memories = lara.memories.list();
// List all memories available to the user
$memories = $lara->memories->getAll();
Create new Memory
Creates a new memory with a custom name. It is possible to import a memory from MyMemory using as external_id
the id of the memory on MyMemory
# Create a new empty memory with name 'Memory 1'
memory = lara.memories.create('Memory 1')
# Create a new memory with name 'Memory from MyMemory' using the content of the memory on MyMemory (with id aabb1122)
memory_2 = lara.memories.create('Memory from MyMemory', 'aabb1122')
// Create a new empty memory with name 'Memory 1'
const memory = await lara.memories.create('Memory 1');
// Create a new memory with name 'Memory from MyMemory' using the content of the memory on MyMemory (with id aabb1122)
const memory2 = await lara.memories.create('Memory from MyMemory', 'aabb1122');
// Create a new empty memory with name 'Memory 1'
Memory memory = lara.memories.create("Memory 1");
// Create a new memory with name 'Memory from MyMemory' using the content of the memory on MyMemory (with id aabb1122)
Memory memory2 = lara.memories.create("Memory from MyMemory", "aabb1122");
// Create a new empty memory with name 'Memory 1'
$memory = $lara->memories->create('Memory 1');
// Create a new memory with name 'Memory from MyMemory' using the content of the memory on MyMemory (with id aabb1122)
$memory2 = $lara->memories->create('Memory from MyMemory', 'aabb1122');
Field | Type | Required | Default | Description |
---|---|---|---|---|
name | String | Yes | - | The name of the new memory |
external_id | String | No | - | The ID of the memory to be imported from MyMemory. Use this to initialize the memory with external content. Format: ext_my_[MyMemory ID] |
Update Memory Name
Updates the name of a specific memory
# Update memory name
updated_memory = lara.memories.update('mem_1...', 'New Name for my memory')
// Update memory name
const updatedMemory = await lara.memories.update('mem_1...', 'New Name for my memory');
// Update memory name
Memory updatedMemory = lara.memories.update("mem_1...", "New Name for my memory");
// Update memory name
$updatedMemory = $lara->memories->update('mem_1...', 'New Name for my memory');
Field | Type | Required | Default | Description |
---|---|---|---|---|
id | String | Yes | - | The unique identifier of the memory to update. Format: mem_xyz123 |
name | String | Yes | - | The new name for the memory |
Delete Memory
Deletes a specific memory
# Delete a memory
deleted_memory = lara.memories.delete('mem_1...')
// Delete a memory
const deletedMemory = await lara.memories.delete('mem_1...');
// Delete a memory
Memory deletedMemory = lara.memories.delete("mem_1...");
// Delete a memory
$deletedMemory = $lara->memories->delete('mem_1...');
Field | Type | Required | Default | Description |
---|---|---|---|---|
id | String | Yes | - | The unique identifier of the memory to update. Format: mem_xyz123 |
Import TMX to Memory
Imports a TMX file into an existing memory
# Import a local tmx file to an existing memory
import_job = lara.memories.import_tmx('mem_1...', 'file/to/path')
/*
NODE
*/
import * as fs from 'fs';
// Import a local tmx file to an existing memory
const stream = fs.createReadStream('path/to/tmx');
const importJob = await lara.memories.importTmx('mem_1...', stream);
// Import a local compressed tmx file to an existing memory
const streamGzip = fs.createReadStream('path/to/tmx.gz');
const importJobGzip = await lara.memories.importTmx('mem_1...', streamGzip, true)
/*
BROWSER
*/
// replace with your input id
const fileInput = document.getElementById("fileInput");
const file = fileInput.files[0];
const importJob = await lara.memories.importTmx(MEMORY_ID, file, true/false);
// Import a local tmx file to an existing memory
MemoryImport importJob = lara.memories.importTmx("mem_1...", new File("file/to/path"));
// Import a local tmx file to an existing memory
$importJob = $lara->memories->importTmx('mem_1...', 'file/to/path');
Field | Type | Required | Default | Description |
---|---|---|---|---|
id | String | Yes | - | The unique identifier of the memory to update. Format: mem_xyz123 |
tmx | File | Stream | String | Yes | - | The tmx file to upload |
gzip | Boolean | No | False | Indicates if the file is a compressed |
Check Import Status
Checks the status of an ongoing memory import using the unique import_job
id returned in the "Import TMX" method
# Import a local tmx file to an existing memory
import_job = lara.memories.import_tmx('mem_1...', 'file/to/path')
// Import a local tmx file to an existing memory
const importJob = await lara.memories.importTmx('mem_1...', 'file/to/path');
// Import a local tmx file to an existing memory
boolean importJob = lara.memories.importTmx("mem_1...", "file/to/path");
// Import a local tmx file to an existing memory
$importJob = $lara->memories->importTmx('mem_1...', 'file/to/path');
Field | Type | Required | Default | Description |
---|---|---|---|---|
id | String | Yes | - | The ID of the import job |
Add Translation (TU) to Memory
Add a translation unit to a memory. Context information and unique ID can be specified
# Add a simple translation unit to an existing memory
import_job = lara.memories.add_translation(
'mem_1...',
source='en-US',
target='it-IT',
sentence='Hello World!',
translation='Ciao Mondo!'
)
# Add a simple translation unit to multiple existing memories
multi_import_job = lara.memories.add_translation(
['mem_1...', 'mem_2...'],
source='en-US',
target='it-IT',
sentence='Hello World!',
translation='Ciao Mondo!'
)
// Add a simple translation unit to an existing memory
const importJob = await lara.memories.addTranslation(
'mem_1...',
'en-US',
'it-IT',
'Hello World!',
'Ciao Mondo!'
);
// Add a simple translation unit to multiple existing memories
const multiImportJob = await lara.memories.addTranslation(
['mem_1...', 'mem_2...'],
'en-US',
'it-IT',
'Hello World!',
'Ciao Mondo!'
);
// Add a simple translation unit to an existing memory
MemoryImport importJob = lara.memories.addTranslation(
"mem_1...",
"en-US",
"it-IT",
"Hello World!",
"Ciao Mondo!"
);
// Add a simple translation unit to multiple existing memories
MemoryImport multiImportJob = lara.memories.addTranslation(
Arrays.asList("mem_1...", "mem_2..."),
"en-US",
"it-IT",
"Hello World!",
"Ciao Mondo!"
);
// Add a simple translation unit to an existing memory
$importJob = $lara->memories->addTranslation(
'mem_1...',
'en-US',
'it-IT',
'Hello World!',
'Ciao Mondo!'
);
// Add a simple translation unit to multiple existing memories
$multiImportJob = $lara->memories->addTranslation(
array('mem_1...', 'mem_2...'),
'en-US',
'it-IT',
'Hello World!',
'Ciao Mondo!'
);
Field | Type | Parameter Type | Required | Default | Description |
---|---|---|---|---|---|
id | String | String[] | Positional | Yes | - | The ID or list of IDs where to save the translation unit. Format: mem_xyz123 |
source | String | Keyword | Yes | - | The source language code of the sentence |
target | String | Keyword | Yes | - | The target language code of the translation |
sentence | String | Keyword | Yes | - | The source sentence |
translation | String | Keyword | Yes | - | The translated sentence |
tuid | String | Keyword | No | Null | Translation Unit unique identifier |
sentence_before | String | Keyword | No | Null | The sentence before the source sentence to specify the context of the translation unit |
sentence_after | String | Keyword | No | Null | The sentence after the source sentence to specify the context of the translation unit |
Delete Translation (TU) from Memory
Deletes specific translations from a memory. Context information and unique ID can be specified
# Delete a translation unit using a combination of {source, target, sentence, translation}
delete_job = lara.memories.delete_translation(
'mem_1...',
source='en-US',
target='it-IT',
sentence='Hello World!',
translation='Ciao Mondo!'
)
// Delete a translation unit using a combination of {source, target, sentence, translation}
const deleteJob = await lara.memories.deleteTranslation(
'mem_1...',
'en-US',
'it-IT',
'Hello World!',
'Ciao Mondo!'
);
// Delete a translation unit using a combination of {source, target, sentence, translation}
MemoryImport deleteJob = lara.memories.deleteTranslation(
"mem_1...",
"en-US",
"it-IT",
"Hello World!",
"Ciao Mondo!"
);
// Delete a translation unit using a combination of {source, target, sentence, translation}
$deleteJob = $lara->memories->deleteTranslation(
'mem_1...',
'en-US',
'it-IT',
'Hello World!',
'Ciao Mondo!'
);
Field | Type | Required | Default | Description |
---|---|---|---|---|
id | String | String[] | Yes | - | The ID or list of IDs where to delete the translation unit from.\ Format: mem_xyz123 |
source | String | Yes | - | The source language code of the sentence |
target | String | Yes | - | The target language code of the translation |
sentence | String | Yes | - | The source sentence |
translation | String | Yes | - | The translated sentence |
tuid | String | No | Null | Translation Unit unique identifier |
sentence_before | String | No | Null | The sentence before the source sentence to specify the context of the translation unit |
sentence_after | String | No | Null | The sentence after the source sentence to specify the context of the translation unit |
Updated 3 months ago