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.
@@ -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] ?? "").trim();
244
+ out[i] = tidyTranslation(current[at] ?? "");
230
245
  });
231
246
  return out;
232
247
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nixamp",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "description": "It really whips the terminal's ass. A Winamp-shaped audio player for your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
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] ?? "").trim();
281
+ out[i] = tidyTranslation(current[at] ?? "");
266
282
  });
267
283
  return out;
268
284
  });
package/web/dist/sw.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* nixamp service worker — generated, do not edit */
2
- const CACHE = "nixamp-1789290815965";
2
+ const CACHE = "nixamp-1789291692037";
3
3
  const PRECACHE = [
4
4
  "/",
5
5
  "/.well-known/openaccess.json",