lindera-wasm-web-ipadic 1.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 by the project authors.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # lindera-wasm
2
+
3
+ WebAssembly of Lindera
4
+
5
+ ![Screenshot from 2025-09-13 23-05-49](https://github.com/user-attachments/assets/a6ca165a-825c-4260-ba52-d76cd262a21f)
6
+
7
+ ## Demo Application
8
+
9
+ - <https://lindera.github.io/lindera-wasm/>
10
+
11
+ ## npm
12
+
13
+ ### Web
14
+
15
+ - <https://www.npmjs.com/package/lindera-wasm-web-cjk>
16
+ Lindera WASM with CJK dictionaries (IPADIC, ko-dic, CC-CEDICT) for Web
17
+
18
+ - <https://www.npmjs.com/package/lindera-wasm-web-ipadic>
19
+ Lindera WASM with Japanese dictionary (IPADIC) for Web
20
+
21
+ - <https://www.npmjs.com/package/lindera-wasm-web-unidic>
22
+ Lindera WASM with Japanese dictionary (UniDic) for Web
23
+
24
+ - <https://www.npmjs.com/package/lindera-wasm-web-ko-dic>
25
+ Lindera WASM with Korean dictionary (ko-dic) for Web
26
+
27
+ - <https://www.npmjs.com/package/lindera-wasm-web-cc-cedict>
28
+ Lindera WASM with Chinese dictionary (CC-CEDICT) for Web
29
+
30
+ ### Node.js
31
+
32
+ - <https://www.npmjs.com/package/lindera-wasm-nodejs-cjk>
33
+ Lindera WASM with CJK dictionaries (IPADIC, ko-dic, CC-CEDICT) for Node.js
34
+
35
+ - <https://www.npmjs.com/package/lindera-wasm-nodejs-ipadic>
36
+ Lindera WASM with Japanese dictionary (IPADIC) for Node.js
37
+
38
+ - <https://www.npmjs.com/package/lindera-wasm-nodejs-unidic>
39
+ Lindera WASM with Japanese dictionary (UniDic) for Node.js
40
+
41
+ - <https://www.npmjs.com/package/lindera-wasm-nodejs-ko-dic>
42
+ Lindera WASM with Korean dictionary (ko-dic) for Node.js
43
+
44
+ - <https://www.npmjs.com/package/lindera-wasm-nodejs-cc-cedict>
45
+ Lindera WASM with Chinese dictionary (CC-CEDICT) for Node.js
46
+
47
+ ## Usage
48
+
49
+ init the wasm module before construct `TokenizerBuilder`:
50
+
51
+ ```ts
52
+ import __wbg_init, { TokenizerBuilder } from 'lindera-wasm'
53
+
54
+ __wbg_init.then(() => {
55
+ const builder = new TokenizerBuilder()
56
+ //...
57
+ })
58
+ ```
59
+
60
+ ### for [Vite](https://vite.dev/) base project
61
+
62
+ You should exclude this package in the `optimizeDeps`:
63
+
64
+ ```ts
65
+ // vite.config.js
66
+ import { defineConfig } from 'vite'
67
+
68
+ export default defineConfig({
69
+ optimizeDeps: {
70
+ exclude: [
71
+ "lindera-wasm"
72
+ ]
73
+ },
74
+ })
75
+ ```
76
+
77
+ ### for Browser extension development
78
+
79
+ Set the `cors` config in vite.config.js
80
+
81
+ ```ts
82
+ // vite.config.js
83
+ import { defineConfig } from 'vite'
84
+
85
+ export default defineConfig({
86
+ server: {
87
+ cors: {
88
+ origin: [
89
+ /chrome-extension:\/\//,
90
+ ],
91
+ },
92
+ },
93
+ })
94
+ ```
95
+
96
+ and set the `content_security_policy` to contains `wasm-unsafe-eval` in manifest.json:
97
+
98
+ ```json
99
+ // manifest.json
100
+ "content_security_policy": {
101
+ "extension_pages": "script-src 'self' 'wasm-unsafe-eval';"
102
+ }
103
+ ```
104
+
105
+ ## Development
106
+
107
+ ### Install project dependencies
108
+
109
+ - wasm-pack : <https://rustwasm.github.io/wasm-pack/installer/>
110
+
111
+ ### Setup repository
112
+
113
+ ```shell
114
+ # Clone lindera-py project repository
115
+ % git clone git@github.com:lindera/lindera-wasm.git
116
+ % cd lindera-wasm
117
+ ```
118
+
119
+ ### Build project
120
+
121
+ ```shell
122
+ % wasm-pack build --release --features=cjk --target=bundler
123
+ ```
124
+
125
+ ### Build example web application
126
+
127
+ ```shell
128
+ % cd lindera-wasm && npm install && npm run build && cp index.html dist/index.html
129
+ ```
130
+
131
+ ### Run example web application
132
+
133
+ ```shell
134
+ % cd lindera-wasm && npm run start
135
+ ```
@@ -0,0 +1,304 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Gets the version of the lindera-wasm library.
5
+ *
6
+ * # Returns
7
+ *
8
+ * The version string of the library (e.g., "1.0.0").
9
+ *
10
+ * # Examples
11
+ *
12
+ * ```javascript
13
+ * import { getVersion } from 'lindera-wasm';
14
+ * console.log(getVersion()); // "1.0.0"
15
+ * ```
16
+ */
17
+ export function getVersion(): string;
18
+ /**
19
+ * A tokenizer for morphological analysis.
20
+ *
21
+ * The `Tokenizer` performs text tokenization based on the configuration
22
+ * provided by [`TokenizerBuilder`].
23
+ *
24
+ * # Examples
25
+ *
26
+ * ```javascript
27
+ * const builder = new TokenizerBuilder();
28
+ * builder.setDictionary("embedded://ipadic");
29
+ * builder.setMode("normal");
30
+ *
31
+ * const tokenizer = builder.build();
32
+ * const tokens = tokenizer.tokenize("関西国際空港");
33
+ * console.log(tokens);
34
+ * // Output: [
35
+ * // { surface: "関西国際空港", ... },
36
+ * // ...
37
+ * // ]
38
+ * ```
39
+ */
40
+ export class Tokenizer {
41
+ private constructor();
42
+ free(): void;
43
+ [Symbol.dispose](): void;
44
+ /**
45
+ * Tokenizes the input text.
46
+ *
47
+ * Analyzes the input text and returns an array of token objects. Each token
48
+ * contains information such as surface form, part-of-speech tags, reading, etc.
49
+ * Field names in the returned objects are in camelCase.
50
+ *
51
+ * # Parameters
52
+ *
53
+ * - `input_text`: The text to tokenize.
54
+ *
55
+ * # Returns
56
+ *
57
+ * A JavaScript array of token objects. Each token object contains:
58
+ * - `surface`: The surface form of the token
59
+ * - `pos`: Part-of-speech tags
60
+ * - Additional language-specific fields
61
+ *
62
+ * # Errors
63
+ *
64
+ * Returns an error if tokenization fails.
65
+ *
66
+ * # Examples
67
+ *
68
+ * ```javascript
69
+ * const tokens = tokenizer.tokenize("東京都に行く");
70
+ * tokens.forEach(token => {
71
+ * console.log(token.surface, token.pos);
72
+ * });
73
+ * ```
74
+ */
75
+ tokenize(input_text: string): any;
76
+ }
77
+ /**
78
+ * Builder for creating a [`Tokenizer`] instance.
79
+ *
80
+ * `TokenizerBuilder` provides a fluent API for configuring and building a tokenizer
81
+ * with various options such as dictionary selection, tokenization mode, character filters,
82
+ * and token filters.
83
+ *
84
+ * # Examples
85
+ *
86
+ * ```javascript
87
+ * const builder = new TokenizerBuilder();
88
+ * builder.setDictionary("embedded://ipadic");
89
+ * builder.setMode("normal");
90
+ * builder.setKeepWhitespace(false);
91
+ * builder.appendCharacterFilter("unicode_normalize", { "kind": "nfkc" });
92
+ * builder.appendTokenFilter("lowercase");
93
+ *
94
+ * const tokenizer = builder.build();
95
+ * ```
96
+ */
97
+ export class TokenizerBuilder {
98
+ free(): void;
99
+ [Symbol.dispose](): void;
100
+ /**
101
+ * Creates a new `TokenizerBuilder` instance.
102
+ *
103
+ * # Returns
104
+ *
105
+ * A new `TokenizerBuilder` instance.
106
+ *
107
+ * # Errors
108
+ *
109
+ * Returns an error if the builder cannot be initialized.
110
+ *
111
+ * # Examples
112
+ *
113
+ * ```javascript
114
+ * const builder = new TokenizerBuilder();
115
+ * ```
116
+ */
117
+ constructor();
118
+ /**
119
+ * Builds and returns a configured [`Tokenizer`] instance.
120
+ *
121
+ * This method consumes the builder and creates the final tokenizer with all
122
+ * configured settings.
123
+ *
124
+ * # Returns
125
+ *
126
+ * A configured `Tokenizer` instance.
127
+ *
128
+ * # Errors
129
+ *
130
+ * Returns an error if the tokenizer cannot be built with the current configuration.
131
+ *
132
+ * # Examples
133
+ *
134
+ * ```javascript
135
+ * const builder = new TokenizerBuilder();
136
+ * builder.setDictionary("embedded://ipadic");
137
+ * const tokenizer = builder.build();
138
+ * ```
139
+ */
140
+ build(): Tokenizer;
141
+ /**
142
+ * Sets the tokenization mode.
143
+ *
144
+ * # Parameters
145
+ *
146
+ * - `mode`: The tokenization mode. Valid values are:
147
+ * - `"normal"`: Standard tokenization
148
+ * - `"decompose"`: Decomposes compound words into their components
149
+ *
150
+ * # Errors
151
+ *
152
+ * Returns an error if the mode string is invalid.
153
+ *
154
+ * # Examples
155
+ *
156
+ * ```javascript
157
+ * builder.setMode("normal");
158
+ * // or
159
+ * builder.setMode("decompose");
160
+ * ```
161
+ */
162
+ setMode(mode: string): void;
163
+ /**
164
+ * Sets the dictionary to use for tokenization.
165
+ *
166
+ * # Parameters
167
+ *
168
+ * - `uri`: The dictionary URI. Valid embedded dictionaries are:
169
+ * - `"embedded://ipadic"`: Japanese IPADIC dictionary
170
+ * - `"embedded://unidic"`: Japanese UniDic dictionary
171
+ * - `"embedded://ko-dic"`: Korean ko-dic dictionary
172
+ * - `"embedded://cc-cedict"`: Chinese CC-CEDICT dictionary
173
+ *
174
+ * # Examples
175
+ *
176
+ * ```javascript
177
+ * builder.setDictionary("embedded://ipadic");
178
+ * ```
179
+ */
180
+ setDictionary(uri: string): void;
181
+ /**
182
+ * Sets a user-defined dictionary.
183
+ *
184
+ * User dictionaries allow you to add custom words and their properties
185
+ * to supplement the main dictionary.
186
+ *
187
+ * # Parameters
188
+ *
189
+ * - `uri`: The URI to the user dictionary file.
190
+ *
191
+ * # Examples
192
+ *
193
+ * ```javascript
194
+ * builder.setUserDictionary("path/to/user_dict.csv");
195
+ * ```
196
+ */
197
+ setUserDictionary(uri: string): void;
198
+ /**
199
+ * Sets whether to keep whitespace tokens in the output.
200
+ *
201
+ * # Parameters
202
+ *
203
+ * - `keep`: If `true`, whitespace tokens are preserved; if `false`, they are removed.
204
+ *
205
+ * # Examples
206
+ *
207
+ * ```javascript
208
+ * builder.setKeepWhitespace(false); // Remove whitespace tokens
209
+ * // or
210
+ * builder.setKeepWhitespace(true); // Keep whitespace tokens
211
+ * ```
212
+ */
213
+ setKeepWhitespace(keep: boolean): void;
214
+ /**
215
+ * Appends a character filter to the tokenization pipeline.
216
+ *
217
+ * Character filters transform the input text before tokenization.
218
+ *
219
+ * # Parameters
220
+ *
221
+ * - `name`: The name of the character filter (e.g., `"unicode_normalize"`).
222
+ * - `args`: A JavaScript object containing filter-specific arguments.
223
+ *
224
+ * # Errors
225
+ *
226
+ * Returns an error if the arguments cannot be parsed.
227
+ *
228
+ * # Examples
229
+ *
230
+ * ```javascript
231
+ * builder.appendCharacterFilter("unicode_normalize", { "kind": "nfkc" });
232
+ * ```
233
+ */
234
+ appendCharacterFilter(name: string, args: any): void;
235
+ /**
236
+ * Appends a token filter to the tokenization pipeline.
237
+ *
238
+ * Token filters transform or filter the tokens after tokenization.
239
+ *
240
+ * # Parameters
241
+ *
242
+ * - `name`: The name of the token filter (e.g., `"lowercase"`, `"japanese_number"`).
243
+ * - `args`: A JavaScript object containing filter-specific arguments.
244
+ *
245
+ * # Errors
246
+ *
247
+ * Returns an error if the arguments cannot be parsed.
248
+ *
249
+ * # Examples
250
+ *
251
+ * ```javascript
252
+ * builder.appendTokenFilter("lowercase");
253
+ * builder.appendTokenFilter("japanese_number", { "tags": ["名詞,数"] });
254
+ * ```
255
+ */
256
+ appendTokenFilter(name: string, args: any): void;
257
+ }
258
+
259
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
260
+
261
+ export interface InitOutput {
262
+ readonly memory: WebAssembly.Memory;
263
+ readonly getVersion: () => [number, number];
264
+ readonly __wbg_tokenizerbuilder_free: (a: number, b: number) => void;
265
+ readonly tokenizerbuilder_new: () => [number, number, number];
266
+ readonly tokenizerbuilder_build: (a: number) => [number, number, number];
267
+ readonly tokenizerbuilder_setMode: (a: number, b: number, c: number) => [number, number];
268
+ readonly tokenizerbuilder_setDictionary: (a: number, b: number, c: number) => [number, number];
269
+ readonly tokenizerbuilder_setUserDictionary: (a: number, b: number, c: number) => [number, number];
270
+ readonly tokenizerbuilder_setKeepWhitespace: (a: number, b: number) => [number, number];
271
+ readonly tokenizerbuilder_appendCharacterFilter: (a: number, b: number, c: number, d: any) => [number, number];
272
+ readonly tokenizerbuilder_appendTokenFilter: (a: number, b: number, c: number, d: any) => [number, number];
273
+ readonly __wbg_tokenizer_free: (a: number, b: number) => void;
274
+ readonly tokenizer_tokenize: (a: number, b: number, c: number) => [number, number, number];
275
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
276
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
277
+ readonly __wbindgen_exn_store: (a: number) => void;
278
+ readonly __externref_table_alloc: () => number;
279
+ readonly __wbindgen_export_4: WebAssembly.Table;
280
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
281
+ readonly __externref_table_dealloc: (a: number) => void;
282
+ readonly __wbindgen_start: () => void;
283
+ }
284
+
285
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
286
+ /**
287
+ * Instantiates the given `module`, which can either be bytes or
288
+ * a precompiled `WebAssembly.Module`.
289
+ *
290
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
291
+ *
292
+ * @returns {InitOutput}
293
+ */
294
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
295
+
296
+ /**
297
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
298
+ * for everything else, calls `WebAssembly.instantiate` directly.
299
+ *
300
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
301
+ *
302
+ * @returns {Promise<InitOutput>}
303
+ */
304
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,886 @@
1
+ let wasm;
2
+
3
+ let cachedUint8ArrayMemory0 = null;
4
+
5
+ function getUint8ArrayMemory0() {
6
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
+ }
9
+ return cachedUint8ArrayMemory0;
10
+ }
11
+
12
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
+
14
+ cachedTextDecoder.decode();
15
+
16
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
+ let numBytesDecoded = 0;
18
+ function decodeText(ptr, len) {
19
+ numBytesDecoded += len;
20
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
+ cachedTextDecoder.decode();
23
+ numBytesDecoded = len;
24
+ }
25
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ function getStringFromWasm0(ptr, len) {
29
+ ptr = ptr >>> 0;
30
+ return decodeText(ptr, len);
31
+ }
32
+
33
+ let WASM_VECTOR_LEN = 0;
34
+
35
+ const cachedTextEncoder = new TextEncoder();
36
+
37
+ if (!('encodeInto' in cachedTextEncoder)) {
38
+ cachedTextEncoder.encodeInto = function (arg, view) {
39
+ const buf = cachedTextEncoder.encode(arg);
40
+ view.set(buf);
41
+ return {
42
+ read: arg.length,
43
+ written: buf.length
44
+ };
45
+ }
46
+ }
47
+
48
+ function passStringToWasm0(arg, malloc, realloc) {
49
+
50
+ if (realloc === undefined) {
51
+ const buf = cachedTextEncoder.encode(arg);
52
+ const ptr = malloc(buf.length, 1) >>> 0;
53
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
54
+ WASM_VECTOR_LEN = buf.length;
55
+ return ptr;
56
+ }
57
+
58
+ let len = arg.length;
59
+ let ptr = malloc(len, 1) >>> 0;
60
+
61
+ const mem = getUint8ArrayMemory0();
62
+
63
+ let offset = 0;
64
+
65
+ for (; offset < len; offset++) {
66
+ const code = arg.charCodeAt(offset);
67
+ if (code > 0x7F) break;
68
+ mem[ptr + offset] = code;
69
+ }
70
+
71
+ if (offset !== len) {
72
+ if (offset !== 0) {
73
+ arg = arg.slice(offset);
74
+ }
75
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
76
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
77
+ const ret = cachedTextEncoder.encodeInto(arg, view);
78
+
79
+ offset += ret.written;
80
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
81
+ }
82
+
83
+ WASM_VECTOR_LEN = offset;
84
+ return ptr;
85
+ }
86
+
87
+ let cachedDataViewMemory0 = null;
88
+
89
+ function getDataViewMemory0() {
90
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
91
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
92
+ }
93
+ return cachedDataViewMemory0;
94
+ }
95
+
96
+ function addToExternrefTable0(obj) {
97
+ const idx = wasm.__externref_table_alloc();
98
+ wasm.__wbindgen_export_4.set(idx, obj);
99
+ return idx;
100
+ }
101
+
102
+ function handleError(f, args) {
103
+ try {
104
+ return f.apply(this, args);
105
+ } catch (e) {
106
+ const idx = addToExternrefTable0(e);
107
+ wasm.__wbindgen_exn_store(idx);
108
+ }
109
+ }
110
+
111
+ function getArrayU8FromWasm0(ptr, len) {
112
+ ptr = ptr >>> 0;
113
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
114
+ }
115
+
116
+ function isLikeNone(x) {
117
+ return x === undefined || x === null;
118
+ }
119
+
120
+ function debugString(val) {
121
+ // primitive types
122
+ const type = typeof val;
123
+ if (type == 'number' || type == 'boolean' || val == null) {
124
+ return `${val}`;
125
+ }
126
+ if (type == 'string') {
127
+ return `"${val}"`;
128
+ }
129
+ if (type == 'symbol') {
130
+ const description = val.description;
131
+ if (description == null) {
132
+ return 'Symbol';
133
+ } else {
134
+ return `Symbol(${description})`;
135
+ }
136
+ }
137
+ if (type == 'function') {
138
+ const name = val.name;
139
+ if (typeof name == 'string' && name.length > 0) {
140
+ return `Function(${name})`;
141
+ } else {
142
+ return 'Function';
143
+ }
144
+ }
145
+ // objects
146
+ if (Array.isArray(val)) {
147
+ const length = val.length;
148
+ let debug = '[';
149
+ if (length > 0) {
150
+ debug += debugString(val[0]);
151
+ }
152
+ for(let i = 1; i < length; i++) {
153
+ debug += ', ' + debugString(val[i]);
154
+ }
155
+ debug += ']';
156
+ return debug;
157
+ }
158
+ // Test for built-in
159
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
160
+ let className;
161
+ if (builtInMatches && builtInMatches.length > 1) {
162
+ className = builtInMatches[1];
163
+ } else {
164
+ // Failed to match the standard '[object ClassName]'
165
+ return toString.call(val);
166
+ }
167
+ if (className == 'Object') {
168
+ // we're a user defined class or Object
169
+ // JSON.stringify avoids problems with cycles, and is generally much
170
+ // easier than looping through ownProperties of `val`.
171
+ try {
172
+ return 'Object(' + JSON.stringify(val) + ')';
173
+ } catch (_) {
174
+ return 'Object';
175
+ }
176
+ }
177
+ // errors
178
+ if (val instanceof Error) {
179
+ return `${val.name}: ${val.message}\n${val.stack}`;
180
+ }
181
+ // TODO we could test for more things here, like `Set`s and `Map`s.
182
+ return className;
183
+ }
184
+ /**
185
+ * Gets the version of the lindera-wasm library.
186
+ *
187
+ * # Returns
188
+ *
189
+ * The version string of the library (e.g., "1.0.0").
190
+ *
191
+ * # Examples
192
+ *
193
+ * ```javascript
194
+ * import { getVersion } from 'lindera-wasm';
195
+ * console.log(getVersion()); // "1.0.0"
196
+ * ```
197
+ * @returns {string}
198
+ */
199
+ export function getVersion() {
200
+ let deferred1_0;
201
+ let deferred1_1;
202
+ try {
203
+ const ret = wasm.getVersion();
204
+ deferred1_0 = ret[0];
205
+ deferred1_1 = ret[1];
206
+ return getStringFromWasm0(ret[0], ret[1]);
207
+ } finally {
208
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
209
+ }
210
+ }
211
+
212
+ function takeFromExternrefTable0(idx) {
213
+ const value = wasm.__wbindgen_export_4.get(idx);
214
+ wasm.__externref_table_dealloc(idx);
215
+ return value;
216
+ }
217
+
218
+ const TokenizerFinalization = (typeof FinalizationRegistry === 'undefined')
219
+ ? { register: () => {}, unregister: () => {} }
220
+ : new FinalizationRegistry(ptr => wasm.__wbg_tokenizer_free(ptr >>> 0, 1));
221
+ /**
222
+ * A tokenizer for morphological analysis.
223
+ *
224
+ * The `Tokenizer` performs text tokenization based on the configuration
225
+ * provided by [`TokenizerBuilder`].
226
+ *
227
+ * # Examples
228
+ *
229
+ * ```javascript
230
+ * const builder = new TokenizerBuilder();
231
+ * builder.setDictionary("embedded://ipadic");
232
+ * builder.setMode("normal");
233
+ *
234
+ * const tokenizer = builder.build();
235
+ * const tokens = tokenizer.tokenize("関西国際空港");
236
+ * console.log(tokens);
237
+ * // Output: [
238
+ * // { surface: "関西国際空港", ... },
239
+ * // ...
240
+ * // ]
241
+ * ```
242
+ */
243
+ export class Tokenizer {
244
+
245
+ static __wrap(ptr) {
246
+ ptr = ptr >>> 0;
247
+ const obj = Object.create(Tokenizer.prototype);
248
+ obj.__wbg_ptr = ptr;
249
+ TokenizerFinalization.register(obj, obj.__wbg_ptr, obj);
250
+ return obj;
251
+ }
252
+
253
+ __destroy_into_raw() {
254
+ const ptr = this.__wbg_ptr;
255
+ this.__wbg_ptr = 0;
256
+ TokenizerFinalization.unregister(this);
257
+ return ptr;
258
+ }
259
+
260
+ free() {
261
+ const ptr = this.__destroy_into_raw();
262
+ wasm.__wbg_tokenizer_free(ptr, 0);
263
+ }
264
+ /**
265
+ * Tokenizes the input text.
266
+ *
267
+ * Analyzes the input text and returns an array of token objects. Each token
268
+ * contains information such as surface form, part-of-speech tags, reading, etc.
269
+ * Field names in the returned objects are in camelCase.
270
+ *
271
+ * # Parameters
272
+ *
273
+ * - `input_text`: The text to tokenize.
274
+ *
275
+ * # Returns
276
+ *
277
+ * A JavaScript array of token objects. Each token object contains:
278
+ * - `surface`: The surface form of the token
279
+ * - `pos`: Part-of-speech tags
280
+ * - Additional language-specific fields
281
+ *
282
+ * # Errors
283
+ *
284
+ * Returns an error if tokenization fails.
285
+ *
286
+ * # Examples
287
+ *
288
+ * ```javascript
289
+ * const tokens = tokenizer.tokenize("東京都に行く");
290
+ * tokens.forEach(token => {
291
+ * console.log(token.surface, token.pos);
292
+ * });
293
+ * ```
294
+ * @param {string} input_text
295
+ * @returns {any}
296
+ */
297
+ tokenize(input_text) {
298
+ const ptr0 = passStringToWasm0(input_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
299
+ const len0 = WASM_VECTOR_LEN;
300
+ const ret = wasm.tokenizer_tokenize(this.__wbg_ptr, ptr0, len0);
301
+ if (ret[2]) {
302
+ throw takeFromExternrefTable0(ret[1]);
303
+ }
304
+ return takeFromExternrefTable0(ret[0]);
305
+ }
306
+ }
307
+ if (Symbol.dispose) Tokenizer.prototype[Symbol.dispose] = Tokenizer.prototype.free;
308
+
309
+ const TokenizerBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
310
+ ? { register: () => {}, unregister: () => {} }
311
+ : new FinalizationRegistry(ptr => wasm.__wbg_tokenizerbuilder_free(ptr >>> 0, 1));
312
+ /**
313
+ * Builder for creating a [`Tokenizer`] instance.
314
+ *
315
+ * `TokenizerBuilder` provides a fluent API for configuring and building a tokenizer
316
+ * with various options such as dictionary selection, tokenization mode, character filters,
317
+ * and token filters.
318
+ *
319
+ * # Examples
320
+ *
321
+ * ```javascript
322
+ * const builder = new TokenizerBuilder();
323
+ * builder.setDictionary("embedded://ipadic");
324
+ * builder.setMode("normal");
325
+ * builder.setKeepWhitespace(false);
326
+ * builder.appendCharacterFilter("unicode_normalize", { "kind": "nfkc" });
327
+ * builder.appendTokenFilter("lowercase");
328
+ *
329
+ * const tokenizer = builder.build();
330
+ * ```
331
+ */
332
+ export class TokenizerBuilder {
333
+
334
+ __destroy_into_raw() {
335
+ const ptr = this.__wbg_ptr;
336
+ this.__wbg_ptr = 0;
337
+ TokenizerBuilderFinalization.unregister(this);
338
+ return ptr;
339
+ }
340
+
341
+ free() {
342
+ const ptr = this.__destroy_into_raw();
343
+ wasm.__wbg_tokenizerbuilder_free(ptr, 0);
344
+ }
345
+ /**
346
+ * Creates a new `TokenizerBuilder` instance.
347
+ *
348
+ * # Returns
349
+ *
350
+ * A new `TokenizerBuilder` instance.
351
+ *
352
+ * # Errors
353
+ *
354
+ * Returns an error if the builder cannot be initialized.
355
+ *
356
+ * # Examples
357
+ *
358
+ * ```javascript
359
+ * const builder = new TokenizerBuilder();
360
+ * ```
361
+ */
362
+ constructor() {
363
+ const ret = wasm.tokenizerbuilder_new();
364
+ if (ret[2]) {
365
+ throw takeFromExternrefTable0(ret[1]);
366
+ }
367
+ this.__wbg_ptr = ret[0] >>> 0;
368
+ TokenizerBuilderFinalization.register(this, this.__wbg_ptr, this);
369
+ return this;
370
+ }
371
+ /**
372
+ * Builds and returns a configured [`Tokenizer`] instance.
373
+ *
374
+ * This method consumes the builder and creates the final tokenizer with all
375
+ * configured settings.
376
+ *
377
+ * # Returns
378
+ *
379
+ * A configured `Tokenizer` instance.
380
+ *
381
+ * # Errors
382
+ *
383
+ * Returns an error if the tokenizer cannot be built with the current configuration.
384
+ *
385
+ * # Examples
386
+ *
387
+ * ```javascript
388
+ * const builder = new TokenizerBuilder();
389
+ * builder.setDictionary("embedded://ipadic");
390
+ * const tokenizer = builder.build();
391
+ * ```
392
+ * @returns {Tokenizer}
393
+ */
394
+ build() {
395
+ const ptr = this.__destroy_into_raw();
396
+ const ret = wasm.tokenizerbuilder_build(ptr);
397
+ if (ret[2]) {
398
+ throw takeFromExternrefTable0(ret[1]);
399
+ }
400
+ return Tokenizer.__wrap(ret[0]);
401
+ }
402
+ /**
403
+ * Sets the tokenization mode.
404
+ *
405
+ * # Parameters
406
+ *
407
+ * - `mode`: The tokenization mode. Valid values are:
408
+ * - `"normal"`: Standard tokenization
409
+ * - `"decompose"`: Decomposes compound words into their components
410
+ *
411
+ * # Errors
412
+ *
413
+ * Returns an error if the mode string is invalid.
414
+ *
415
+ * # Examples
416
+ *
417
+ * ```javascript
418
+ * builder.setMode("normal");
419
+ * // or
420
+ * builder.setMode("decompose");
421
+ * ```
422
+ * @param {string} mode
423
+ */
424
+ setMode(mode) {
425
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
426
+ const len0 = WASM_VECTOR_LEN;
427
+ const ret = wasm.tokenizerbuilder_setMode(this.__wbg_ptr, ptr0, len0);
428
+ if (ret[1]) {
429
+ throw takeFromExternrefTable0(ret[0]);
430
+ }
431
+ }
432
+ /**
433
+ * Sets the dictionary to use for tokenization.
434
+ *
435
+ * # Parameters
436
+ *
437
+ * - `uri`: The dictionary URI. Valid embedded dictionaries are:
438
+ * - `"embedded://ipadic"`: Japanese IPADIC dictionary
439
+ * - `"embedded://unidic"`: Japanese UniDic dictionary
440
+ * - `"embedded://ko-dic"`: Korean ko-dic dictionary
441
+ * - `"embedded://cc-cedict"`: Chinese CC-CEDICT dictionary
442
+ *
443
+ * # Examples
444
+ *
445
+ * ```javascript
446
+ * builder.setDictionary("embedded://ipadic");
447
+ * ```
448
+ * @param {string} uri
449
+ */
450
+ setDictionary(uri) {
451
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
452
+ const len0 = WASM_VECTOR_LEN;
453
+ const ret = wasm.tokenizerbuilder_setDictionary(this.__wbg_ptr, ptr0, len0);
454
+ if (ret[1]) {
455
+ throw takeFromExternrefTable0(ret[0]);
456
+ }
457
+ }
458
+ /**
459
+ * Sets a user-defined dictionary.
460
+ *
461
+ * User dictionaries allow you to add custom words and their properties
462
+ * to supplement the main dictionary.
463
+ *
464
+ * # Parameters
465
+ *
466
+ * - `uri`: The URI to the user dictionary file.
467
+ *
468
+ * # Examples
469
+ *
470
+ * ```javascript
471
+ * builder.setUserDictionary("path/to/user_dict.csv");
472
+ * ```
473
+ * @param {string} uri
474
+ */
475
+ setUserDictionary(uri) {
476
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
477
+ const len0 = WASM_VECTOR_LEN;
478
+ const ret = wasm.tokenizerbuilder_setUserDictionary(this.__wbg_ptr, ptr0, len0);
479
+ if (ret[1]) {
480
+ throw takeFromExternrefTable0(ret[0]);
481
+ }
482
+ }
483
+ /**
484
+ * Sets whether to keep whitespace tokens in the output.
485
+ *
486
+ * # Parameters
487
+ *
488
+ * - `keep`: If `true`, whitespace tokens are preserved; if `false`, they are removed.
489
+ *
490
+ * # Examples
491
+ *
492
+ * ```javascript
493
+ * builder.setKeepWhitespace(false); // Remove whitespace tokens
494
+ * // or
495
+ * builder.setKeepWhitespace(true); // Keep whitespace tokens
496
+ * ```
497
+ * @param {boolean} keep
498
+ */
499
+ setKeepWhitespace(keep) {
500
+ const ret = wasm.tokenizerbuilder_setKeepWhitespace(this.__wbg_ptr, keep);
501
+ if (ret[1]) {
502
+ throw takeFromExternrefTable0(ret[0]);
503
+ }
504
+ }
505
+ /**
506
+ * Appends a character filter to the tokenization pipeline.
507
+ *
508
+ * Character filters transform the input text before tokenization.
509
+ *
510
+ * # Parameters
511
+ *
512
+ * - `name`: The name of the character filter (e.g., `"unicode_normalize"`).
513
+ * - `args`: A JavaScript object containing filter-specific arguments.
514
+ *
515
+ * # Errors
516
+ *
517
+ * Returns an error if the arguments cannot be parsed.
518
+ *
519
+ * # Examples
520
+ *
521
+ * ```javascript
522
+ * builder.appendCharacterFilter("unicode_normalize", { "kind": "nfkc" });
523
+ * ```
524
+ * @param {string} name
525
+ * @param {any} args
526
+ */
527
+ appendCharacterFilter(name, args) {
528
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
529
+ const len0 = WASM_VECTOR_LEN;
530
+ const ret = wasm.tokenizerbuilder_appendCharacterFilter(this.__wbg_ptr, ptr0, len0, args);
531
+ if (ret[1]) {
532
+ throw takeFromExternrefTable0(ret[0]);
533
+ }
534
+ }
535
+ /**
536
+ * Appends a token filter to the tokenization pipeline.
537
+ *
538
+ * Token filters transform or filter the tokens after tokenization.
539
+ *
540
+ * # Parameters
541
+ *
542
+ * - `name`: The name of the token filter (e.g., `"lowercase"`, `"japanese_number"`).
543
+ * - `args`: A JavaScript object containing filter-specific arguments.
544
+ *
545
+ * # Errors
546
+ *
547
+ * Returns an error if the arguments cannot be parsed.
548
+ *
549
+ * # Examples
550
+ *
551
+ * ```javascript
552
+ * builder.appendTokenFilter("lowercase");
553
+ * builder.appendTokenFilter("japanese_number", { "tags": ["名詞,数"] });
554
+ * ```
555
+ * @param {string} name
556
+ * @param {any} args
557
+ */
558
+ appendTokenFilter(name, args) {
559
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
560
+ const len0 = WASM_VECTOR_LEN;
561
+ const ret = wasm.tokenizerbuilder_appendTokenFilter(this.__wbg_ptr, ptr0, len0, args);
562
+ if (ret[1]) {
563
+ throw takeFromExternrefTable0(ret[0]);
564
+ }
565
+ }
566
+ }
567
+ if (Symbol.dispose) TokenizerBuilder.prototype[Symbol.dispose] = TokenizerBuilder.prototype.free;
568
+
569
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
570
+
571
+ async function __wbg_load(module, imports) {
572
+ if (typeof Response === 'function' && module instanceof Response) {
573
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
574
+ try {
575
+ return await WebAssembly.instantiateStreaming(module, imports);
576
+
577
+ } catch (e) {
578
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
579
+
580
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
581
+ 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);
582
+
583
+ } else {
584
+ throw e;
585
+ }
586
+ }
587
+ }
588
+
589
+ const bytes = await module.arrayBuffer();
590
+ return await WebAssembly.instantiate(bytes, imports);
591
+
592
+ } else {
593
+ const instance = await WebAssembly.instantiate(module, imports);
594
+
595
+ if (instance instanceof WebAssembly.Instance) {
596
+ return { instance, module };
597
+
598
+ } else {
599
+ return instance;
600
+ }
601
+ }
602
+ }
603
+
604
+ function __wbg_get_imports() {
605
+ const imports = {};
606
+ imports.wbg = {};
607
+ imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
608
+ const ret = Error(getStringFromWasm0(arg0, arg1));
609
+ return ret;
610
+ };
611
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
612
+ const ret = String(arg1);
613
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
614
+ const len1 = WASM_VECTOR_LEN;
615
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
616
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
617
+ };
618
+ imports.wbg.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
619
+ const ret = arg0.call(arg1);
620
+ return ret;
621
+ }, arguments) };
622
+ imports.wbg.__wbg_done_75ed0ee6dd243d9d = function(arg0) {
623
+ const ret = arg0.done;
624
+ return ret;
625
+ };
626
+ imports.wbg.__wbg_entries_2be2f15bd5554996 = function(arg0) {
627
+ const ret = Object.entries(arg0);
628
+ return ret;
629
+ };
630
+ imports.wbg.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
631
+ const ret = arg0[arg1 >>> 0];
632
+ return ret;
633
+ };
634
+ imports.wbg.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
635
+ const ret = Reflect.get(arg0, arg1);
636
+ return ret;
637
+ }, arguments) };
638
+ imports.wbg.__wbg_instanceof_ArrayBuffer_67f3012529f6a2dd = function(arg0) {
639
+ let result;
640
+ try {
641
+ result = arg0 instanceof ArrayBuffer;
642
+ } catch (_) {
643
+ result = false;
644
+ }
645
+ const ret = result;
646
+ return ret;
647
+ };
648
+ imports.wbg.__wbg_instanceof_Map_ebb01a5b6b5ffd0b = function(arg0) {
649
+ let result;
650
+ try {
651
+ result = arg0 instanceof Map;
652
+ } catch (_) {
653
+ result = false;
654
+ }
655
+ const ret = result;
656
+ return ret;
657
+ };
658
+ imports.wbg.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
659
+ let result;
660
+ try {
661
+ result = arg0 instanceof Uint8Array;
662
+ } catch (_) {
663
+ result = false;
664
+ }
665
+ const ret = result;
666
+ return ret;
667
+ };
668
+ imports.wbg.__wbg_isArray_030cce220591fb41 = function(arg0) {
669
+ const ret = Array.isArray(arg0);
670
+ return ret;
671
+ };
672
+ imports.wbg.__wbg_isSafeInteger_1c0d1af5542e102a = function(arg0) {
673
+ const ret = Number.isSafeInteger(arg0);
674
+ return ret;
675
+ };
676
+ imports.wbg.__wbg_iterator_f370b34483c71a1c = function() {
677
+ const ret = Symbol.iterator;
678
+ return ret;
679
+ };
680
+ imports.wbg.__wbg_length_186546c51cd61acd = function(arg0) {
681
+ const ret = arg0.length;
682
+ return ret;
683
+ };
684
+ imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
685
+ const ret = arg0.length;
686
+ return ret;
687
+ };
688
+ imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
689
+ const ret = new Object();
690
+ return ret;
691
+ };
692
+ imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
693
+ const ret = new Array();
694
+ return ret;
695
+ };
696
+ imports.wbg.__wbg_new_638ebfaedbf32a5e = function(arg0) {
697
+ const ret = new Uint8Array(arg0);
698
+ return ret;
699
+ };
700
+ imports.wbg.__wbg_next_5b3530e612fde77d = function(arg0) {
701
+ const ret = arg0.next;
702
+ return ret;
703
+ };
704
+ imports.wbg.__wbg_next_692e82279131b03c = function() { return handleError(function (arg0) {
705
+ const ret = arg0.next();
706
+ return ret;
707
+ }, arguments) };
708
+ imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
709
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
710
+ };
711
+ imports.wbg.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
712
+ const ret = arg0.push(arg1);
713
+ return ret;
714
+ };
715
+ imports.wbg.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
716
+ const ret = Reflect.set(arg0, arg1, arg2);
717
+ return ret;
718
+ }, arguments) };
719
+ imports.wbg.__wbg_value_dd9372230531eade = function(arg0) {
720
+ const ret = arg0.value;
721
+ return ret;
722
+ };
723
+ imports.wbg.__wbg_wbindgenbigintgetasi64_ac743ece6ab9bba1 = function(arg0, arg1) {
724
+ const v = arg1;
725
+ const ret = typeof(v) === 'bigint' ? v : undefined;
726
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
727
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
728
+ };
729
+ imports.wbg.__wbg_wbindgenbooleanget_3fe6f642c7d97746 = function(arg0) {
730
+ const v = arg0;
731
+ const ret = typeof(v) === 'boolean' ? v : undefined;
732
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
733
+ };
734
+ imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
735
+ const ret = debugString(arg1);
736
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
737
+ const len1 = WASM_VECTOR_LEN;
738
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
739
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
740
+ };
741
+ imports.wbg.__wbg_wbindgenin_d7a1ee10933d2d55 = function(arg0, arg1) {
742
+ const ret = arg0 in arg1;
743
+ return ret;
744
+ };
745
+ imports.wbg.__wbg_wbindgenisbigint_ecb90cc08a5a9154 = function(arg0) {
746
+ const ret = typeof(arg0) === 'bigint';
747
+ return ret;
748
+ };
749
+ imports.wbg.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
750
+ const ret = typeof(arg0) === 'function';
751
+ return ret;
752
+ };
753
+ imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
754
+ const val = arg0;
755
+ const ret = typeof(val) === 'object' && val !== null;
756
+ return ret;
757
+ };
758
+ imports.wbg.__wbg_wbindgenjsvaleq_e6f2ad59ccae1b58 = function(arg0, arg1) {
759
+ const ret = arg0 === arg1;
760
+ return ret;
761
+ };
762
+ imports.wbg.__wbg_wbindgenjsvallooseeq_9bec8c9be826bed1 = function(arg0, arg1) {
763
+ const ret = arg0 == arg1;
764
+ return ret;
765
+ };
766
+ imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
767
+ const obj = arg1;
768
+ const ret = typeof(obj) === 'number' ? obj : undefined;
769
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
770
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
771
+ };
772
+ imports.wbg.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
773
+ const obj = arg1;
774
+ const ret = typeof(obj) === 'string' ? obj : undefined;
775
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
776
+ var len1 = WASM_VECTOR_LEN;
777
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
778
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
779
+ };
780
+ imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
781
+ throw new Error(getStringFromWasm0(arg0, arg1));
782
+ };
783
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
784
+ // Cast intrinsic for `Ref(String) -> Externref`.
785
+ const ret = getStringFromWasm0(arg0, arg1);
786
+ return ret;
787
+ };
788
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
789
+ // Cast intrinsic for `U64 -> Externref`.
790
+ const ret = BigInt.asUintN(64, arg0);
791
+ return ret;
792
+ };
793
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
794
+ // Cast intrinsic for `I64 -> Externref`.
795
+ const ret = arg0;
796
+ return ret;
797
+ };
798
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
799
+ // Cast intrinsic for `F64 -> Externref`.
800
+ const ret = arg0;
801
+ return ret;
802
+ };
803
+ imports.wbg.__wbindgen_init_externref_table = function() {
804
+ const table = wasm.__wbindgen_export_4;
805
+ const offset = table.grow(4);
806
+ table.set(0, undefined);
807
+ table.set(offset + 0, undefined);
808
+ table.set(offset + 1, null);
809
+ table.set(offset + 2, true);
810
+ table.set(offset + 3, false);
811
+ ;
812
+ };
813
+
814
+ return imports;
815
+ }
816
+
817
+ function __wbg_init_memory(imports, memory) {
818
+
819
+ }
820
+
821
+ function __wbg_finalize_init(instance, module) {
822
+ wasm = instance.exports;
823
+ __wbg_init.__wbindgen_wasm_module = module;
824
+ cachedDataViewMemory0 = null;
825
+ cachedUint8ArrayMemory0 = null;
826
+
827
+
828
+ wasm.__wbindgen_start();
829
+ return wasm;
830
+ }
831
+
832
+ function initSync(module) {
833
+ if (wasm !== undefined) return wasm;
834
+
835
+
836
+ if (typeof module !== 'undefined') {
837
+ if (Object.getPrototypeOf(module) === Object.prototype) {
838
+ ({module} = module)
839
+ } else {
840
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
841
+ }
842
+ }
843
+
844
+ const imports = __wbg_get_imports();
845
+
846
+ __wbg_init_memory(imports);
847
+
848
+ if (!(module instanceof WebAssembly.Module)) {
849
+ module = new WebAssembly.Module(module);
850
+ }
851
+
852
+ const instance = new WebAssembly.Instance(module, imports);
853
+
854
+ return __wbg_finalize_init(instance, module);
855
+ }
856
+
857
+ async function __wbg_init(module_or_path) {
858
+ if (wasm !== undefined) return wasm;
859
+
860
+
861
+ if (typeof module_or_path !== 'undefined') {
862
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
863
+ ({module_or_path} = module_or_path)
864
+ } else {
865
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
866
+ }
867
+ }
868
+
869
+ if (typeof module_or_path === 'undefined') {
870
+ module_or_path = new URL('lindera_wasm_bg.wasm', import.meta.url);
871
+ }
872
+ const imports = __wbg_get_imports();
873
+
874
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
875
+ module_or_path = fetch(module_or_path);
876
+ }
877
+
878
+ __wbg_init_memory(imports);
879
+
880
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
881
+
882
+ return __wbg_finalize_init(instance, module);
883
+ }
884
+
885
+ export { initSync };
886
+ export default __wbg_init;
Binary file
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "lindera-wasm-web-ipadic",
3
+ "type": "module",
4
+ "description": "Lindera WASM with Japanese dictionary (IPADIC) (web target)",
5
+ "version": "1.2.1",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/lindera/lindera-wasm"
10
+ },
11
+ "files": [
12
+ "lindera_wasm_bg.wasm",
13
+ "lindera_wasm.js",
14
+ "lindera_wasm.d.ts"
15
+ ],
16
+ "main": "lindera_wasm.js",
17
+ "homepage": "https://github.com/lindera/lindera-wasm",
18
+ "types": "lindera_wasm.d.ts",
19
+ "sideEffects": [
20
+ "./snippets/*"
21
+ ],
22
+ "keywords": [
23
+ "morphological",
24
+ "analysis",
25
+ "library",
26
+ "wasm",
27
+ "webassembly"
28
+ ]
29
+ }