hybridtm 0.3.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.
Files changed (107) hide show
  1. package/dist/{ts/tmxHandler.d.ts → tmxHandler.d.ts} +1 -0
  2. package/dist/{ts/tmxHandler.js → tmxHandler.js} +10 -0
  3. package/dist/{tmxhandler.js.map → tmxHandler.js.map} +1 -1
  4. package/dist/{ts/xliffHandler.d.ts → xliffHandler.d.ts} +1 -0
  5. package/dist/{ts/xliffHandler.js → xliffHandler.js} +10 -0
  6. package/dist/{xliffhandler.js.map → xliffHandler.js.map} +1 -1
  7. package/package.json +14 -9
  8. package/dist/batchimporter.d.ts +0 -22
  9. package/dist/batchimporter.js +0 -203
  10. package/dist/constants.d.ts +0 -15
  11. package/dist/constants.js +0 -16
  12. package/dist/constants.js.map +0 -1
  13. package/dist/debug-progress.d.ts +0 -12
  14. package/dist/debug-progress.js +0 -49
  15. package/dist/debug-progress.js.map +0 -1
  16. package/dist/ngramIndex.d.ts +0 -31
  17. package/dist/ngramIndex.js +0 -132
  18. package/dist/ngramIndex.js.map +0 -1
  19. package/dist/ngrams.d.ts +0 -21
  20. package/dist/ngrams.js +0 -73
  21. package/dist/ngrams.js.map +0 -1
  22. package/dist/package.json +0 -35
  23. package/dist/progressProvider.d.ts +0 -17
  24. package/dist/progressProvider.js +0 -14
  25. package/dist/progressProvider.js.map +0 -1
  26. package/dist/simplexlifftest.d.ts +0 -1
  27. package/dist/simplexlifftest.js +0 -23
  28. package/dist/simplexlifftest.js.map +0 -1
  29. package/dist/test-import.d.ts +0 -12
  30. package/dist/test-import.js +0 -101
  31. package/dist/test-import.js.map +0 -1
  32. package/dist/test-progress-fix.d.ts +0 -1
  33. package/dist/test-progress-fix.js +0 -32
  34. package/dist/test-progress-fix.js.map +0 -1
  35. package/dist/test-progress.d.ts +0 -12
  36. package/dist/test-progress.js +0 -32
  37. package/dist/test-progress.js.map +0 -1
  38. package/dist/tests/vectorSimilarityComparison.d.ts +0 -12
  39. package/dist/tests/vectorSimilarityComparison.js +0 -153
  40. package/dist/tests/vectorSimilarityComparison.js.map +0 -1
  41. package/dist/tmxhandler.d.ts +0 -61
  42. package/dist/tmxhandler.js +0 -347
  43. package/dist/tmxreader.d.ts +0 -25
  44. package/dist/tmxreader.js +0 -51
  45. package/dist/tmxtest.d.ts +0 -16
  46. package/dist/tmxtest.js +0 -316
  47. package/dist/tmxtest.js.map +0 -1
  48. package/dist/ts/batchImporter.js.map +0 -1
  49. package/dist/ts/hybridtm.d.ts +0 -67
  50. package/dist/ts/hybridtm.js +0 -932
  51. package/dist/ts/hybridtm.js.map +0 -1
  52. package/dist/ts/hybridtmFactory.d.ts +0 -43
  53. package/dist/ts/hybridtmFactory.js +0 -165
  54. package/dist/ts/hybridtmFactory.js.map +0 -1
  55. package/dist/ts/importOptions.d.ts +0 -21
  56. package/dist/ts/importOptions.js +0 -24
  57. package/dist/ts/importOptions.js.map +0 -1
  58. package/dist/ts/index.d.ts +0 -25
  59. package/dist/ts/index.js +0 -22
  60. package/dist/ts/index.js.map +0 -1
  61. package/dist/ts/langEntry.d.ts +0 -64
  62. package/dist/ts/langEntry.js +0 -13
  63. package/dist/ts/langEntry.js.map +0 -1
  64. package/dist/ts/match.d.ts +0 -22
  65. package/dist/ts/match.js +0 -38
  66. package/dist/ts/match.js.map +0 -1
  67. package/dist/ts/matchQuality.d.ts +0 -16
  68. package/dist/ts/matchQuality.js +0 -83
  69. package/dist/ts/matchQuality.js.map +0 -1
  70. package/dist/ts/pendingEntry.d.ts +0 -24
  71. package/dist/ts/pendingEntry.js +0 -13
  72. package/dist/ts/pendingEntry.js.map +0 -1
  73. package/dist/ts/searchFilters.d.ts +0 -24
  74. package/dist/ts/searchFilters.js +0 -13
  75. package/dist/ts/searchFilters.js.map +0 -1
  76. package/dist/ts/tmxHandler.js.map +0 -1
  77. package/dist/ts/tmxReader.js.map +0 -1
  78. package/dist/ts/tmxtest.d.ts +0 -16
  79. package/dist/ts/tmxtest.js +0 -316
  80. package/dist/ts/tmxtest.js.map +0 -1
  81. package/dist/ts/utils.d.ts +0 -17
  82. package/dist/ts/utils.js +0 -49
  83. package/dist/ts/utils.js.map +0 -1
  84. package/dist/ts/xliffHandler.js.map +0 -1
  85. package/dist/ts/xliffReader.js.map +0 -1
  86. package/dist/ts/xlifftest.d.ts +0 -54
  87. package/dist/ts/xlifftest.js +0 -245
  88. package/dist/ts/xlifftest.js.map +0 -1
  89. package/dist/vectorSimilarityTester.d.ts +0 -56
  90. package/dist/vectorSimilarityTester.js +0 -164
  91. package/dist/vectorSimilarityTester.js.map +0 -1
  92. package/dist/xliffhandler.d.ts +0 -67
  93. package/dist/xliffhandler.js +0 -522
  94. package/dist/xliffreader.d.ts +0 -25
  95. package/dist/xliffreader.js +0 -50
  96. package/dist/xlifftest.d.ts +0 -54
  97. package/dist/xlifftest.js +0 -245
  98. package/dist/xlifftest.js.map +0 -1
  99. /package/dist/{ts/batchImporter.d.ts → batchImporter.d.ts} +0 -0
  100. /package/dist/{ts/batchImporter.js → batchImporter.js} +0 -0
  101. /package/dist/{batchimporter.js.map → batchImporter.js.map} +0 -0
  102. /package/dist/{ts/tmxReader.d.ts → tmxReader.d.ts} +0 -0
  103. /package/dist/{ts/tmxReader.js → tmxReader.js} +0 -0
  104. /package/dist/{tmxreader.js.map → tmxReader.js.map} +0 -0
  105. /package/dist/{ts/xliffReader.d.ts → xliffReader.d.ts} +0 -0
  106. /package/dist/{ts/xliffReader.js → xliffReader.js} +0 -0
  107. /package/dist/{xliffreader.js.map → xliffReader.js.map} +0 -0
