garu-ko 0.5.1 → 0.5.3
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/index.js
CHANGED
|
@@ -63,34 +63,27 @@ export class Garu {
|
|
|
63
63
|
}
|
|
64
64
|
modelBytes = new Uint8Array(await response.arrayBuffer());
|
|
65
65
|
}
|
|
66
|
-
// Construct the WASM analyzer
|
|
67
|
-
const wasmInstance = new wasmModule.GaruWasm(modelBytes);
|
|
68
66
|
// Load CNN reranker
|
|
69
|
-
let cnnBytes
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
cnnBytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
const cnnUrl = new URL('../models/cnn2.bin', import.meta.url).href;
|
|
81
|
-
const cnnResp = await fetch(cnnUrl);
|
|
82
|
-
if (cnnResp.ok) {
|
|
83
|
-
cnnBytes = new Uint8Array(await cnnResp.arrayBuffer());
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
// CNN loading is best-effort
|
|
67
|
+
let cnnBytes;
|
|
68
|
+
if (isNode) {
|
|
69
|
+
const { readFile } = await import('fs/promises');
|
|
70
|
+
const { fileURLToPath } = await import('url');
|
|
71
|
+
const { join, dirname } = await import('path');
|
|
72
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
73
|
+
const buf = await readFile(join(dir, '..', 'models', 'cnn2.bin'));
|
|
74
|
+
cnnBytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
89
75
|
}
|
|
90
|
-
|
|
91
|
-
|
|
76
|
+
else {
|
|
77
|
+
const cnnUrl = new URL('../models/cnn2.bin', import.meta.url).href;
|
|
78
|
+
const cnnResp = await fetch(cnnUrl);
|
|
79
|
+
if (!cnnResp.ok) {
|
|
80
|
+
throw new Error(`Failed to fetch CNN model from ${cnnUrl}: ${cnnResp.status}`);
|
|
81
|
+
}
|
|
82
|
+
cnnBytes = new Uint8Array(await cnnResp.arrayBuffer());
|
|
92
83
|
}
|
|
93
|
-
|
|
84
|
+
// Construct the WASM analyzer with both models
|
|
85
|
+
const wasmInstance = new wasmModule.GaruWasm(modelBytes, cnnBytes);
|
|
86
|
+
return new Garu(wasmInstance, modelBytes.byteLength + cnnBytes.byteLength);
|
|
94
87
|
}
|
|
95
88
|
/**
|
|
96
89
|
* Analyze Korean text, returning morphological tokens with scores.
|
package/package.json
CHANGED
package/pkg/garu_wasm.js
CHANGED
|
@@ -85,7 +85,7 @@ export class GaruWasm {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
if (Symbol.dispose) GaruWasm.prototype[Symbol.dispose] = GaruWasm.prototype.free;
|
|
88
|
-
import * as import1 from "./snippets/garu-core-
|
|
88
|
+
import * as import1 from "./snippets/garu-core-deda0dfbf85b90ef/inline0.js"
|
|
89
89
|
|
|
90
90
|
function __wbg_get_imports() {
|
|
91
91
|
const import0 = {
|
|
@@ -146,7 +146,7 @@ function __wbg_get_imports() {
|
|
|
146
146
|
return {
|
|
147
147
|
__proto__: null,
|
|
148
148
|
"./garu_wasm_bg.js": import0,
|
|
149
|
-
"./snippets/garu-core-
|
|
149
|
+
"./snippets/garu-core-deda0dfbf85b90ef/inline0.js": import1,
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
|
package/pkg/garu_wasm_bg.wasm
CHANGED
|
Binary file
|
package/pkg/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function performance_now() { return performance.now(); }
|
package/models/cnn2.bin.gz
DELETED
|
Binary file
|