garu-ko 0.13.1 → 0.14.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,9 +2,9 @@
2
2
 
3
3
  **Browser-native Korean morphological analyzer.** No server required.
4
4
 
5
- - **1.34MB model** bundled in npm package (no CDN needed)
6
- - **447KB WASM** engine (182KB gzipped) -- runs in any modern browser
7
- - **F1 96.18%** on 9k human-verified gold testset (ep_norm), **F1 92.32%** on a fixed 2025 spoken-language set
5
+ - **1.43MB model** bundled in npm package (no CDN needed)
6
+ - **471KB WASM** engine (201KB gzipped) -- runs in any modern browser
7
+ - **F1 96.17%** on the 9,000-sentence v15k gold set (ep_norm), **F1 92.33%** on a fixed 2025 spoken-language set
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
@@ -36,7 +36,7 @@ console.log(result.tokens);
36
36
  // { text: '배', pos: 'NNG', start: 0, end: 2 },
37
37
  // { text: '가', pos: 'JKS', start: 0, end: 2 },
38
38
  // { text: '아프', pos: 'VA', start: 3, end: 6 },
39
- // { text: '어서', pos: 'EC', start: 3, end: 6 },
39
+ // { text: '아서', pos: 'EC', start: 3, end: 6 },
40
40
  // { text: '약', pos: 'NNG', start: 7, end: 9 },
41
41
  // { text: '을', pos: 'JKO', start: 7, end: 9 },
42
42
  // { text: '먹', pos: 'VV', start: 10, end: 13 },
@@ -46,7 +46,7 @@ console.log(result.tokens);
46
46
 
47
47
  // Simple tokenization
48
48
  const tokens = garu.tokenize('나는 학교에 간다');
49
- // ['나', '는', '학교', '에', '간다']
49
+ // ['나', '는', '학교', '에', '가', 'ㄴ다']
50
50
 
51
51
  garu.destroy(); // free WASM memory
52
52
  ```
@@ -118,6 +118,7 @@ Initialize WASM and load model. Uses bundled model by default.
118
118
  |---|---|---|
119
119
  | `modelData` | `ArrayBuffer` | Provide model bytes directly |
120
120
  | `modelUrl` | `string` | Fetch model from URL |
121
+ | `promiseEndings` | `'legacy' \| 'standard'` | Defaults to `'standard'`, which analyzes `먹을게요` as `먹/VV + 을게/EF + 요/JX`. Use `'legacy'` for the promise-ending behavior of 0.13.1. |
121
122
 
122
123
  ### `garu.analyze(text, options?): AnalyzeResult`
123
124
 
@@ -127,11 +128,15 @@ Returns morphological tokens with POS tags (Sejong tagset).
127
128
  interface Token {
128
129
  text: string; // surface form
129
130
  pos: POS; // POS tag
130
- start: number; // eojeol start offset
131
- end: number; // eojeol end offset
131
+ start: number; // start in original Unicode code points
132
+ end: number; // exclusive end in original Unicode code points
132
133
  }
133
134
  ```
134
135
 
136
+ By default, Garu selects the verb stem `사/VV` (buy) in `이걸 살게요` and `살/VV` (live) in `여기서 평생 살게요`. Setting `promiseEndings: 'legacy'` also disables this contextual correction.
137
+
138
+ Modern Hangul has the same analysis in composed and decomposed input. User dictionary lookups also accept either spelling. For example, `garu.nouns('학교'.normalize('NFD'))` returns `['학교']`. Its span is `[0, 5)` in original code points.
139
+
135
140
  Set `options.topN > 1` to get N-best results as an array. Note: topN > 1 is not yet fully supported and may return fewer results.
136
141
 
137
142
  ### `garu.nouns(text, options?): string[]`
@@ -211,13 +216,13 @@ await search(db, { term: '먹다' }) // ← matches
211
216
  ## FAQ
212
217
 
213
218
  **What is garu-ko?**
214
- garu-ko (가루/Garu) is a browser-native Korean morphological analyzer. A 1.34MB model and a 447KB WASM engine run entirely in the browser, so it segments Korean text, tags parts of speech, extracts nouns, and tokenizes with no server and no network.
219
+ garu-ko (가루/Garu) is a browser-native Korean morphological analyzer. A 1.43MB model and a 471KB WASM engine run entirely in the browser, so it segments Korean text, tags parts of speech, extracts nouns, and tokenizes with no server and no network.
215
220
 
216
221
  **Does it need a server or API?**
217
222
  No. It runs 100% client-side via WebAssembly. After the initial load there is no backend call, so it works offline and inside browser extensions, service-worker PWAs, and intranet apps.
218
223
 
219
224
  **How accurate is it?**
