garu-ko 0.3.1 → 0.3.2
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.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/normalize.d.ts +19 -0
- package/dist/normalize.js +71 -0
- package/package.json +1 -1
- package/pkg/garu_wasm.d.ts +0 -52
- package/pkg/garu_wasm.js +0 -345
- package/pkg/garu_wasm_bg.wasm +0 -0
- package/pkg/garu_wasm_bg.wasm.d.ts +0 -15
- package/pkg/package.json +0 -15
- package/pkg/snippets/garu-core-82ebac66ba12d856/inline0.js +0 -1
- package/pkg/snippets/garu-core-8bb32ce2ac7b2d7b/inline0.js +0 -1
- package/pkg/snippets/garu-core-c91d368e7251f313/inline0.js +0 -1
- package/pkg/snippets/garu-core-d0bd202007f7afa3/inline0.js +0 -1
- package/pkg/snippets/garu-core-ea50edba4dc5fdae/inline0.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface AnalyzeResult {
|
|
|
11
11
|
score: number;
|
|
12
12
|
elapsed: number;
|
|
13
13
|
}
|
|
14
|
+
export { normalizeText, splitSentences } from './normalize.js';
|
|
15
|
+
export type { NormalizeOptions, Segment } from './normalize.js';
|
|
14
16
|
export interface AnalyzeOptions {
|
|
15
17
|
topN?: number;
|
|
16
18
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { normalizeText, splitSentences } from './normalize.js';
|
|
1
2
|
const isNode = typeof process !== 'undefined' &&
|
|
2
3
|
process.versions != null &&
|
|
3
4
|
process.versions.node != null;
|
|
@@ -132,7 +133,7 @@ export class Garu {
|
|
|
132
133
|
return {
|
|
133
134
|
version: this._wasm.constructor.version(),
|
|
134
135
|
size: this._modelSize,
|
|
135
|
-
accuracy: 0.
|
|
136
|
+
accuracy: 0.908,
|
|
136
137
|
};
|
|
137
138
|
}
|
|
138
139
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text normalization utilities for Garu Korean morphological analyzer.
|
|
3
|
+
* Pre-processes informal/non-standard Korean text before analysis.
|
|
4
|
+
*/
|
|
5
|
+
export interface NormalizeOptions {
|
|
6
|
+
/** Collapse repeated jamo (ㅋㅋㅋ→ㅋㅋ). Default: true */
|
|
7
|
+
jamo?: boolean;
|
|
8
|
+
/** Expand 2-char jamo abbreviations (ㄱㅅ→감사). Default: false */
|
|
9
|
+
jamoAbbrev?: boolean;
|
|
10
|
+
/** Normalize common dialect stems (워디→어디). Default: false */
|
|
11
|
+
dialect?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function normalizeText(text: string, opts?: NormalizeOptions): string;
|
|
14
|
+
export interface Segment {
|
|
15
|
+
text: string;
|
|
16
|
+
/** Character offset of this segment in the original text */
|
|
17
|
+
offset: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function splitSentences(text: string): Segment[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text normalization utilities for Garu Korean morphological analyzer.
|
|
3
|
+
* Pre-processes informal/non-standard Korean text before analysis.
|
|
4
|
+
*/
|
|
5
|
+
const COMPAT_JAMO_RE = /([\u3131-\u3163])\1{2,}/g;
|
|
6
|
+
const JAMO_ABBREV_MAP = {
|
|
7
|
+
'ㄱㅅ': '감사',
|
|
8
|
+
'ㅊㅋ': '축하',
|
|
9
|
+
'ㄴㄴ': '노노',
|
|
10
|
+
'ㅂㅂ': '바이바이',
|
|
11
|
+
'ㅈㅅ': '죄송',
|
|
12
|
+
'ㄱㅊ': '괜찮',
|
|
13
|
+
'ㅇㅈ': '인정',
|
|
14
|
+
'ㅎㅇ': '하이',
|
|
15
|
+
'ㄹㅇ': '리얼',
|
|
16
|
+
'ㅇㅋ': '오케이',
|
|
17
|
+
'ㅁㄹ': '모름',
|
|
18
|
+
'ㅅㄱ': '수고',
|
|
19
|
+
'ㅊㅊ': '추천',
|
|
20
|
+
'ㅍㅌ': '파이팅',
|
|
21
|
+
'ㄷㄷ': '덜덜',
|
|
22
|
+
};
|
|
23
|
+
const DIALECT_MAP = {
|
|
24
|
+
'워디': '어디',
|
|
25
|
+
'와케': '왜이렇게',
|
|
26
|
+
'우예': '어떻게',
|
|
27
|
+
'긍게': '그러니까',
|
|
28
|
+
'워메': '어머',
|
|
29
|
+
'가유': '가요',
|
|
30
|
+
'허유': '해요',
|
|
31
|
+
};
|
|
32
|
+
export function normalizeText(text, opts = {}) {
|
|
33
|
+
const { jamo = true, jamoAbbrev = false, dialect = false } = opts;
|
|
34
|
+
let result = text;
|
|
35
|
+
if (jamo) {
|
|
36
|
+
result = result.replace(COMPAT_JAMO_RE, '$1$1');
|
|
37
|
+
}
|
|
38
|
+
if (jamoAbbrev) {
|
|
39
|
+
for (const [abbrev, expansion] of Object.entries(JAMO_ABBREV_MAP)) {
|
|
40
|
+
const re = new RegExp(`(?<![가-힣ㄱ-ㅣ])${abbrev}(?![가-힣ㄱ-ㅣ])`, 'g');
|
|
41
|
+
result = result.replace(re, expansion);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (dialect) {
|
|
45
|
+
for (const [dialectForm, standard] of Object.entries(DIALECT_MAP)) {
|
|
46
|
+
result = result.replace(new RegExp(dialectForm, 'g'), standard);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
export function splitSentences(text) {
|
|
52
|
+
const segments = [];
|
|
53
|
+
const re = /([.!?…]+)\s+(?=[가-힣A-Z"'([{])/g;
|
|
54
|
+
let lastCharOffset = 0;
|
|
55
|
+
let lastByteIdx = 0;
|
|
56
|
+
let match;
|
|
57
|
+
while ((match = re.exec(text)) !== null) {
|
|
58
|
+
const segText = text.slice(lastByteIdx, match.index + match[1].length).trim();
|
|
59
|
+
if (segText.length > 0) {
|
|
60
|
+
segments.push({ text: segText, offset: lastCharOffset });
|
|
61
|
+
}
|
|
62
|
+
const newStart = match.index + match[0].length;
|
|
63
|
+
lastCharOffset += [...text.slice(lastByteIdx, newStart)].length;
|
|
64
|
+
lastByteIdx = newStart;
|
|
65
|
+
}
|
|
66
|
+
const last = text.slice(lastByteIdx).trim();
|
|
67
|
+
if (last.length > 0) {
|
|
68
|
+
segments.push({ text: last, offset: lastCharOffset });
|
|
69
|
+
}
|
|
70
|
+
return segments.length > 0 ? segments : [{ text: text.trim(), offset: 0 }];
|
|
71
|
+
}
|
package/package.json
CHANGED
package/pkg/garu_wasm.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
export class GaruWasm {
|
|
5
|
-
free(): void;
|
|
6
|
-
[Symbol.dispose](): void;
|
|
7
|
-
analyze(text: string): any;
|
|
8
|
-
analyze_topn(text: string, n: number): any;
|
|
9
|
-
constructor(model_data: Uint8Array);
|
|
10
|
-
tokenize(text: string): any;
|
|
11
|
-
static version(): string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
15
|
-
|
|
16
|
-
export interface InitOutput {
|
|
17
|
-
readonly memory: WebAssembly.Memory;
|
|
18
|
-
readonly __wbg_garuwasm_free: (a: number, b: number) => void;
|
|
19
|
-
readonly garuwasm_analyze: (a: number, b: number, c: number) => [number, number, number];
|
|
20
|
-
readonly garuwasm_analyze_topn: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
21
|
-
readonly garuwasm_new: (a: number, b: number) => [number, number, number];
|
|
22
|
-
readonly garuwasm_tokenize: (a: number, b: number, c: number) => [number, number, number];
|
|
23
|
-
readonly garuwasm_version: () => [number, number];
|
|
24
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
25
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
26
|
-
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
27
|
-
readonly __externref_table_dealloc: (a: number) => void;
|
|
28
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
29
|
-
readonly __wbindgen_start: () => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
36
|
-
* a precompiled `WebAssembly.Module`.
|
|
37
|
-
*
|
|
38
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
39
|
-
*
|
|
40
|
-
* @returns {InitOutput}
|
|
41
|
-
*/
|
|
42
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
46
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
47
|
-
*
|
|
48
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
49
|
-
*
|
|
50
|
-
* @returns {Promise<InitOutput>}
|
|
51
|
-
*/
|
|
52
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/pkg/garu_wasm.js
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
/* @ts-self-types="./garu_wasm.d.ts" */
|
|
2
|
-
|
|
3
|
-
export class GaruWasm {
|
|
4
|
-
__destroy_into_raw() {
|
|
5
|
-
const ptr = this.__wbg_ptr;
|
|
6
|
-
this.__wbg_ptr = 0;
|
|
7
|
-
GaruWasmFinalization.unregister(this);
|
|
8
|
-
return ptr;
|
|
9
|
-
}
|
|
10
|
-
free() {
|
|
11
|
-
const ptr = this.__destroy_into_raw();
|
|
12
|
-
wasm.__wbg_garuwasm_free(ptr, 0);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @param {string} text
|
|
16
|
-
* @returns {any}
|
|
17
|
-
*/
|
|
18
|
-
analyze(text) {
|
|
19
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
20
|
-
const len0 = WASM_VECTOR_LEN;
|
|
21
|
-
const ret = wasm.garuwasm_analyze(this.__wbg_ptr, ptr0, len0);
|
|
22
|
-
if (ret[2]) {
|
|
23
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
24
|
-
}
|
|
25
|
-
return takeFromExternrefTable0(ret[0]);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @param {string} text
|
|
29
|
-
* @param {number} n
|
|
30
|
-
* @returns {any}
|
|
31
|
-
*/
|
|
32
|
-
analyze_topn(text, n) {
|
|
33
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
34
|
-
const len0 = WASM_VECTOR_LEN;
|
|
35
|
-
const ret = wasm.garuwasm_analyze_topn(this.__wbg_ptr, ptr0, len0, n);
|
|
36
|
-
if (ret[2]) {
|
|
37
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
38
|
-
}
|
|
39
|
-
return takeFromExternrefTable0(ret[0]);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @param {Uint8Array} model_data
|
|
43
|
-
*/
|
|
44
|
-
constructor(model_data) {
|
|
45
|
-
const ptr0 = passArray8ToWasm0(model_data, wasm.__wbindgen_malloc);
|
|
46
|
-
const len0 = WASM_VECTOR_LEN;
|
|
47
|
-
const ret = wasm.garuwasm_new(ptr0, len0);
|
|
48
|
-
if (ret[2]) {
|
|
49
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
50
|
-
}
|
|
51
|
-
this.__wbg_ptr = ret[0] >>> 0;
|
|
52
|
-
GaruWasmFinalization.register(this, this.__wbg_ptr, this);
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @param {string} text
|
|
57
|
-
* @returns {any}
|
|
58
|
-
*/
|
|
59
|
-
tokenize(text) {
|
|
60
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
61
|
-
const len0 = WASM_VECTOR_LEN;
|
|
62
|
-
const ret = wasm.garuwasm_tokenize(this.__wbg_ptr, ptr0, len0);
|
|
63
|
-
if (ret[2]) {
|
|
64
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
65
|
-
}
|
|
66
|
-
return takeFromExternrefTable0(ret[0]);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* @returns {string}
|
|
70
|
-
*/
|
|
71
|
-
static version() {
|
|
72
|
-
let deferred1_0;
|
|
73
|
-
let deferred1_1;
|
|
74
|
-
try {
|
|
75
|
-
const ret = wasm.garuwasm_version();
|
|
76
|
-
deferred1_0 = ret[0];
|
|
77
|
-
deferred1_1 = ret[1];
|
|
78
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
79
|
-
} finally {
|
|
80
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (Symbol.dispose) GaruWasm.prototype[Symbol.dispose] = GaruWasm.prototype.free;
|
|
85
|
-
import * as import1 from "./snippets/garu-core-d0bd202007f7afa3/inline0.js"
|
|
86
|
-
|
|
87
|
-
function __wbg_get_imports() {
|
|
88
|
-
const import0 = {
|
|
89
|
-
__proto__: null,
|
|
90
|
-
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
91
|
-
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
92
|
-
return ret;
|
|
93
|
-
},
|
|
94
|
-
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
95
|
-
const ret = String(arg1);
|
|
96
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
97
|
-
const len1 = WASM_VECTOR_LEN;
|
|
98
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
99
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
100
|
-
},
|
|
101
|
-
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
102
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
103
|
-
},
|
|
104
|
-
__wbg_new_a70fbab9066b301f: function() {
|
|
105
|
-
const ret = new Array();
|
|
106
|
-
return ret;
|
|
107
|
-
},
|
|
108
|
-
__wbg_new_ab79df5bd7c26067: function() {
|
|
109
|
-
const ret = new Object();
|
|
110
|
-
return ret;
|
|
111
|
-
},
|
|
112
|
-
__wbg_set_282384002438957f: function(arg0, arg1, arg2) {
|
|
113
|
-
arg0[arg1 >>> 0] = arg2;
|
|
114
|
-
},
|
|
115
|
-
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
116
|
-
arg0[arg1] = arg2;
|
|
117
|
-
},
|
|
118
|
-
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
119
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
120
|
-
const ret = arg0;
|
|
121
|
-
return ret;
|
|
122
|
-
},
|
|
123
|
-
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
124
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
125
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
126
|
-
return ret;
|
|
127
|
-
},
|
|
128
|
-
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
129
|
-
// Cast intrinsic for `U64 -> Externref`.
|
|
130
|
-
const ret = BigInt.asUintN(64, arg0);
|
|
131
|
-
return ret;
|
|
132
|
-
},
|
|
133
|
-
__wbindgen_init_externref_table: function() {
|
|
134
|
-
const table = wasm.__wbindgen_externrefs;
|
|
135
|
-
const offset = table.grow(4);
|
|
136
|
-
table.set(0, undefined);
|
|
137
|
-
table.set(offset + 0, undefined);
|
|
138
|
-
table.set(offset + 1, null);
|
|
139
|
-
table.set(offset + 2, true);
|
|
140
|
-
table.set(offset + 3, false);
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
return {
|
|
144
|
-
__proto__: null,
|
|
145
|
-
"./garu_wasm_bg.js": import0,
|
|
146
|
-
"./snippets/garu-core-d0bd202007f7afa3/inline0.js": import1,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const GaruWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
151
|
-
? { register: () => {}, unregister: () => {} }
|
|
152
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_garuwasm_free(ptr >>> 0, 1));
|
|
153
|
-
|
|
154
|
-
let cachedDataViewMemory0 = null;
|
|
155
|
-
function getDataViewMemory0() {
|
|
156
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
157
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
158
|
-
}
|
|
159
|
-
return cachedDataViewMemory0;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function getStringFromWasm0(ptr, len) {
|
|
163
|
-
ptr = ptr >>> 0;
|
|
164
|
-
return decodeText(ptr, len);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let cachedUint8ArrayMemory0 = null;
|
|
168
|
-
function getUint8ArrayMemory0() {
|
|
169
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
170
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
171
|
-
}
|
|
172
|
-
return cachedUint8ArrayMemory0;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
176
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
177
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
178
|
-
WASM_VECTOR_LEN = arg.length;
|
|
179
|
-
return ptr;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
183
|
-
if (realloc === undefined) {
|
|
184
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
185
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
186
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
187
|
-
WASM_VECTOR_LEN = buf.length;
|
|
188
|
-
return ptr;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
let len = arg.length;
|
|
192
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
193
|
-
|
|
194
|
-
const mem = getUint8ArrayMemory0();
|
|
195
|
-
|
|
196
|
-
let offset = 0;
|
|
197
|
-
|
|
198
|
-
for (; offset < len; offset++) {
|
|
199
|
-
const code = arg.charCodeAt(offset);
|
|
200
|
-
if (code > 0x7F) break;
|
|
201
|
-
mem[ptr + offset] = code;
|
|
202
|
-
}
|
|
203
|
-
if (offset !== len) {
|
|
204
|
-
if (offset !== 0) {
|
|
205
|
-
arg = arg.slice(offset);
|
|
206
|
-
}
|
|
207
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
208
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
209
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
210
|
-
|
|
211
|
-
offset += ret.written;
|
|
212
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
WASM_VECTOR_LEN = offset;
|
|
216
|
-
return ptr;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function takeFromExternrefTable0(idx) {
|
|
220
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
221
|
-
wasm.__externref_table_dealloc(idx);
|
|
222
|
-
return value;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
226
|
-
cachedTextDecoder.decode();
|
|
227
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
228
|
-
let numBytesDecoded = 0;
|
|
229
|
-
function decodeText(ptr, len) {
|
|
230
|
-
numBytesDecoded += len;
|
|
231
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
232
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
233
|
-
cachedTextDecoder.decode();
|
|
234
|
-
numBytesDecoded = len;
|
|
235
|
-
}
|
|
236
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const cachedTextEncoder = new TextEncoder();
|
|
240
|
-
|
|
241
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
242
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
243
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
244
|
-
view.set(buf);
|
|
245
|
-
return {
|
|
246
|
-
read: arg.length,
|
|
247
|
-
written: buf.length
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
let WASM_VECTOR_LEN = 0;
|
|
253
|
-
|
|
254
|
-
let wasmModule, wasm;
|
|
255
|
-
function __wbg_finalize_init(instance, module) {
|
|
256
|
-
wasm = instance.exports;
|
|
257
|
-
wasmModule = module;
|
|
258
|
-
cachedDataViewMemory0 = null;
|
|
259
|
-
cachedUint8ArrayMemory0 = null;
|
|
260
|
-
wasm.__wbindgen_start();
|
|
261
|
-
return wasm;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async function __wbg_load(module, imports) {
|
|
265
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
266
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
267
|
-
try {
|
|
268
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
269
|
-
} catch (e) {
|
|
270
|
-
const validResponse = module.ok && expectedResponseType(module.type);
|
|
271
|
-
|
|
272
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
273
|
-
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
274
|
-
|
|
275
|
-
} else { throw e; }
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const bytes = await module.arrayBuffer();
|
|
280
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
281
|
-
} else {
|
|
282
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
283
|
-
|
|
284
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
285
|
-
return { instance, module };
|
|
286
|
-
} else {
|
|
287
|
-
return instance;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function expectedResponseType(type) {
|
|
292
|
-
switch (type) {
|
|
293
|
-
case 'basic': case 'cors': case 'default': return true;
|
|
294
|
-
}
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function initSync(module) {
|
|
300
|
-
if (wasm !== undefined) return wasm;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (module !== undefined) {
|
|
304
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
305
|
-
({module} = module)
|
|
306
|
-
} else {
|
|
307
|
-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const imports = __wbg_get_imports();
|
|
312
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
313
|
-
module = new WebAssembly.Module(module);
|
|
314
|
-
}
|
|
315
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
316
|
-
return __wbg_finalize_init(instance, module);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
async function __wbg_init(module_or_path) {
|
|
320
|
-
if (wasm !== undefined) return wasm;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (module_or_path !== undefined) {
|
|
324
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
325
|
-
({module_or_path} = module_or_path)
|
|
326
|
-
} else {
|
|
327
|
-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (module_or_path === undefined) {
|
|
332
|
-
module_or_path = new URL('garu_wasm_bg.wasm', import.meta.url);
|
|
333
|
-
}
|
|
334
|
-
const imports = __wbg_get_imports();
|
|
335
|
-
|
|
336
|
-
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
337
|
-
module_or_path = fetch(module_or_path);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
341
|
-
|
|
342
|
-
return __wbg_finalize_init(instance, module);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export { initSync, __wbg_init as default };
|
package/pkg/garu_wasm_bg.wasm
DELETED
|
Binary file
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const __wbg_garuwasm_free: (a: number, b: number) => void;
|
|
5
|
-
export const garuwasm_analyze: (a: number, b: number, c: number) => [number, number, number];
|
|
6
|
-
export const garuwasm_analyze_topn: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
7
|
-
export const garuwasm_new: (a: number, b: number) => [number, number, number];
|
|
8
|
-
export const garuwasm_tokenize: (a: number, b: number, c: number) => [number, number, number];
|
|
9
|
-
export const garuwasm_version: () => [number, number];
|
|
10
|
-
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
11
|
-
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
12
|
-
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
13
|
-
export const __externref_table_dealloc: (a: number) => void;
|
|
14
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
15
|
-
export const __wbindgen_start: () => void;
|
package/pkg/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function performance_now() { return performance.now(); }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function performance_now() { return performance.now(); }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function performance_now() { return performance.now(); }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function performance_now() { return performance.now(); }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function performance_now() { return performance.now(); }
|