garu-ko 0.13.0 → 0.13.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/dist/normalize.js CHANGED
@@ -55,17 +55,23 @@ export function splitSentences(text) {
55
55
  let lastByteIdx = 0;
56
56
  let match;
57
57
  while ((match = re.exec(text)) !== null) {
58
- const segText = text.slice(lastByteIdx, match.index + match[1].length).trim();
58
+ const raw = text.slice(lastByteIdx, match.index + match[1].length);
59
+ const segText = raw.trim();
59
60
  if (segText.length > 0) {
60
- segments.push({ text: segText, offset: lastCharOffset });
61
+ segments.push({ text: segText, offset: lastCharOffset + leadingSpace(raw) });
61
62
  }
62
63
  const newStart = match.index + match[0].length;
63
64
  lastCharOffset += [...text.slice(lastByteIdx, newStart)].length;
64
65
  lastByteIdx = newStart;
65
66
  }
66
- const last = text.slice(lastByteIdx).trim();
67
+ const rawLast = text.slice(lastByteIdx);
68
+ const last = rawLast.trim();
67
69
  if (last.length > 0) {
68
- segments.push({ text: last, offset: lastCharOffset });
70
+ segments.push({ text: last, offset: lastCharOffset + leadingSpace(rawLast) });
69
71
  }
70
72
  return segments.length > 0 ? segments : [{ text: text.trim(), offset: 0 }];
71
73
  }
74
+ /** Codepoints `trim()` drops from the start; JS whitespace is all BMP, so UTF-16 length is exact. */
75
+ function leadingSpace(raw) {
76
+ return raw.length - raw.trimStart().length;
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "garu-ko",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Ultra-lightweight Korean morphological analyzer for the web (1.34MB model, WASM, F1 96.18% gold testset)",
5
5
  "type": "module",
6
6
  "main": "dist/node.js",
package/pkg/garu_wasm.js CHANGED
@@ -156,7 +156,7 @@ export class GaruWasm {
156
156
  }
157
157
  }
158
158
  if (Symbol.dispose) GaruWasm.prototype[Symbol.dispose] = GaruWasm.prototype.free;
159
- import * as import1 from "./snippets/garu-core-c2e3720a73bec734/inline0.js"
159
+ import * as import1 from "./snippets/garu-core-42affb4a75f2d545/inline0.js"
160
160
 
161
161
  function __wbg_get_imports() {
162
162
  const import0 = {
@@ -215,7 +215,7 @@ function __wbg_get_imports() {
215
215
  return {
216
216
  __proto__: null,
217
217
  "./garu_wasm_bg.js": import0,
218
- "./snippets/garu-core-c2e3720a73bec734/inline0.js": import1,
218
+ "./snippets/garu-core-42affb4a75f2d545/inline0.js": import1,
219
219
  };
220
220
  }
221
221
 
Binary file
package/pkg/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "garu-wasm",
3
3
  "type": "module",
4
- "version": "0.13.0",
4
+ "version": "0.13.1",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "garu_wasm_bg.wasm",