220
- F1 96.18% on a 9,000-sentence human-verified gold testset (ep_norm), and F1 92.32% on a fixed 2025 spoken-language evaluation set.
225
+ F1 96.17% on a 9,000-sentence v15k gold set (ep_norm), and F1 92.33% on a fixed 2025 spoken-language evaluation set.
221
226
 
222
227
  **Which POS tagset does it use?**
223
228
  The Sejong tagset (42 tags) from the National Institute of Korean Language — NNG/NNP for nouns, VV/VA for verbs/adjectives, particles, endings, and symbols.
package/dist/browser.js CHANGED
@@ -31,6 +31,6 @@ export class Garu extends GaruBase {
31
31
  modelBytes = new Uint8Array(await response.arrayBuffer());
32
32
  }
33
33
  const wasmInstance = new wasmModule.GaruWasm(modelBytes, options?.normalizeJamo ?? false);
34
- return new Garu(wasmInstance, modelBytes.byteLength);
34
+ return new Garu(wasmInstance, modelBytes.byteLength, options?.promiseEndings);
35
35
  }
36
36
  }
package/dist/core.d.ts CHANGED
@@ -2,7 +2,9 @@ export type POS = 'NNG' | 'NNP' | 'NNB' | 'NR' | 'NP' | 'VV' | 'VA' | 'VX' | 'VC
2
2
  export interface Token {
3
3
  text: string;
4
4
  pos: POS;
5
+ /** Inclusive Unicode code-point offset of the source span in the original input. */
5
6
  start: number;
7
+ /** Exclusive Unicode code-point offset of the source span in the original input. */
6
8
  end: number;
7
9
  score?: number;
8
10
  }
@@ -32,6 +34,8 @@ export interface LoadOptions {
32
34
  /** 분석 결과의 자모 형태소(ETM 'ㄴ' 등)를 U+11xx 결합 자모로 정규화.
33
35
  * 기본값 false (gold v15k 다수가 호환 자모 U+3130-318F를 사용). canonical 출력이 필요하면 true. */
34
36
  normalizeJamo?: boolean;
37
+ /** Defaults to 'standard' (ㄹ게/을게 EF + 요 JX). Use 'legacy' for the earlier search and output. */
38
+ promiseEndings?: 'legacy' | 'standard';
35
39
  }
