garu-ko 0.1.5 → 0.2.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Browser-native Korean morphological analyzer.** No server required.
4
4
 
5
- - **2.2MB model** bundled in npm package (no CDN needed)
5
+ - **1.7MB model** bundled in npm package (no CDN needed)
6
6
  - **93KB WASM** engine -- runs in any modern browser
7
7
  - **F1 95.3%** on NIKL MP benchmark (vs. Kiwi 87.9%)
8
8
  - **< 1ms** inference per sentence
@@ -12,7 +12,7 @@
12
12
 
13
13
  | | Kiwi | MeCab-ko | garu-ko |
14
14
  |---|---|---|---|
15
- | Model size | ~40MB | ~50MB | **2.2MB** |
15
+ | Model size | ~40MB | ~50MB | **1.7MB** |
16
16
  | npm package | No | No | **Yes** |
17
17
  | F1 (NIKL MP) | 87.9% | ~85% | **95.3%** |
18
18
  | Browser support | Impractical | No | **Yes** |
package/dist/index.js CHANGED
@@ -23,7 +23,17 @@ export class Garu {
23
23
  // Dynamic import of the WASM glue module and initialise it
24
24
  // @ts-ignore dynamic WASM import
25
25
  const wasmModule = await import('../pkg/garu_wasm.js');
26
- await wasmModule.default();
26
+ if (isNode) {
27
+ const { readFile } = await import('fs/promises');
28
+ const { fileURLToPath } = await import('url');
29
+ const { join, dirname } = await import('path');
30
+ const dir = dirname(fileURLToPath(import.meta.url));
31
+ const wasmBytes = await readFile(join(dir, '..', 'pkg', 'garu_wasm_bg.wasm'));
32
+ await wasmModule.default(wasmBytes);
33
+ }
34
+ else {
35
+ await wasmModule.default();
36
+ }
27
37
  // Resolve model bytes
28
38
  let modelBytes;
29
39
  if (options?.modelData) {
package/models/base.gmdl CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "garu-ko",
3
- "version": "0.1.5",
4
- "description": "Ultra-lightweight Korean morphological analyzer for the web (2.2MB model, WASM 93KB, F1 95.3%)",
3
+ "version": "0.2.0",
4
+ "description": "Ultra-lightweight Korean morphological analyzer for the web (1.7MB model, WASM 93KB, F1 95.3%)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
Binary file
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "garu-wasm",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "files": [
6
+ "garu_wasm_bg.wasm",
7
+ "garu_wasm.js",
8
+ "garu_wasm.d.ts"
9
+ ],
10
+ "main": "garu_wasm.js",
11
+ "types": "garu_wasm.d.ts",
12
+ "sideEffects": [
13
+ "./snippets/*"
14
+ ]
15
+ }