@@ -1,54 +0,0 @@
1
- export declare class XLIFFTest {
2
- private static readonly NAME;
3
- private static readonly DB_PATH;
4
- private static readonly SAMPLE_XLIFF;
5
- runTest(): Promise<void>;
6
- private resetEnvironment;
7
- private verifyEntry;
8
- private expectTranslationMatch;
9
- private expectConcordanceMatch;
10
- private verifyMetadataRoundtrip;
11
- private assertMetadataEquals;
12
- }
13
- /*******************************************************************************
14
-
15
- Follow the steps to create a translation project from your DITA map
16
-
17
- I need to edit the name or description of a translation memory
18
-
19
- How do I add more target languages to my project?
20
-
21
- What should I do after updating my DITA content?
22
-
23
- Export a memory as a TMX file to save the translation data
24
-
25
- Associate existing memories with the new project to reuse translations
26
-
27
- I want to permanently remove a project from the system
28
-
29
- Select a name and location for the TMX file containing memory data
30
-
31
- Import a TMX file into a memory from the command line
32
-
33
- Fluenta recovers exact matches from translations stored in the previous cycle
34
-
35
- You don't need to pay again for translation of content that didn't change
36
-
37
- A company specialized in providing translation and localization services
38
-
39
- Before using the Command Line Interface you must start Fluenta from the GUI at least once
40
-
41
- Create a JSON file containing the data required for creating the memory
42
-
43
- An XLIFF file is generated for each selected target language
44
-
45
- Check your email and register the evaluation key using the instructions
46
-
47
- Additional configurations can be added by the user as required
48
-
49
- Use the buttons in the dialog to update the configuration file
50
-
51
- The configuration file is automatically updated as you add or remove elements
52
-
53
- Avoid using folders that could be modified by other programs while you work
54
- */
@@ -1,245 +0,0 @@
1
- import { rmSync } from 'node:fs';
2
- import { HybridTM } from './hybridtm.js';
3
- import { HybridTMFactory } from './hybridtmFactory.js';
4
- import { Utils } from './utils.js';
5
- export class XLIFFTest {
6
- static NAME = 'XLIFF Test';
7
- static DB_PATH = 'my-xliff.lancedb';
8
- static SAMPLE_XLIFF = './samples/fluenta_es.ditamap.xlf';
9
- async runTest() {
10
- try {
11
- this.resetEnvironment();
12
- const tm = HybridTMFactory.createInstance(XLIFFTest.NAME, XLIFFTest.DB_PATH, HybridTM.SPEED_MODEL);
13
- console.log('Created new HybridTM instance with name: ' + XLIFFTest.NAME);
14
- await tm.importXLIFF(XLIFFTest.SAMPLE_XLIFF)
15
- .then(() => {
16
- console.log('XLIFF file imported successfully.');
17
- })
18
- .catch(err => {
19
- console.error('Failed to import XLIFF file:', err);
20
- });
21
- await this.verifyEntry(tm, '45', '4', 'en', 1, 1);
22
- await this.verifyEntry(tm, '45', '4', 'es', 1, 1);
23
- 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.', 'exact match');
24
- 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.', 'fuzzy paraphrase');
25
- 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ó.', 'semantic reuse reminder');
26
- 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.', 'concordance reuse unit');
27
- await this.verifyMetadataRoundtrip(tm);
28
- /*
29
- const array: Map<string, XMLElement>[] = await tm.concordanceSearch('XLIFF file', 'en', 5);
30
- console.log('Concordance search results:' + array.length + ' entries found.');
31
- for (const map of array) {
32
- for (const [lang, element] of map) {
33
- console.log('Language: ' + lang + '\nElement: ' + element.toString());
34
- }
35
- console.log('-------------------------\n');
36
- }
37
- */
38
- await tm.close();
39
- }
40
- catch (err) {
41
- console.error('Error stack:', err instanceof Error ? err.stack : String(err));
42
- throw err;
43
- }
44
- }
45
- resetEnvironment() {
46
- try {
47
- HybridTMFactory.removeInstance(XLIFFTest.NAME);
48
- }
49
- catch (err) {
50
- // ignore missing instance
51
- }
52
- try {
53
- rmSync(XLIFFTest.DB_PATH, { recursive: true, force: true });
54
- }
55
- catch (err) {
56
- // ignore file system cleanup issues
57
- }
58
- }
59
- async verifyEntry(tm, fileId, unitId, lang, segmentIndex, segmentCount) {
60
- const entry = await tm.getLangEntry(fileId, unitId, lang, segmentIndex);
61
- if (!entry) {
62
- throw new Error('Entry not found for ' + fileId + ':' + unitId + ':' + segmentIndex + ':' + lang);
63
- }
64
- if (entry.id !== fileId + ':' + unitId + ':' + segmentIndex + ':' + lang) {
65
- throw new Error('Unexpected entry id ' + entry.id);
66
- }
67
- if (entry.segmentIndex !== segmentIndex) {
68
- throw new Error('Segment index mismatch for ' + entry.id);
69
- }
70
- if (entry.segmentCount !== segmentCount) {
71
- throw new Error('Segment count mismatch for ' + entry.id);
72
- }
73
- if (!entry.metadata) {
74
- throw new Error('Metadata missing for ' + entry.id);
75
- }
76
- if (!entry.vector || entry.vector.length === 0) {
77
- throw new Error('Vector missing for ' + entry.id);
78
- }
79
- console.log('Verified entry ' + entry.id + ' with vector size ' + entry.vector.length);
80
- }
81
- async expectTranslationMatch(tm, query, srcLang, tgtLang, similarity, expectedSourceSnippet, expectedTargetSnippet, label) {
82
- const matches = await tm.semanticTranslationSearch(query, srcLang, tgtLang, similarity);
83
- if (matches.length === 0) {
84
- throw new Error('No matches found for "' + label + '" query.');
85
- }
86
- const best = matches[0];
87
- const sourceXml = best.source.toString();
88
- const targetXml = best.target.toString();
89
- if (!sourceXml.includes(expectedSourceSnippet)) {
90
- throw new Error('Unexpected source match for "' + label + '": ' + sourceXml);
91
- }
92
- if (!targetXml.includes(expectedTargetSnippet)) {
93
- throw new Error('Unexpected target match for "' + label + '": ' + targetXml);
94
- }
95
- console.log('[' + label + '] matches=' + matches.length + ' semantic=' + best.semantic + ' fuzzy=' + best.fuzzy + ' hybrid=' + best.hybridScore());
96
- }
97
- async expectConcordanceMatch(tm, fragment, srcLang, tgtLang, expectedSourceSnippet, expectedTargetSnippet, label) {
98
- const results = await tm.concordanceSearch(fragment, srcLang, 5);
99
- if (results.length === 0) {
100
- throw new Error('No concordance matches found for "' + label + '" fragment.');
101
- }
102
- const best = results[0];
103
- const sourceElement = best.get(srcLang);
104
- const targetElement = best.get(tgtLang);
105
- if (!sourceElement || !sourceElement.toString().includes(expectedSourceSnippet)) {
106
- throw new Error('Unexpected concordance source for "' + label + '".');
107
- }
108
- if (!targetElement || !targetElement.toString().includes(expectedTargetSnippet)) {
109
- throw new Error('Unexpected concordance target for "' + label + '".');
110
- }
111
- console.log('[' + label + '] concordance languages=' + Array.from(best.keys()).join(', '));
112
- }
113
- async verifyMetadataRoundtrip(tm) {
114
- const fileId = 'xliff-metadata-roundtrip.xlf';
115
- const unitId = 'XLIFF-ROUNDTRIP-1';
116
- const lang = 'es';
117
- const segmentIndex = 1;
118
- const metadata = {
119
- state: 'reviewed',
120
- quality: 88,
121
- creationDate: '2024-11-05T09:15:00Z',
122
- changeDate: '2024-12-20T17:45:00Z',
123
- creationTool: 'XLIFF Test Harness',
124
- creationToolVersion: '1.2.3',
125
- context: 'XLIFF metadata context',
126
- properties: {
127
- release: 'Winter',
128
- locale: 'es-ES'
129
- },
130
- segment: {
131
- provider: 'xliff-roundtrip',
132
- fileHash: 'hash-xliff-001',
133
- fileId: 'roundtrip-file',
134
- unitId,
135
- segmentId: '1',
136
- segmentIndex,
137
- segmentCount: 1,
138
- segmentKey: unitId + '-1'
139
- }
140
- };
141
- const entryElement = '<seg>XLIFF metadata roundtrip target</seg>';
142
- await tm.storeLangEntry(fileId, entryElement, unitId, lang, 'XLIFF metadata roundtrip target', Utils.buildXMLElement(entryElement), undefined, segmentIndex, 1, metadata);
143
- const fetched = await tm.getLangEntry(fileId, unitId, lang, segmentIndex);
144
- if (!fetched) {
145
- throw new Error('XLIFF metadata roundtrip entry missing for ' + unitId);
146
- }
147
- this.assertMetadataEquals(fetched.metadata, metadata);
148
- console.log('[XLIFF metadata roundtrip] state=' + fetched.metadata.state + ' quality=' + fetched.metadata.quality + ' properties=' + JSON.stringify(fetched.metadata.properties));
149
- }
150
- assertMetadataEquals(actual, expected) {
151
- const fail = (field, actualValue, expectedValue) => {
152
- throw new Error('XLIFF metadata roundtrip mismatch for ' + field + ': expected ' + JSON.stringify(expectedValue) + ' but received ' + JSON.stringify(actualValue));
153
- };
154
- const scalarFields = [
155
- 'state',
156
- 'quality',
157
- 'creationDate',
158
- 'changeDate',
159
- 'creationTool',
160
- 'creationToolVersion',
161
- 'context'
162
- ];
163
- scalarFields.forEach((field) => {
164
- if ((actual[field] ?? null) !== (expected[field] ?? null)) {
165
- fail(field, actual[field], expected[field]);
166
- }
167
- });
168
- const normalizeObject = (value) => {
169
- if (!value) {
170
- return {};
171
- }
172
- const sortedKeys = Object.keys(value).sort();
173
- return sortedKeys.reduce((acc, key) => {
174
- acc[key] = value[key];
175
- return acc;
176
- }, {});
177
- };
178
- const actualProperties = normalizeObject(actual.properties);
179
- const expectedProperties = normalizeObject(expected.properties);
180
- if (JSON.stringify(actualProperties) !== JSON.stringify(expectedProperties)) {
181
- fail('properties', actualProperties, expectedProperties);
182
- }
183
- const actualSegment = normalizeObject(actual.segment);
184
- const expectedSegment = normalizeObject(expected.segment);
185
- if (JSON.stringify(actualSegment) !== JSON.stringify(expectedSegment)) {
186
- fail('segment', actualSegment, expectedSegment);
187
- }
188
- }
189
- }
190
- async function main() {
191
- const test = new XLIFFTest();
192
- try {
193
- await test.runTest();
194
- console.log('All done!');
195
- process.exit(0);
196
- }
197
- catch (error) {
198
- console.error('Test execution failed:', error);
199
- process.exit(1);
200
- }
201
- }
202
- main();
203
- /*******************************************************************************
204
-
205
- Follow the steps to create a translation project from your DITA map
206
-
207
- I need to edit the name or description of a translation memory
208
-
209
- How do I add more target languages to my project?
210
-
211
- What should I do after updating my DITA content?
212
-
213
- Export a memory as a TMX file to save the translation data
214
-
215
- Associate existing memories with the new project to reuse translations
216
-
217
- I want to permanently remove a project from the system
218
-
219
- Select a name and location for the TMX file containing memory data
220
-
221
- Import a TMX file into a memory from the command line
222
-
223
- Fluenta recovers exact matches from translations stored in the previous cycle
224
-
225
- You don't need to pay again for translation of content that didn't change
226
-
227
- A company specialized in providing translation and localization services
228
-
229
- Before using the Command Line Interface you must start Fluenta from the GUI at least once
230
-
231
- Create a JSON file containing the data required for creating the memory
232
-
233
- An XLIFF file is generated for each selected target language
234
-
235
- Check your email and register the evaluation key using the instructions
236
-
237
- Additional configurations can be added by the user as required
238
-
239
- Use the buttons in the dialog to update the configuration file
240
-
241
- The configuration file is automatically updated as you add or remove elements
242
-
243
- Avoid using folders that could be modified by other programs while you work
244
- */
245
- //# sourceMappingURL=xlifftest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xlifftest.js","sourceRoot":"","sources":["../../ts/xlifftest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,MAAM,OAAO,SAAS;IAEV,MAAM,CAAU,IAAI,GAAW,YAAY,CAAC;IAC5C,MAAM,CAAU,OAAO,GAAW,kBAAkB,CAAC;IACrD,MAAM,CAAU,YAAY,GAAW,kCAAkC,CAAC;IAElF,KAAK,CAAC,OAAO;QACT,IAAI,CAAC;YACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,MAAM,EAAE,GAAa,eAAe,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC7G,OAAO,CAAC,GAAG,CAAC,2CAA2C,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YAC1E,MAAM,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC;iBACvC,IAAI,CAAC,GAAG,EAAE;gBACP,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;YACrD,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,CAAC,EAAE;gBACT,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;YACvD,CAAC,CAAC,CAAC;YAEP,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI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ACb,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;AAIP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCE"}
@@ -1,56 +0,0 @@
1
- /*******************************************************************************
2
- * Copyright (c) 2025 Maxprograms.
3
- *
4
- * This program and the accompanying materials
5
- * are made available under the terms of the Eclipse Public 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
- export interface VectorComparisonInput {
13
- label?: string;
14
- sourceVector: number[];
15
- targetVector: number[];
16
- }
17
- export interface TextComparisonInput {
18
- label?: string;
19
- sourceText: string;
20
- targetText: string;
21
- }
22
- export interface VectorComparisonResult {
23
- label?: string;
24
- manhattanScore: number;
25
- cosineScore: number;
26
- cosineMinusManhattan: number;
27
- absoluteDifference: number;
28
- manhattanPercent: number;
29
- cosinePercent: number;
30
- }
31
- export interface TextComparisonResult extends VectorComparisonResult {
32
- sourceText: string;
33
- targetText: string;
34
- }
35
- export interface ComparisonSummary {
36
- averageManhattan: number;
37
- averageCosine: number;
38
- averageAbsoluteDifference: number;
39
- maxAbsoluteDifference: number;
40
- minAbsoluteDifference: number;
41
- }
42
- export declare class VectorSimilarityTester {
43
- static readonly DEFAULT_MODEL: string;
44
- private embedder;
45
- private readonly modelName;
46
- constructor(modelName?: string);
47
- private static manhattanSimilarity;
48
- private static cosineSimilarity;
49
- private static buildResult;
50
- private ensureEmbedder;
51
- private embed;
52
- static compareVectors(input: VectorComparisonInput): VectorComparisonResult;
53
- compareTexts(inputs: TextComparisonInput[]): Promise<TextComparisonResult[]>;
54
- static summarize(results: VectorComparisonResult[]): ComparisonSummary;
55
- static formatResults(results: VectorComparisonResult[]): string;
56
- }
@@ -1,164 +0,0 @@
1
- "use strict";
2
- /*******************************************************************************
3
- * Copyright (c) 2025 Maxprograms.
4
- *
5
- * This program and the accompanying materials
6
- * are made available under the terms of the Eclipse Public License 1.0
7
- * which accompanies this distribution, and is available at
8
- * https://www.eclipse.org/org/documents/epl-v10.html
9
- *
10
- * Contributors:
11
- * Maxprograms - initial API and implementation
12
- *******************************************************************************/
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.VectorSimilarityTester = void 0;
15
- const transformers_1 = require("@xenova/transformers");
16
- class VectorSimilarityTester {
17
- static DEFAULT_MODEL = 'Xenova/LaBSE';
18
- embedder = null;
19
- modelName;
20
- constructor(modelName = VectorSimilarityTester.DEFAULT_MODEL) {
21
- this.modelName = modelName;
22
- }
23
- static manhattanSimilarity(vecA, vecB) {
24
- if (vecA.length !== vecB.length) {
25
- throw new Error('Vectors must have the same length');
26
- }
27
- let sumAbsDiff = 0;
28
- for (let i = 0; i < vecA.length; i++) {
29
- sumAbsDiff += Math.abs(vecA[i] - vecB[i]);
30
- }
31
- return Math.exp(-sumAbsDiff / vecA.length);
32
- }
33
- static cosineSimilarity(vecA, vecB) {
34
- if (vecA.length !== vecB.length) {
35
- throw new Error('Vectors must have the same length');
36
- }
37
- let dotProduct = 0;
38
- let normA = 0;
39
- let normB = 0;
40
- for (let i = 0; i < vecA.length; i++) {
41
- const a = vecA[i];
42
- const b = vecB[i];
43
- dotProduct += a * b;
44
- normA += a * a;
45
- normB += b * b;
46
- }
47
- if (normA === 0 || normB === 0) {
48
- return 0;
49
- }
50
- return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
51
- }
52
- static buildResult(label, manhattanScore, cosineScore) {
53
- const cosineMinusManhattan = cosineScore - manhattanScore;
54
- const absoluteDifference = Math.abs(cosineMinusManhattan);
55
- return {
56
- label,
57
- manhattanScore,
58
- cosineScore,
59
- cosineMinusManhattan,
60
- absoluteDifference,
61
- manhattanPercent: Math.round(manhattanScore * 100),
62
- cosinePercent: Math.round(cosineScore * 100)
63
- };
64
- }
65
- async ensureEmbedder() {
66
- if (this.embedder) {
67
- return;
68
- }
69
- this.embedder = await (0, transformers_1.pipeline)('feature-extraction', this.modelName);
70
- }
71
- async embed(text) {
72
- await this.ensureEmbedder();
73
- if (!this.embedder) {
74
- throw new Error('Failed to initialize embedder');
75
- }
76
- const result = await this.embedder(text, {
77
- pooling: 'mean',
78
- normalize: true
79
- });
80
- return Array.from(result.data);
81
- }
82
- static compareVectors(input) {
83
- const manhattanScore = VectorSimilarityTester.manhattanSimilarity(input.sourceVector, input.targetVector);
84
- const cosineScore = VectorSimilarityTester.cosineSimilarity(input.sourceVector, input.targetVector);
85
- return VectorSimilarityTester.buildResult(input.label, manhattanScore, cosineScore);
86
- }
87
- async compareTexts(inputs) {
88
- if (inputs.length === 0) {
89
- return [];
90
- }
91
- const cache = new Map();
92
- const getEmbedding = async (text) => {
93
- const normalized = text || '';
94
- const cached = cache.get(normalized);
95
- if (cached) {
96
- return cached;
97
- }
98
- const embedding = await this.embed(normalized);
99
- cache.set(normalized, embedding);
100
- return embedding;
101
- };
102
- const results = [];
103
- for (const input of inputs) {
104
- const sourceEmbedding = await getEmbedding(input.sourceText);
105
- const targetEmbedding = await getEmbedding(input.targetText);
106
- const comparison = VectorSimilarityTester.buildResult(input.label, VectorSimilarityTester.manhattanSimilarity(sourceEmbedding, targetEmbedding), VectorSimilarityTester.cosineSimilarity(sourceEmbedding, targetEmbedding));
107
- results.push({
108
- ...comparison,
109
- sourceText: input.sourceText,
110
- targetText: input.targetText
111
- });
112
- }
113
- return results;
114
- }
115
- static summarize(results) {
116
- if (results.length === 0) {
117
- return {
118
- averageManhattan: 0,
119
- averageCosine: 0,
120
- averageAbsoluteDifference: 0,
121
- maxAbsoluteDifference: 0,
122
- minAbsoluteDifference: 0
123
- };
124
- }
125
- let sumManhattan = 0;
126
- let sumCosine = 0;
127
- let sumAbs = 0;
128
- let maxAbs = Number.NEGATIVE_INFINITY;
129
- let minAbs = Number.POSITIVE_INFINITY;
130
- for (const result of results) {
131
- sumManhattan += result.manhattanScore;
132
- sumCosine += result.cosineScore;
133
- sumAbs += result.absoluteDifference;
134
- if (result.absoluteDifference > maxAbs) {
135
- maxAbs = result.absoluteDifference;
136
- }
137
- if (result.absoluteDifference < minAbs) {
138
- minAbs = result.absoluteDifference;
139
- }
140
- }
141
- return {
142
- averageManhattan: sumManhattan / results.length,
143
- averageCosine: sumCosine / results.length,
144
- averageAbsoluteDifference: sumAbs / results.length,
145
- maxAbsoluteDifference: maxAbs,
146
- minAbsoluteDifference: minAbs
147
- };
148
- }
149
- static formatResults(results) {
150
- if (results.length === 0) {
151
- return 'No comparison data available.';
152
- }
153
- const lines = results.map(function (result, index) {
154
- const label = result.label || 'pair-' + (index + 1);
155
- const manhattanPercent = result.manhattanPercent.toString().padStart(3, ' ');
156
- const cosinePercent = result.cosinePercent.toString().padStart(3, ' ');
157
- const delta = result.cosineMinusManhattan.toFixed(4);
158
- return label + ': manhattan=' + manhattanPercent + '% cosine=' + cosinePercent + '% delta=' + delta;
159
- });
160
- return lines.join('\n');
161
- }
162
- }
163
- exports.VectorSimilarityTester = VectorSimilarityTester;
164
- //# sourceMappingURL=vectorSimilarityTester.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vectorSimilarityTester.js","sourceRoot":"","sources":["../ts/vectorSimilarityTester.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;iFAUiF;;;AAEjF,uDAAmF;AAqCnF,MAAa,sBAAsB;IAE/B,MAAM,CAAU,aAAa,GAAW,cAAc,CAAC;IAE/C,QAAQ,GAAqC,IAAI,CAAC;IACzC,SAAS,CAAS;IAEnC,YAAY,YAAoB,sBAAsB,CAAC,aAAa;QAChE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAEO,MAAM,CAAC,mBAAmB,CAAC,IAAc,EAAE,IAAc;QAC7D,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAA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CAAC,MAAM;YAClD,qBAAqB,EAAE,MAAM;YAC7B,qBAAqB,EAAE,MAAM;SAChC,CAAC;IACN,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,OAAiC;QACzD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,+BAA+B,CAAC;QAC3C,CAAC;QAED,MAAM,KAAK,GAAa,OAAO,CAAC,GAAG,CAAC,UAAS,MAA8B,EAAE,KAAa;YACtF,MAAM,KAAK,GAAW,MAAM,CAAC,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAC5D,MAAM,gBAAgB,GAAW,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACrF,MAAM,aAAa,GAAW,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YAC/E,MAAM,KAAK,GAAW,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC7D,OAAO,KAAK,GAAG,cAAc,GAAG,gBAAgB,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,GAAG,KAAK,CAAC;QACxG,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;;AAjLL,wDAkLC"}
@@ -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
- }