36
40
  export interface ModelInfo {
37
41
  version: string;
@@ -48,7 +52,8 @@ export declare class GaruBase {
48
52
  protected _wasm: any;
49
53
  protected _loaded: boolean;
50
54
  protected _modelSize: number;
51
- protected constructor(wasmInstance: any, modelSize: number);
55
+ private readonly promiseEndings;
56
+ protected constructor(wasmInstance: any, modelSize: number, promiseEndings?: LoadOptions['promiseEndings']);
52
57
  /**
53
58
  * Analyze Korean text, returning morphological tokens with scores.
54
59
  *
package/dist/core.js CHANGED
@@ -10,10 +10,13 @@ export const EMPTY_RESULT = Object.freeze({
10
10
  * environment-appropriate APIs (fetch vs fs).
11
11
  */
12
12
  export class GaruBase {
13
- constructor(wasmInstance, modelSize) {
13
+ constructor(wasmInstance, modelSize, promiseEndings = 'standard') {
14
14
  this._wasm = wasmInstance;
15
15
  this._loaded = true;
16
16
  this._modelSize = modelSize;
17
+ this.promiseEndings = promiseEndings;
18
+ if (promiseEndings === 'legacy')
19
+ wasmInstance.use_legacy_promise_endings();
17
20
  }
18
21
  /**
19
22
  * Analyze Korean text, returning morphological tokens with scores.
@@ -121,7 +124,7 @@ export class GaruBase {
121
124
  return {
122
125
  version: this._wasm.constructor.version(),
123
126
  size: this._modelSize,
124
- accuracy: 0.9618,
127
+ accuracy: this.promiseEndings === 'legacy' ? 0.9618 : 0.9617,
125
128
  };
126
129
  }
127
130
  /**
package/dist/node.js CHANGED
@@ -32,6 +32,6 @@ export class Garu extends GaruBase {
32
32
  modelBytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
33
33
  }
34
34
  const wasmInstance = new wasmModule.GaruWasm(modelBytes, options?.normalizeJamo ?? false);
35
- return new Garu(wasmInstance, modelBytes.byteLength);
35
+ return new Garu(wasmInstance, modelBytes.byteLength, options?.promiseEndings);
36
36
  }
37
37
  }
package/models/NOTICE.md CHANGED
@@ -15,3 +15,5 @@ The changes comprise Unicode normalization, POS mapping, deduplication, selectio
15
15
  Retain the applicable attribution and modification notices when redistributing this data. Include a copy of the Apache-2.0 license for the MeCab-derived portions, and the CC license text or its URI for the CC-licensed portions. The ShareAlike condition applies to adaptations of the CC-licensed data. This notice does not relicense the independent engine code or grant new rights to the original training corpora. The full license texts govern their respective source material.
16
16
 
17
17
  The context-POS parameters in Section 16, the optional `garu-ko/text` boundary weights and the Q4 context-verifier weights in `garu-ko/sentences` were trained from the National Institute of Korean Language (국립국어원) NIKL morphological corpus, 2021 edition. Since research history #83 the sentence half of the `garu-ko/text` boundary weights also uses Instagram sentence records from the NIKL online posting materials corpus 2025 (국립국어원 온라인 게시 자료 말뭉치 2025, version 1.0), and the Section 17 spoken `그` rule uses the 2021 spoken corpus with tildes removed. Training and evaluation lineage is recorded in `training/ambiguity/` and `training/boundaries/` in the repository; `sentence-provenance.json` identifies both the fast and morphology-assisted Q4 artifacts. Original corpus paragraphs and annotations are not included in the package.
18
+
19
+ Section 19 resolves the verb stems 사 and 살 using context features from 3,369 labeled occurrences in 1,115 documents of the NIKL 2021 morphological training corpus. The packaged section contains feature hashes and quantized weights. The 2025 evaluation sets were used for evaluation only for this classifier.
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.13.1",
4
- "description": "Ultra-lightweight Korean morphological analyzer for the web (1.34MB model, WASM, F1 96.18% gold testset)",
3
+ "version": "0.14.0",
4
+ "description": "Ultra-lightweight Korean morphological analyzer for the web (1.43MB model, WASM, F1 96.17% gold testset)",
5
5
  "type": "module",
6
6
  "main": "dist/node.js",
7
7
  "browser": "dist/browser.js",
@@ -16,6 +16,7 @@ export class GaruWasm {
16
16
  clear_user_words(): void;
17
17
  constructor(model_data: Uint8Array, normalize_jamo?: boolean | null);
18
18
  tokenize(text: string): any;
19
+ use_legacy_promise_endings(): void;
19
20
  /**
20
21
  * 등록된 사용자 단어 수.
21
22
  */
@@ -34,6 +35,7 @@ export interface InitOutput {
34
35
  readonly garuwasm_clear_user_words: (a: number) => void;
35
36
  readonly garuwasm_new: (a: number, b: number, c: number, d: number) => void;
36
37
  readonly garuwasm_tokenize: (a: number, b: number, c: number, d: number) => void;
38
+ readonly garuwasm_use_legacy_promise_endings: (a: number) => void;
37
39
  readonly garuwasm_user_word_count: (a: number) => number;
38
40
  readonly garuwasm_version: (a: number) => void;
39
41
  readonly __wbindgen_export: (a: number, b: number) => number;
package/pkg/garu_wasm.js CHANGED
@@ -127,6 +127,9 @@ export class GaruWasm {
127
127
  wasm.__wbindgen_add_to_stack_pointer(16);
128
128
  }
129
129
  }
130
+ use_legacy_promise_endings() {
131
+ wasm.garuwasm_use_legacy_promise_endings(this.__wbg_ptr);
132
+ }
130
133
  /**
131
134
  * 등록된 사용자 단어 수.
132
135
  * @returns {number}
@@ -156,7 +159,7 @@ export class GaruWasm {
156
159
  }
157
160
  }
158
161
  if (Symbol.dispose) GaruWasm.prototype[Symbol.dispose] = GaruWasm.prototype.free;
159
- import * as import1 from "./snippets/garu-core-42affb4a75f2d545/inline0.js"
162
+ import * as import1 from "./snippets/garu-core-ebaf5956ee45f13f/inline0.js"
160
163
 
161
164
  function __wbg_get_imports() {
162
165
  const import0 = {
@@ -215,7 +218,7 @@ function __wbg_get_imports() {
215
218
  return {
216
219
  __proto__: null,
217
220
  "./garu_wasm_bg.js": import0,
218
- "./snippets/garu-core-42affb4a75f2d545/inline0.js": import1,
221
+ "./snippets/garu-core-ebaf5956ee45f13f/inline0.js": import1,
219
222
  };
220
223
  }
221
224
 
Binary file
@@ -8,6 +8,7 @@ export const garuwasm_analyze_topn: (a: number, b: number, c: number, d: number,
8
8
  export const garuwasm_clear_user_words: (a: number) => void;
9
9
  export const garuwasm_new: (a: number, b: number, c: number, d: number) => void;
10
10
  export const garuwasm_tokenize: (a: number, b: number, c: number, d: number) => void;
11
+ export const garuwasm_use_legacy_promise_endings: (a: number) => void;
11
12
  export const garuwasm_user_word_count: (a: number) => number;
12
13
  export const garuwasm_version: (a: number) => void;
13
14
  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.13.1",
4
+ "version": "0.14.0",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "garu_wasm_bg.wasm",