nixamp 0.24.0 → 0.24.1
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/dist/translate.d.ts +8 -0
- package/dist/translate.js +16 -1
- package/package.json +1 -1
- package/src/translate.ts +17 -1
- package/web/dist/sw.js +1 -1
package/dist/translate.d.ts
CHANGED
|
@@ -21,6 +21,14 @@ export declare const LANGUAGES: Record<string, {
|
|
|
21
21
|
name: string;
|
|
22
22
|
native: string;
|
|
23
23
|
}>;
|
|
24
|
+
/**
|
|
25
|
+
* A Marian model's line, tidied. Given a short line it tends to run on in
|
|
26
|
+
* punctuation until the token cap ("Och sånt.............."), and to put a
|
|
27
|
+
* comma and a full stop where one was meant. A space before a mark, a mark
|
|
28
|
+
* repeated, and a run of different marks each become the one mark, the
|
|
29
|
+
* first of them.
|
|
30
|
+
*/
|
|
31
|
+
export declare function tidyTranslation(text: string): string;
|
|
24
32
|
/** The models a translation from one language to another goes through, or null when there is no way. */
|
|
25
33
|
export declare function route(from: string, to: string, pairs?: ReadonlySet<string>): [string, string][] | null;
|
|
26
34
|
export declare function modelFor(from: string, to: string): string;
|
package/dist/translate.js
CHANGED
|
@@ -71,6 +71,21 @@ export const LANGUAGES = {
|
|
|
71
71
|
id: { name: "Indonesian", native: "Bahasa Indonesia" },
|
|
72
72
|
hi: { name: "Hindi", native: "हिन्दी" },
|
|
73
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* A Marian model's line, tidied. Given a short line it tends to run on in
|
|
76
|
+
* punctuation until the token cap ("Och sånt.............."), and to put a
|
|
77
|
+
* comma and a full stop where one was meant. A space before a mark, a mark
|
|
78
|
+
* repeated, and a run of different marks each become the one mark, the
|
|
79
|
+
* first of them.
|
|
80
|
+
*/
|
|
81
|
+
export function tidyTranslation(text) {
|
|
82
|
+
return text
|
|
83
|
+
.replace(/\s+([.,!?;:])/g, "$1")
|
|
84
|
+
.replace(/([.,!?;:])[.,;:]+/g, "$1")
|
|
85
|
+
.replace(/([!?])[!?]+/g, "$1")
|
|
86
|
+
.replace(/\s+/g, " ")
|
|
87
|
+
.trim();
|
|
88
|
+
}
|
|
74
89
|
/** The models a translation from one language to another goes through, or null when there is no way. */
|
|
75
90
|
export function route(from, to, pairs = PAIRS) {
|
|
76
91
|
if (from === to)
|
|
@@ -226,7 +241,7 @@ export class Translator {
|
|
|
226
241
|
}
|
|
227
242
|
const out = [...spoken];
|
|
228
243
|
which.forEach((i, at) => {
|
|
229
|
-
out[i] = (current[at] ?? "")
|
|
244
|
+
out[i] = tidyTranslation(current[at] ?? "");
|
|
230
245
|
});
|
|
231
246
|
return out;
|
|
232
247
|
});
|
package/package.json
CHANGED
package/src/translate.ts
CHANGED
|
@@ -75,6 +75,22 @@ export const LANGUAGES: Record<string, { name: string; native: string }> = {
|
|
|
75
75
|
hi: { name: "Hindi", native: "हिन्दी" },
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* A Marian model's line, tidied. Given a short line it tends to run on in
|
|
80
|
+
* punctuation until the token cap ("Och sånt.............."), and to put a
|
|
81
|
+
* comma and a full stop where one was meant. A space before a mark, a mark
|
|
82
|
+
* repeated, and a run of different marks each become the one mark, the
|
|
83
|
+
* first of them.
|
|
84
|
+
*/
|
|
85
|
+
export function tidyTranslation(text: string): string {
|
|
86
|
+
return text
|
|
87
|
+
.replace(/\s+([.,!?;:])/g, "$1")
|
|
88
|
+
.replace(/([.,!?;:])[.,;:]+/g, "$1")
|
|
89
|
+
.replace(/([!?])[!?]+/g, "$1")
|
|
90
|
+
.replace(/\s+/g, " ")
|
|
91
|
+
.trim();
|
|
92
|
+
}
|
|
93
|
+
|
|
78
94
|
/** The models a translation from one language to another goes through, or null when there is no way. */
|
|
79
95
|
export function route(from: string, to: string, pairs: ReadonlySet<string> = PAIRS): [string, string][] | null {
|
|
80
96
|
if (from === to) return [];
|
|
@@ -262,7 +278,7 @@ export class Translator {
|
|
|
262
278
|
}
|
|
263
279
|
const out = [...spoken];
|
|
264
280
|
which.forEach((i, at) => {
|
|
265
|
-
out[i] = (current[at] ?? "")
|
|
281
|
+
out[i] = tidyTranslation(current[at] ?? "");
|
|
266
282
|
});
|
|
267
283
|
return out;
|
|
268
284
|
});
|
package/web/dist/sw.js
CHANGED