garu-ko 0.8.1 → 0.9.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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  - **1MB model** bundled in npm package (no CDN needed)
6
6
  - **332KB WASM** engine (152KB gzipped) -- runs in any modern browser
7
- - **F1 93.97%** on human-verified gold testset (vs. Kiwi 89.7%)
7
+ - **F1 93.29%** on 9k human-verified gold testset (ep_norm), **F1 93.7%** on NIKL MP
8
8
  - **~1ms** inference per sentence
9
9
  - **Offline-ready** -- works without network
10
10
  - **[Live Demo](https://garu.zerry.co.kr)** -- try it in your browser
@@ -15,8 +15,8 @@
15
15
  |---|---|---|---|
16
16
  | Model size | ~40MB | ~50MB | **1MB** |
17
17
  | npm package | No | No | **Yes** |
18
- | F1 (gold testset) | 89.7% | | **93.97%** |
19
- | F1 (NIKL MP) | 87.9% | ~85% | **93.90%** |
18
+ | F1 (gold v15k, ep_norm) | 95.0% | 75.5% | 93.3% |
19
+ | F1 (NIKL MP) | 87.9% | ~85% | **93.7%** |
20
20
  | Browser support | Impractical | No | **Yes** |
21
21
 
22
22
  ## Quick Start
package/dist/browser.js CHANGED
@@ -30,7 +30,7 @@ export class Garu extends GaruBase {
30
30
  }
31
31
  modelBytes = new Uint8Array(await response.arrayBuffer());
32
32
  }
33
- const wasmInstance = new wasmModule.GaruWasm(modelBytes);
33
+ const wasmInstance = new wasmModule.GaruWasm(modelBytes, options?.normalizeJamo ?? false);
34
34
  return new Garu(wasmInstance, modelBytes.byteLength);
35
35
  }
36
36
  }
package/dist/core.d.ts CHANGED
@@ -22,6 +22,9 @@ export interface NounsOptions {
22
22
  export interface LoadOptions {
23
23
  modelData?: ArrayBuffer;
24
24
  modelUrl?: string;
25
+ /** 분석 결과의 자모 형태소(ETM 'ㄴ' 등)를 U+11xx 결합 자모로 정규화.
26
+ * 기본값 false (gold v15k 다수가 호환 자모 U+3130-318F를 사용). canonical 출력이 필요하면 true. */
27
+ normalizeJamo?: boolean;
25
28
  }
26
29
  export interface ModelInfo {
27
30
  version: string;
package/dist/node.js CHANGED
@@ -31,7 +31,7 @@ export class Garu extends GaruBase {
31
31
  const buf = await readFile(join(dir, '..', 'models', 'base.gmdl'));
32
32
  modelBytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
33
33
  }
34
- const wasmInstance = new wasmModule.GaruWasm(modelBytes);
34
+ const wasmInstance = new wasmModule.GaruWasm(modelBytes, options?.normalizeJamo ?? false);
35
35
  return new Garu(wasmInstance, modelBytes.byteLength);
36
36
  }
37
37
  }
package/models/base.gmdl CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "garu-ko",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "Ultra-lightweight Korean morphological analyzer for the web (1.9MB model, WASM, F1 93.9%)",
5
5
  "type": "module",
6
6
  "main": "dist/node.js",
@@ -6,7 +6,7 @@ export class GaruWasm {
6
6
  [Symbol.dispose](): void;
7
7
  analyze(text: string): any;
8
8
  analyze_topn(text: string, n: number): any;
9
- constructor(model_data: Uint8Array);
9
+ constructor(model_data: Uint8Array, normalize_jamo?: boolean | null);
10
10
  tokenize(text: string): any;
11
11
  static version(): string;
12
12
  }
