hybridtm 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -8
- package/dist/batchimporter.d.ts +0 -22
- package/dist/batchimporter.js +0 -203
- package/dist/constants.d.ts +0 -15
- package/dist/constants.js +0 -16
- package/dist/constants.js.map +0 -1
- package/dist/debug-progress.d.ts +0 -12
- package/dist/debug-progress.js +0 -49
- package/dist/debug-progress.js.map +0 -1
- package/dist/ngramIndex.d.ts +0 -31
- package/dist/ngramIndex.js +0 -132
- package/dist/ngramIndex.js.map +0 -1
- package/dist/ngrams.d.ts +0 -21
- package/dist/ngrams.js +0 -73
- package/dist/ngrams.js.map +0 -1
- package/dist/package.json +0 -35
- package/dist/progressProvider.d.ts +0 -17
- package/dist/progressProvider.js +0 -14
- package/dist/progressProvider.js.map +0 -1
- package/dist/simplexlifftest.d.ts +0 -1
- package/dist/simplexlifftest.js +0 -23
- package/dist/simplexlifftest.js.map +0 -1
- package/dist/test-import.d.ts +0 -12
- package/dist/test-import.js +0 -101
- package/dist/test-import.js.map +0 -1
- package/dist/test-progress-fix.d.ts +0 -1
- package/dist/test-progress-fix.js +0 -32
- package/dist/test-progress-fix.js.map +0 -1
- package/dist/test-progress.d.ts +0 -12
- package/dist/test-progress.js +0 -32
- package/dist/test-progress.js.map +0 -1
- package/dist/tests/vectorSimilarityComparison.d.ts +0 -12
- package/dist/tests/vectorSimilarityComparison.js +0 -153
- package/dist/tests/vectorSimilarityComparison.js.map +0 -1
- package/dist/tmxreader.d.ts +0 -25
- package/dist/tmxreader.js +0 -51
- package/dist/tmxtest.d.ts +0 -16
- package/dist/tmxtest.js +0 -316
- package/dist/tmxtest.js.map +0 -1
- package/dist/ts/batchImporter.js.map +0 -1
- package/dist/ts/hybridtm.d.ts +0 -67
- package/dist/ts/hybridtm.js +0 -932
- package/dist/ts/hybridtm.js.map +0 -1
- package/dist/ts/hybridtmFactory.d.ts +0 -43
- package/dist/ts/hybridtmFactory.js +0 -165
- package/dist/ts/hybridtmFactory.js.map +0 -1
- package/dist/ts/importOptions.d.ts +0 -21
- package/dist/ts/importOptions.js +0 -24
- package/dist/ts/importOptions.js.map +0 -1
- package/dist/ts/index.d.ts +0 -25
- package/dist/ts/index.js +0 -22
- package/dist/ts/index.js.map +0 -1
- package/dist/ts/langEntry.d.ts +0 -64
- package/dist/ts/langEntry.js +0 -13
- package/dist/ts/langEntry.js.map +0 -1
- package/dist/ts/match.d.ts +0 -22
- package/dist/ts/match.js +0 -38
- package/dist/ts/match.js.map +0 -1
- package/dist/ts/matchQuality.d.ts +0 -16
- package/dist/ts/matchQuality.js +0 -83
- package/dist/ts/matchQuality.js.map +0 -1
- package/dist/ts/pendingEntry.d.ts +0 -24
- package/dist/ts/pendingEntry.js +0 -13
- package/dist/ts/pendingEntry.js.map +0 -1
- package/dist/ts/searchFilters.d.ts +0 -24
- package/dist/ts/searchFilters.js +0 -13
- package/dist/ts/searchFilters.js.map +0 -1
- package/dist/ts/tmxHandler.d.ts +0 -61
- package/dist/ts/tmxHandler.js +0 -347
- package/dist/ts/tmxHandler.js.map +0 -1
- package/dist/ts/tmxReader.js.map +0 -1
- package/dist/ts/tmxtest.d.ts +0 -16
- package/dist/ts/tmxtest.js +0 -316
- package/dist/ts/tmxtest.js.map +0 -1
- package/dist/ts/utils.d.ts +0 -17
- package/dist/ts/utils.js +0 -49
- package/dist/ts/utils.js.map +0 -1
- package/dist/ts/xliffHandler.d.ts +0 -67
- package/dist/ts/xliffHandler.js +0 -522
- package/dist/ts/xliffHandler.js.map +0 -1
- package/dist/ts/xliffReader.js.map +0 -1
- package/dist/ts/xlifftest.d.ts +0 -54
- package/dist/ts/xlifftest.js +0 -245
- package/dist/ts/xlifftest.js.map +0 -1
- package/dist/vectorSimilarityTester.d.ts +0 -56
- package/dist/vectorSimilarityTester.js +0 -164
- package/dist/vectorSimilarityTester.js.map +0 -1
- package/dist/xliffreader.d.ts +0 -25
- package/dist/xliffreader.js +0 -50
- package/dist/xlifftest.d.ts +0 -54
- package/dist/xlifftest.js +0 -245
- package/dist/xlifftest.js.map +0 -1
- /package/dist/{ts/batchImporter.d.ts → batchImporter.d.ts} +0 -0
- /package/dist/{ts/batchImporter.js → batchImporter.js} +0 -0
- /package/dist/{batchimporter.js.map → batchImporter.js.map} +0 -0
- /package/dist/{tmxhandler.d.ts → tmxHandler.d.ts} +0 -0
- /package/dist/{tmxhandler.js → tmxHandler.js} +0 -0
- /package/dist/{tmxhandler.js.map → tmxHandler.js.map} +0 -0
- /package/dist/{ts/tmxReader.d.ts → tmxReader.d.ts} +0 -0
- /package/dist/{ts/tmxReader.js → tmxReader.js} +0 -0
- /package/dist/{tmxreader.js.map → tmxReader.js.map} +0 -0
- /package/dist/{xliffhandler.d.ts → xliffHandler.d.ts} +0 -0
- /package/dist/{xliffhandler.js → xliffHandler.js} +0 -0
- /package/dist/{xliffhandler.js.map → xliffHandler.js.map} +0 -0
- /package/dist/{ts/xliffReader.d.ts → xliffReader.d.ts} +0 -0
- /package/dist/{ts/xliffReader.js → xliffReader.js} +0 -0
- /package/dist/{xliffreader.js.map → xliffReader.js.map} +0 -0
package/dist/ts/tmxtest.js
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import { rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { BatchImporter } from './batchImporter.js';
|
|
3
|
-
import { HybridTM } from './hybridtm.js';
|
|
4
|
-
import { HybridTMFactory } from './hybridtmFactory.js';
|
|
5
|
-
import { Utils } from './utils.js';
|
|
6
|
-
export class TMXTest {
|
|
7
|
-
static NAME = 'TMX Test';
|
|
8
|
-
static DB_PATH = 'my-tmx.lancedb';
|
|
9
|
-
static SAMPLE_TMX = './samples/fluenta_sample.tmx';
|
|
10
|
-
static SWORD_FISH_TMX = './samples/terms.xlf.tmx';
|
|
11
|
-
async runTest() {
|
|
12
|
-
try {
|
|
13
|
-
this.resetEnvironment();
|
|
14
|
-
const tm = HybridTMFactory.createInstance(TMXTest.NAME, TMXTest.DB_PATH, HybridTM.SPEED_MODEL);
|
|
15
|
-
console.log('Created new HybridTM instance with name: ' + TMXTest.NAME);
|
|
16
|
-
await tm.importTMX(TMXTest.SAMPLE_TMX)
|
|
17
|
-
.then(() => {
|
|
18
|
-
console.log('TMX file imported successfully.');
|
|
19
|
-
})
|
|
20
|
-
.catch(err => {
|
|
21
|
-
console.error('Failed to import TMX file:', err);
|
|
22
|
-
});
|
|
23
|
-
await this.verifyEntry(tm, 'fluenta_sample.tmx', 'TMX-001', 'en', 0, 1);
|
|
24
|
-
await this.verifyEntry(tm, 'fluenta_sample.tmx', 'TMX-001', 'es', 0, 1);
|
|
25
|
-
await this.expectTranslationMatch(tm, 'Fluenta recovers exact matches from translations stored in the previous cycle.', 'en', 'es', 90, 'Fluenta recovers exact matches from translations stored in the previous cycle.', 'Fluenta recupera coincidencias exactas de las traducciones almacenadas en el ciclo anterior.', 'TMX exact match');
|
|
26
|
-
await this.expectTranslationMatch(tm, 'Fluenta automatically recovers exact matches from the previous translation cycle.', 'en', 'es', 75, 'Fluenta recovers exact matches from translations stored in the previous cycle.', 'Fluenta recupera coincidencias exactas de las traducciones almacenadas en el ciclo anterior.', 'TMX fuzzy paraphrase');
|
|
27
|
-
await this.expectTranslationMatch(tm, 'You do not need to pay again for content that stayed the same.', 'en', 'es', 65, 'You don\'t need to pay again for translation of content that didn\'t change.', 'No necesita pagar de nuevo por la traducción del contenido que no cambió.', 'TMX semantic reuse reminder');
|
|
28
|
-
await this.expectConcordanceMatch(tm, 'translation memory for reuse', 'en', 'es', 'Archive the translation memory for reuse.', 'Archive la memoria de traducción para su reutilización.', 'TMX concordance reuse unit');
|
|
29
|
-
await this.logConcordanceExample(tm, 'translation memory', 'en');
|
|
30
|
-
await tm.importTMX(TMXTest.SWORD_FISH_TMX);
|
|
31
|
-
await this.verifySegmentMetadata(tm, 'terms.xlf.tmx', '228667853-1-11-11', 'en', {
|
|
32
|
-
fileHash: '228667853',
|
|
33
|
-
fileId: '1',
|
|
34
|
-
unitId: '11',
|
|
35
|
-
segmentId: '11'
|
|
36
|
-
});
|
|
37
|
-
await this.verifyMetadataRoundtrip(tm);
|
|
38
|
-
await this.verifyBatchImporterRoundtrip(tm);
|
|
39
|
-
await tm.close();
|
|
40
|
-
console.log('Test completed successfully');
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
console.error('Test failed:', err);
|
|
44
|
-
throw err;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
resetEnvironment() {
|
|
48
|
-
try {
|
|
49
|
-
HybridTMFactory.removeInstance(TMXTest.NAME);
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
// ignore missing instance
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
rmSync(TMXTest.DB_PATH, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
// ignore cleanup issues
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async verifyEntry(tm, fileId, unitId, lang, segmentIndex, segmentCount) {
|
|
62
|
-
const entry = await tm.getLangEntry(fileId, unitId, lang, segmentIndex);
|
|
63
|
-
if (!entry) {
|
|
64
|
-
throw new Error('Entry not found for ' + fileId + ':' + unitId + ':' + segmentIndex + ':' + lang);
|
|
65
|
-
}
|
|
66
|
-
if (entry.id !== fileId + ':' + unitId + ':' + segmentIndex + ':' + lang) {
|
|
67
|
-
throw new Error('Unexpected entry id ' + entry.id);
|
|
68
|
-
}
|
|
69
|
-
if (entry.segmentIndex !== segmentIndex) {
|
|
70
|
-
throw new Error('Segment index mismatch for ' + entry.id);
|
|
71
|
-
}
|
|
72
|
-
if (entry.segmentCount !== segmentCount) {
|
|
73
|
-
throw new Error('Segment count mismatch for ' + entry.id);
|
|
74
|
-
}
|
|
75
|
-
if (!entry.metadata) {
|
|
76
|
-
throw new Error('Metadata missing for ' + entry.id);
|
|
77
|
-
}
|
|
78
|
-
if (!entry.vector || entry.vector.length === 0) {
|
|
79
|
-
throw new Error('Vector missing for ' + entry.id);
|
|
80
|
-
}
|
|
81
|
-
console.log('Verified entry ' + entry.id + ' with vector size ' + entry.vector.length);
|
|
82
|
-
}
|
|
83
|
-
async verifySegmentMetadata(tm, fileId, unitId, lang, expected) {
|
|
84
|
-
const entry = await tm.getLangEntry(fileId, unitId, lang, 0);
|
|
85
|
-
if (!entry || !entry.metadata || !entry.metadata.segment) {
|
|
86
|
-
throw new Error('Missing segment metadata for ' + unitId);
|
|
87
|
-
}
|
|
88
|
-
const segmentMeta = entry.metadata.segment;
|
|
89
|
-
if (segmentMeta.provider !== 'xliff-segment') {
|
|
90
|
-
throw new Error('Unexpected metadata provider for ' + unitId);
|
|
91
|
-
}
|
|
92
|
-
if (segmentMeta.fileHash !== expected.fileHash ||
|
|
93
|
-
segmentMeta.fileId !== expected.fileId ||
|
|
94
|
-
segmentMeta.unitId !== expected.unitId ||
|
|
95
|
-
segmentMeta.segmentId !== expected.segmentId) {
|
|
96
|
-
throw new Error('Segment metadata mismatch for ' + unitId);
|
|
97
|
-
}
|
|
98
|
-
if (!segmentMeta.segmentKey || segmentMeta.segmentKey !== unitId) {
|
|
99
|
-
throw new Error('Segment key missing on metadata for ' + unitId);
|
|
100
|
-
}
|
|
101
|
-
if (!entry.metadata.context || entry.metadata.context.indexOf('unit 10, segment 10') === -1) {
|
|
102
|
-
throw new Error('Directional context not decoded for ' + unitId);
|
|
103
|
-
}
|
|
104
|
-
console.log('Verified segment metadata for ' + unitId + ' (' + segmentMeta.segmentKey + ')');
|
|
105
|
-
}
|
|
106
|
-
async expectTranslationMatch(tm, query, srcLang, tgtLang, similarity, expectedSourceSnippet, expectedTargetSnippet, label) {
|
|
107
|
-
const matches = await tm.semanticTranslationSearch(query, srcLang, tgtLang, similarity);
|
|
108
|
-
if (matches.length === 0) {
|
|
109
|
-
throw new Error('No matches found for "' + label + '" query.');
|
|
110
|
-
}
|
|
111
|
-
const best = matches[0];
|
|
112
|
-
const sourceXml = best.source.toString();
|
|
113
|
-
const targetXml = best.target.toString();
|
|
114
|
-
if (!sourceXml.includes(expectedSourceSnippet)) {
|
|
115
|
-
throw new Error('Unexpected source match for "' + label + '": ' + sourceXml);
|
|
116
|
-
}
|
|
117
|
-
if (!targetXml.includes(expectedTargetSnippet)) {
|
|
118
|
-
throw new Error('Unexpected target match for "' + label + '": ' + targetXml);
|
|
119
|
-
}
|
|
120
|
-
console.log('[' + label + '] matches=' + matches.length + ' semantic=' + best.semantic + ' fuzzy=' + best.fuzzy + ' hybrid=' + best.hybridScore());
|
|
121
|
-
}
|
|
122
|
-
async expectConcordanceMatch(tm, fragment, srcLang, tgtLang, expectedSourceSnippet, expectedTargetSnippet, label) {
|
|
123
|
-
const results = await tm.concordanceSearch(fragment, srcLang, 5);
|
|
124
|
-
if (results.length === 0) {
|
|
125
|
-
throw new Error('No concordance matches found for "' + label + '" fragment.');
|
|
126
|
-
}
|
|
127
|
-
const best = results[0];
|
|
128
|
-
const sourceElement = best.get(srcLang);
|
|
129
|
-
const targetElement = best.get(tgtLang);
|
|
130
|
-
if (!sourceElement || !sourceElement.toString().includes(expectedSourceSnippet)) {
|
|
131
|
-
throw new Error('Unexpected concordance source for "' + label + '".');
|
|
132
|
-
}
|
|
133
|
-
if (!targetElement || !targetElement.toString().includes(expectedTargetSnippet)) {
|
|
134
|
-
throw new Error('Unexpected concordance target for "' + label + '".');
|
|
135
|
-
}
|
|
136
|
-
console.log('[' + label + '] concordance languages=' + Array.from(best.keys()).join(', '));
|
|
137
|
-
}
|
|
138
|
-
async logConcordanceExample(tm, fragment, language) {
|
|
139
|
-
const rows = await tm.concordanceSearch(fragment, language, 1);
|
|
140
|
-
if (rows.length === 0) {
|
|
141
|
-
console.log('No concordance example available for "' + fragment + '".');
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
console.log('Concordance example for "' + fragment + '":');
|
|
145
|
-
const sample = rows[0];
|
|
146
|
-
sample.forEach((element, langKey) => {
|
|
147
|
-
const pureText = Utils.getPureText(element).trim().replace(/\s+/g, ' ');
|
|
148
|
-
const flattened = pureText.length > 0
|
|
149
|
-
? pureText
|
|
150
|
-
: element.toString().replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
|
|
151
|
-
console.log(' [' + langKey + '] ' + flattened);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
async verifyMetadataRoundtrip(tm) {
|
|
155
|
-
const fileId = 'metadata-roundtrip.tmx';
|
|
156
|
-
const unitId = 'ROUNDTRIP-UNIT-1';
|
|
157
|
-
const lang = 'en';
|
|
158
|
-
const segmentIndex = 0;
|
|
159
|
-
const sourceElement = Utils.buildXMLElement('<seg>Metadata roundtrip source</seg>');
|
|
160
|
-
const metadata = {
|
|
161
|
-
state: 'final',
|
|
162
|
-
subState: 'approved',
|
|
163
|
-
quality: 97,
|
|
164
|
-
creationDate: '2024-12-01T10:00:00Z',
|
|
165
|
-
creationId: 'author@example.com',
|
|
166
|
-
changeDate: '2024-12-15T12:34:56Z',
|
|
167
|
-
changeId: 'reviewer@example.com',
|
|
168
|
-
creationTool: 'HybridTM Test Harness',
|
|
169
|
-
creationToolVersion: '1.0.0',
|
|
170
|
-
context: 'Roundtrip metadata context',
|
|
171
|
-
notes: ['roundtrip-note-a', 'roundtrip-note-b'],
|
|
172
|
-
usageCount: 7,
|
|
173
|
-
lastUsageDate: '2025-01-01T08:30:00Z',
|
|
174
|
-
properties: {
|
|
175
|
-
product: 'HybridTM',
|
|
176
|
-
channel: 'support'
|
|
177
|
-
},
|
|
178
|
-
segment: {
|
|
179
|
-
provider: 'unit-test',
|
|
180
|
-
fileHash: 'hash-rt-001',
|
|
181
|
-
fileId: 'roundtrip-file',
|
|
182
|
-
unitId,
|
|
183
|
-
segmentId: 'seg-0',
|
|
184
|
-
segmentIndex,
|
|
185
|
-
segmentCount: 1,
|
|
186
|
-
segmentKey: unitId + '-0'
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
await tm.storeLangEntry(fileId, sourceElement.toString(), unitId, lang, 'Metadata roundtrip source', sourceElement, undefined, segmentIndex, 1, metadata);
|
|
190
|
-
const fetched = await tm.getLangEntry(fileId, unitId, lang, segmentIndex);
|
|
191
|
-
if (!fetched) {
|
|
192
|
-
throw new Error('Metadata roundtrip entry missing for ' + unitId);
|
|
193
|
-
}
|
|
194
|
-
this.assertMetadataEquals(fetched.metadata, metadata);
|
|
195
|
-
console.log('[Metadata roundtrip] state=' + fetched.metadata.state + ' quality=' + fetched.metadata.quality + ' properties=' + JSON.stringify(fetched.metadata.properties));
|
|
196
|
-
}
|
|
197
|
-
async verifyBatchImporterRoundtrip(tm) {
|
|
198
|
-
const tempPath = './temp-jsonl-roundtrip.jsonl';
|
|
199
|
-
const fileId = 'jsonl-batch-roundtrip.tmx';
|
|
200
|
-
const enrichedMetadata = {
|
|
201
|
-
state: 'reviewed',
|
|
202
|
-
context: 'JSONL batch importer context',
|
|
203
|
-
notes: ['jsonl-note-a', 'jsonl-note-b'],
|
|
204
|
-
properties: {
|
|
205
|
-
channel: 'jsonl-test',
|
|
206
|
-
domain: 'batch-importer'
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
const entries = [
|
|
210
|
-
{
|
|
211
|
-
language: 'en',
|
|
212
|
-
fileId,
|
|
213
|
-
original: fileId,
|
|
214
|
-
unitId: 'JSONL-UNIT-1',
|
|
215
|
-
pureText: 'JSONL batch importer roundtrip source',
|
|
216
|
-
element: '<seg>JSONL batch importer roundtrip source</seg>',
|
|
217
|
-
segmentIndex: 0,
|
|
218
|
-
segmentCount: 1,
|
|
219
|
-
metadata: enrichedMetadata
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
language: 'es',
|
|
223
|
-
fileId,
|
|
224
|
-
original: fileId,
|
|
225
|
-
unitId: 'JSONL-UNIT-2',
|
|
226
|
-
pureText: 'JSONL batch importer roundtrip target',
|
|
227
|
-
element: '<seg>JSONL batch importer roundtrip target</seg>',
|
|
228
|
-
segmentIndex: 0,
|
|
229
|
-
segmentCount: 1
|
|
230
|
-
}
|
|
231
|
-
];
|
|
232
|
-
const payload = entries
|
|
233
|
-
.map((entry) => JSON.stringify(entry))
|
|
234
|
-
.join('\n') + '\n';
|
|
235
|
-
writeFileSync(tempPath, payload, { encoding: 'utf8' });
|
|
236
|
-
const importer = new BatchImporter(tm, tempPath, entries.length);
|
|
237
|
-
await importer.import();
|
|
238
|
-
const enriched = await tm.getLangEntry(fileId, 'JSONL-UNIT-1', 'en', 0);
|
|
239
|
-
if (!enriched) {
|
|
240
|
-
throw new Error('BatchImporter JSONL entry with metadata missing');
|
|
241
|
-
}
|
|
242
|
-
this.assertMetadataEquals(enriched.metadata, enrichedMetadata);
|
|
243
|
-
const minimal = await tm.getLangEntry(fileId, 'JSONL-UNIT-2', 'es', 0);
|
|
244
|
-
if (!minimal) {
|
|
245
|
-
throw new Error('BatchImporter JSONL entry without metadata missing');
|
|
246
|
-
}
|
|
247
|
-
if (Object.keys(minimal.metadata).length !== 0) {
|
|
248
|
-
throw new Error('Expected empty metadata object for JSONL-UNIT-2 entry');
|
|
249
|
-
}
|
|
250
|
-
console.log('[BatchImporter JSONL roundtrip] enrichedKeys=' + Object.keys(enriched.metadata).length + ' minimalKeys=' + Object.keys(minimal.metadata).length);
|
|
251
|
-
}
|
|
252
|
-
assertMetadataEquals(actual, expected) {
|
|
253
|
-
const fail = (field, actualValue, expectedValue) => {
|
|
254
|
-
throw new Error('Metadata roundtrip mismatch for ' + field + ': expected ' + JSON.stringify(expectedValue) + ' but received ' + JSON.stringify(actualValue));
|
|
255
|
-
};
|
|
256
|
-
const scalarFields = [
|
|
257
|
-
'state',
|
|
258
|
-
'subState',
|
|
259
|
-
'quality',
|
|
260
|
-
'creationDate',
|
|
261
|
-
'creationId',
|
|
262
|
-
'changeDate',
|
|
263
|
-
'changeId',
|
|
264
|
-
'creationTool',
|
|
265
|
-
'creationToolVersion',
|
|
266
|
-
'context',
|
|
267
|
-
'usageCount',
|
|
268
|
-
'lastUsageDate'
|
|
269
|
-
];
|
|
270
|
-
scalarFields.forEach((field) => {
|
|
271
|
-
if ((actual[field] ?? null) !== (expected[field] ?? null)) {
|
|
272
|
-
fail(field, actual[field], expected[field]);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
const expectedNotes = expected.notes ?? [];
|
|
276
|
-
const actualNotes = actual.notes ?? [];
|
|
277
|
-
if (actualNotes.length !== expectedNotes.length || !actualNotes.every((value, index) => value === expectedNotes[index])) {
|
|
278
|
-
fail('notes', actualNotes, expectedNotes);
|
|
279
|
-
}
|
|
280
|
-
const normalizeObject = (value) => {
|
|
281
|
-
if (!value) {
|
|
282
|
-
return {};
|
|
283
|
-
}
|
|
284
|
-
const sortedKeys = Object.keys(value).sort();
|
|
285
|
-
return sortedKeys.reduce((acc, key) => {
|
|
286
|
-
acc[key] = value[key];
|
|
287
|
-
return acc;
|
|
288
|
-
}, {});
|
|
289
|
-
};
|
|
290
|
-
const actualProperties = normalizeObject(actual.properties);
|
|
291
|
-
const expectedProperties = normalizeObject(expected.properties);
|
|
292
|
-
if (JSON.stringify(actualProperties) !== JSON.stringify(expectedProperties)) {
|
|
293
|
-
fail('properties', actualProperties, expectedProperties);
|
|
294
|
-
}
|
|
295
|
-
const actualSegment = normalizeObject(actual.segment);
|
|
296
|
-
const expectedSegment = normalizeObject(expected.segment);
|
|
297
|
-
if (JSON.stringify(actualSegment) !== JSON.stringify(expectedSegment)) {
|
|
298
|
-
fail('segment', actualSegment, expectedSegment);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
// Instantiate and run the test
|
|
303
|
-
async function main() {
|
|
304
|
-
const test = new TMXTest();
|
|
305
|
-
try {
|
|
306
|
-
await test.runTest();
|
|
307
|
-
console.log('All done!');
|
|
308
|
-
process.exit(0);
|
|
309
|
-
}
|
|
310
|
-
catch (error) {
|
|
311
|
-
console.error('Test execution failed:', error);
|
|
312
|
-
process.exit(1);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
main();
|
|
316
|
-
//# sourceMappingURL=tmxtest.js.map
|
package/dist/ts/tmxtest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tmxtest.js","sourceRoot":"","sources":["../../ts/tmxtest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,OAAO,OAAO;IAER,MAAM,CAAU,IAAI,GAAW,UAAU,CAAC;IAC1C,MAAM,CAAU,OAAO,GAAW,gBAAgB,CAAC;IACnD,MAAM,CAAU,UAAU,GAAW,8BAA8B,CAAC;IACpE,MAAM,CAAU,cAAc,GAAW,yBAAyB,CAAC;IAE3E,KAAK,CAAC,OAAO;QACT,IAAI,CAAC;YACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,MAAM,EAAE,GAAa,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;YACzG,OAAO,CAAC,GAAG,CAAC,2CAA2C,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;YACxE,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC;iBACjC,IAAI,CAAC,GAAG,EAAE;gBACP,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;YACnD,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,CAAC,EAAE;gBACT,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;YACrD,CAAC,CAA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,MAAM,aAAa,GAA4B,eAAe,CAAC,MAAM,CAAC,OAA8C,CAAC,CAAC;QACtH,MAAM,eAAe,GAA4B,eAAe,CAAC,QAAQ,CAAC,OAA8C,CAAC,CAAC;QAC1H,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;YACpE,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;;AAGL,+BAA+B;AAC/B,KAAK,UAAU,IAAI;IACf,MAAM,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;IAC3B,IAAI,CAAC;QACD,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/ts/utils.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*******************************************************************************
|
|
2
|
-
* Copyright (c) 2025-2026 Maxprograms.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials
|
|
5
|
-
* are made available under the terms of the Eclipse License 1.0
|
|
6
|
-
* which accompanies this distribution, and is available at
|
|
7
|
-
* https://www.eclipse.org/org/documents/epl-v10.html
|
|
8
|
-
*
|
|
9
|
-
* Contributors:
|
|
10
|
-
* Maxprograms - initial API and implementation
|
|
11
|
-
*******************************************************************************/
|
|
12
|
-
import { XMLElement } from "typesxml";
|
|
13
|
-
export declare class Utils {
|
|
14
|
-
static replaceQuotes(value: string): string;
|
|
15
|
-
static getPureText(element: XMLElement): string;
|
|
16
|
-
static buildXMLElement(str: string): XMLElement;
|
|
17
|
-
}
|
package/dist/ts/utils.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*******************************************************************************
|
|
2
|
-
* Copyright (c) 2025-2026 Maxprograms.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials
|
|
5
|
-
* are made available under the terms of the Eclipse License 1.0
|
|
6
|
-
* which accompanies this distribution, and is available at
|
|
7
|
-
* https://www.eclipse.org/org/documents/epl-v10.html
|
|
8
|
-
*
|
|
9
|
-
* Contributors:
|
|
10
|
-
* Maxprograms - initial API and implementation
|
|
11
|
-
*******************************************************************************/
|
|
12
|
-
import { DOMBuilder, SAXParser, TextNode, XMLElement } from "typesxml";
|
|
13
|
-
export class Utils {
|
|
14
|
-
static replaceQuotes(value) {
|
|
15
|
-
return value.replaceAll("'", "''");
|
|
16
|
-
}
|
|
17
|
-
static getPureText(element) {
|
|
18
|
-
let text = '';
|
|
19
|
-
let content = element.getContent();
|
|
20
|
-
content.forEach((node) => {
|
|
21
|
-
if (node instanceof TextNode) {
|
|
22
|
-
text += node.getValue();
|
|
23
|
-
}
|
|
24
|
-
if (node instanceof XMLElement) {
|
|
25
|
-
const child = node;
|
|
26
|
-
if ("pc" === child.getName() || "mrk" === child.getName() || "hi" === child.getName()) {
|
|
27
|
-
text += this.getPureText(child);
|
|
28
|
-
}
|
|
29
|
-
// purposedly ignore "cp" for now
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
return text;
|
|
33
|
-
}
|
|
34
|
-
static buildXMLElement(str) {
|
|
35
|
-
const contentHandler = new DOMBuilder();
|
|
36
|
-
const xmlParser = new SAXParser();
|
|
37
|
-
xmlParser.setContentHandler(contentHandler);
|
|
38
|
-
xmlParser.parseString(str);
|
|
39
|
-
const newDoc = contentHandler.getDocument();
|
|
40
|
-
if (newDoc) {
|
|
41
|
-
const root = newDoc.getRoot();
|
|
42
|
-
if (root) {
|
|
43
|
-
return root;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
throw new Error('Error building XMLElement from string');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/ts/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../ts/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;iFAUiF;AAEjF,OAAO,EAAkB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAe,UAAU,EAAW,MAAM,UAAU,CAAC;AAE7G,MAAM,OAAO,KAAK;IAEd,MAAM,CAAC,aAAa,CAAC,KAAa;QAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,OAAmB;QAClC,IAAI,IAAI,GAAW,EAAE,CAAC;QACtB,IAAI,OAAO,GAAc,OAAO,CAAC,UAAU,EAAE,CAAC;QAC9C,OAAO,CAAC,OAAO,CAAC,CAAC,IAAa,EAAE,EAAE;YAC9B,IAAI,IAAI,YAAY,QAAQ,EAAE,CAAC;gBAC3B,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5B,CAAC;YACD,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;gBAC7B,MAAM,KAAK,GAAe,IAAI,CAAC;gBAC/B,IAAI,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,IAAI,KAAK,KAAK,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;oBACpF,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;gBACpC,CAAC;gBACD,iCAAiC;YACrC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,GAAW;QAC9B,MAAM,cAAc,GAAmB,IAAI,UAAU,EAAE,CAAC;QACxD,MAAM,SAAS,GAAc,IAAI,SAAS,EAAE,CAAC;QAC7C,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAC5C,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC3B,MAAM,MAAM,GAA6B,cAA6B,CAAC,WAAW,EAAE,CAAC;QACrF,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,IAAI,GAA2B,MAAM,CAAC,OAAO,EAAE,CAAC;YACtD,IAAI,IAAI,EAAE,CAAC;gBACP,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC7D,CAAC;CACJ"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*******************************************************************************
|
|
2
|
-
* Copyright (c) 2025-2026 Maxprograms.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials
|
|
5
|
-
* are made available under the terms of the Eclipse License 1.0
|
|
6
|
-
* which accompanies this distribution, and is available at
|
|
7
|
-
* https://www.eclipse.org/org/documents/epl-v10.html
|
|
8
|
-
*
|
|
9
|
-
* Contributors:
|
|
10
|
-
* Maxprograms - initial API and implementation
|
|
11
|
-
*******************************************************************************/
|
|
12
|
-
import { Catalog, CData, ContentHandler, Grammar, XMLAttribute, XMLElement } from "typesxml";
|
|
13
|
-
import { ImportOptions } from './importOptions.js';
|
|
14
|
-
export declare class XLIFFHandler implements ContentHandler {
|
|
15
|
-
inCdData: boolean;
|
|
16
|
-
currentCData: CData;
|
|
17
|
-
stack: Array<XMLElement>;
|
|
18
|
-
srcLang: string;
|
|
19
|
-
tgtLang: string;
|
|
20
|
-
original: string;
|
|
21
|
-
fileId: string;
|
|
22
|
-
private writeStream;
|
|
23
|
-
private readonly completionPromise;
|
|
24
|
-
private entryCount;
|
|
25
|
-
private readonly options;
|
|
26
|
-
constructor(tempFilePath: string, options?: ImportOptions);
|
|
27
|
-
setGrammar(grammar: Grammar | undefined): void;
|
|
28
|
-
getEntryCount(): number;
|
|
29
|
-
waitForCompletion(): Promise<void>;
|
|
30
|
-
initialize(): void;
|
|
31
|
-
setCatalog(catalog: Catalog): void;
|
|
32
|
-
startDocument(): void;
|
|
33
|
-
endDocument(): void;
|
|
34
|
-
xmlDeclaration(version: string, encoding: string, standalone: string | undefined): void;
|
|
35
|
-
startElement(name: string, atts: Array<XMLAttribute>): void;
|
|
36
|
-
endElement(name: string): void;
|
|
37
|
-
internalSubset(declaration: string): void;
|
|
38
|
-
characters(ch: string): void;
|
|
39
|
-
ignorableWhitespace(ch: string): void;
|
|
40
|
-
comment(ch: string): void;
|
|
41
|
-
processingInstruction(target: string, data: string): void;
|
|
42
|
-
startCDATA(): void;
|
|
43
|
-
endCDATA(): void;
|
|
44
|
-
startDTD(name: string, publicId: string, systemId: string): void;
|
|
45
|
-
endDTD(): void;
|
|
46
|
-
skippedEntity(name: string): void;
|
|
47
|
-
processUnit(unit: XMLElement): void;
|
|
48
|
-
private buildSegments;
|
|
49
|
-
private buildSegmentData;
|
|
50
|
-
private buildSingleSegment;
|
|
51
|
-
private writeSegmentEntries;
|
|
52
|
-
private applySegmentPosition;
|
|
53
|
-
private writeMergedEntry;
|
|
54
|
-
private writeEntry;
|
|
55
|
-
private hasMetadata;
|
|
56
|
-
private appendElementContent;
|
|
57
|
-
private extractMetadata;
|
|
58
|
-
private assignMetadataString;
|
|
59
|
-
private readAttribute;
|
|
60
|
-
private readSubState;
|
|
61
|
-
private collectNotes;
|
|
62
|
-
private collectMetadataProperties;
|
|
63
|
-
private getStateRank;
|
|
64
|
-
private getStateRankFromOption;
|
|
65
|
-
private isTranslationState;
|
|
66
|
-
getGrammar(): Grammar | undefined;
|
|
67
|
-
}
|