@@ -18,7 +18,7 @@ export interface InitOutput {
18
18
  readonly __wbg_garuwasm_free: (a: number, b: number) => void;
19
19
  readonly garuwasm_analyze: (a: number, b: number, c: number, d: number) => void;
20
20
  readonly garuwasm_analyze_topn: (a: number, b: number, c: number, d: number, e: number) => void;
21
- readonly garuwasm_new: (a: number, b: number, c: number) => void;
21
+ readonly garuwasm_new: (a: number, b: number, c: number, d: number) => void;
22
22
  readonly garuwasm_tokenize: (a: number, b: number, c: number, d: number) => void;
23
23
  readonly garuwasm_version: (a: number) => void;
24
24
  readonly __wbindgen_export: (a: number, b: number) => number;
package/pkg/garu_wasm.js CHANGED
@@ -56,13 +56,14 @@ export class GaruWasm {
56
56
  }
57
57
  /**
58
58
  * @param {Uint8Array} model_data
59
+ * @param {boolean | null} [normalize_jamo]
59
60
  */
60
- constructor(model_data) {
61
+ constructor(model_data, normalize_jamo) {
61
62
  try {
62
63
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
63
64
  const ptr0 = passArray8ToWasm0(model_data, wasm.__wbindgen_export);
64
65
  const len0 = WASM_VECTOR_LEN;
65
- wasm.garuwasm_new(retptr, ptr0, len0);
66
+ wasm.garuwasm_new(retptr, ptr0, len0, isLikeNone(normalize_jamo) ? 0xFFFFFF : normalize_jamo ? 1 : 0);
66
67
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
67
68
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
68
69
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -118,7 +119,7 @@ export class GaruWasm {
118
119
  }
119
120
  }
120
121
  if (Symbol.dispose) GaruWasm.prototype[Symbol.dispose] = GaruWasm.prototype.free;
121
- import * as import1 from "./snippets/garu-core-0a2f508caf98b80c/inline0.js"
122
+ import * as import1 from "./snippets/garu-core-258b8d34fad9321e/inline0.js"
122
123
 
123
124
  function __wbg_get_imports() {
124
125
  const import0 = {
@@ -177,7 +178,7 @@ function __wbg_get_imports() {
177
178
  return {
178
179
  __proto__: null,
179
180
  "./garu_wasm_bg.js": import0,
180
- "./snippets/garu-core-0a2f508caf98b80c/inline0.js": import1,
181
+ "./snippets/garu-core-258b8d34fad9321e/inline0.js": import1,
181
182
  };
182
183
  }
183
184
 
@@ -228,6 +229,10 @@ heap.push(undefined, null, true, false);
228
229
 
229
230
  let heap_next = heap.length;
230
231
 
232
+ function isLikeNone(x) {
233
+ return x === undefined || x === null;
234
+ }
235
+
231
236
  function passArray8ToWasm0(arg, malloc) {
232
237
  const ptr = malloc(arg.length * 1, 1) >>> 0;
233
238
  getUint8ArrayMemory0().set(arg, ptr / 1);
Binary file
@@ -4,7 +4,7 @@ export const memory: WebAssembly.Memory;
4
4
  export const __wbg_garuwasm_free: (a: number, b: number) => void;
5
5
  export const garuwasm_analyze: (a: number, b: number, c: number, d: number) => void;
6
6
  export const garuwasm_analyze_topn: (a: number, b: number, c: number, d: number, e: number) => void;
7
- export const garuwasm_new: (a: number, b: number, c: number) => void;
7
+ export const garuwasm_new: (a: number, b: number, c: number, d: number) => void;
8
8
  export const garuwasm_tokenize: (a: number, b: number, c: number, d: number) => void;
9
9
  export const garuwasm_version: (a: number) => void;
10
10
  export const __wbindgen_export: (a: number, b: number) => number;
package/pkg/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "garu-wasm",
3
3
  "type": "module",
4
- "version": "0.8.1",
4
+ "version": "0.9.1",
5
5
  "files": [
6
6
  "garu_wasm_bg.wasm",
7
7
  "garu_wasm.js",
@@ -0,0 +1 @@
1
+ export function performance_now() { return performance.now(); }
@@ -0,0 +1 @@
1
+ export function performance_now() { return performance.now(); }