lindera-wasm-ko-dic-web 2.1.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.
@@ -0,0 +1,1922 @@
1
+ /* @ts-self-types="./lindera_wasm.d.ts" */
2
+
3
+ /**
4
+ * Compression algorithm for dictionary data.
5
+ * @enum {0 | 1 | 2 | 3}
6
+ */
7
+ export const CompressionAlgorithm = Object.freeze({
8
+ Deflate: 0, "0": "Deflate",
9
+ Zlib: 1, "1": "Zlib",
10
+ Gzip: 2, "2": "Gzip",
11
+ Raw: 3, "3": "Raw",
12
+ });
13
+
14
+ /**
15
+ * A morphological analysis dictionary.
16
+ */
17
+ export class Dictionary {
18
+ static __wrap(ptr) {
19
+ ptr = ptr >>> 0;
20
+ const obj = Object.create(Dictionary.prototype);
21
+ obj.__wbg_ptr = ptr;
22
+ DictionaryFinalization.register(obj, obj.__wbg_ptr, obj);
23
+ return obj;
24
+ }
25
+ __destroy_into_raw() {
26
+ const ptr = this.__wbg_ptr;
27
+ this.__wbg_ptr = 0;
28
+ DictionaryFinalization.unregister(this);
29
+ return ptr;
30
+ }
31
+ free() {
32
+ const ptr = this.__destroy_into_raw();
33
+ wasm.__wbg_dictionary_free(ptr, 0);
34
+ }
35
+ }
36
+ if (Symbol.dispose) Dictionary.prototype[Symbol.dispose] = Dictionary.prototype.free;
37
+
38
+ /**
39
+ * Field definition in dictionary schema.
40
+ */
41
+ export class FieldDefinition {
42
+ static __wrap(ptr) {
43
+ ptr = ptr >>> 0;
44
+ const obj = Object.create(FieldDefinition.prototype);
45
+ obj.__wbg_ptr = ptr;
46
+ FieldDefinitionFinalization.register(obj, obj.__wbg_ptr, obj);
47
+ return obj;
48
+ }
49
+ __destroy_into_raw() {
50
+ const ptr = this.__wbg_ptr;
51
+ this.__wbg_ptr = 0;
52
+ FieldDefinitionFinalization.unregister(this);
53
+ return ptr;
54
+ }
55
+ free() {
56
+ const ptr = this.__destroy_into_raw();
57
+ wasm.__wbg_fielddefinition_free(ptr, 0);
58
+ }
59
+ /**
60
+ * @returns {string | undefined}
61
+ */
62
+ get description() {
63
+ const ret = wasm.__wbg_get_fielddefinition_description(this.__wbg_ptr);
64
+ let v1;
65
+ if (ret[0] !== 0) {
66
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
67
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
68
+ }
69
+ return v1;
70
+ }
71
+ /**
72
+ * @returns {FieldType}
73
+ */
74
+ get field_type() {
75
+ const ret = wasm.__wbg_get_fielddefinition_field_type(this.__wbg_ptr);
76
+ return ret;
77
+ }
78
+ /**
79
+ * @returns {number}
80
+ */
81
+ get index() {
82
+ const ret = wasm.__wbg_get_fielddefinition_index(this.__wbg_ptr);
83
+ return ret >>> 0;
84
+ }
85
+ /**
86
+ * @returns {string}
87
+ */
88
+ get name() {
89
+ let deferred1_0;
90
+ let deferred1_1;
91
+ try {
92
+ const ret = wasm.__wbg_get_fielddefinition_name(this.__wbg_ptr);
93
+ deferred1_0 = ret[0];
94
+ deferred1_1 = ret[1];
95
+ return getStringFromWasm0(ret[0], ret[1]);
96
+ } finally {
97
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
98
+ }
99
+ }
100
+ /**
101
+ * @param {string | null} [arg0]
102
+ */
103
+ set description(arg0) {
104
+ var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
105
+ var len0 = WASM_VECTOR_LEN;
106
+ wasm.__wbg_set_fielddefinition_description(this.__wbg_ptr, ptr0, len0);
107
+ }
108
+ /**
109
+ * @param {FieldType} arg0
110
+ */
111
+ set field_type(arg0) {
112
+ wasm.__wbg_set_fielddefinition_field_type(this.__wbg_ptr, arg0);
113
+ }
114
+ /**
115
+ * @param {number} arg0
116
+ */
117
+ set index(arg0) {
118
+ wasm.__wbg_set_fielddefinition_index(this.__wbg_ptr, arg0);
119
+ }
120
+ /**
121
+ * @param {string} arg0
122
+ */
123
+ set name(arg0) {
124
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
125
+ const len0 = WASM_VECTOR_LEN;
126
+ wasm.__wbg_set_fielddefinition_name(this.__wbg_ptr, ptr0, len0);
127
+ }
128
+ }
129
+ if (Symbol.dispose) FieldDefinition.prototype[Symbol.dispose] = FieldDefinition.prototype.free;
130
+
131
+ /**
132
+ * Field type in dictionary schema.
133
+ * @enum {0 | 1 | 2 | 3 | 4}
134
+ */
135
+ export const FieldType = Object.freeze({
136
+ /**
137
+ * Surface form (word text)
138
+ */
139
+ Surface: 0, "0": "Surface",
140
+ /**
141
+ * Left context ID for morphological analysis
142
+ */
143
+ LeftContextId: 1, "1": "LeftContextId",
144
+ /**
145
+ * Right context ID for morphological analysis
146
+ */
147
+ RightContextId: 2, "2": "RightContextId",
148
+ /**
149
+ * Word cost (used in path selection)
150
+ */
151
+ Cost: 3, "3": "Cost",
152
+ /**
153
+ * Custom field (morphological features)
154
+ */
155
+ Custom: 4, "4": "Custom",
156
+ });
157
+
158
+ export class JsDictionary {
159
+ __destroy_into_raw() {
160
+ const ptr = this.__wbg_ptr;
161
+ this.__wbg_ptr = 0;
162
+ JsDictionaryFinalization.unregister(this);
163
+ return ptr;
164
+ }
165
+ free() {
166
+ const ptr = this.__destroy_into_raw();
167
+ wasm.__wbg_jsdictionary_free(ptr, 0);
168
+ }
169
+ /**
170
+ * @returns {string}
171
+ */
172
+ get encoding() {
173
+ let deferred1_0;
174
+ let deferred1_1;
175
+ try {
176
+ const ret = wasm.jsdictionary_encoding(this.__wbg_ptr);
177
+ deferred1_0 = ret[0];
178
+ deferred1_1 = ret[1];
179
+ return getStringFromWasm0(ret[0], ret[1]);
180
+ } finally {
181
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
182
+ }
183
+ }
184
+ /**
185
+ * @returns {Metadata}
186
+ */
187
+ get metadata() {
188
+ const ret = wasm.jsdictionary_metadata(this.__wbg_ptr);
189
+ return Metadata.__wrap(ret);
190
+ }
191
+ /**
192
+ * @returns {string}
193
+ */
194
+ get name() {
195
+ let deferred1_0;
196
+ let deferred1_1;
197
+ try {
198
+ const ret = wasm.jsdictionary_name(this.__wbg_ptr);
199
+ deferred1_0 = ret[0];
200
+ deferred1_1 = ret[1];
201
+ return getStringFromWasm0(ret[0], ret[1]);
202
+ } finally {
203
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
204
+ }
205
+ }
206
+ }
207
+ if (Symbol.dispose) JsDictionary.prototype[Symbol.dispose] = JsDictionary.prototype.free;
208
+
209
+ export class JsFieldDefinition {
210
+ __destroy_into_raw() {
211
+ const ptr = this.__wbg_ptr;
212
+ this.__wbg_ptr = 0;
213
+ JsFieldDefinitionFinalization.unregister(this);
214
+ return ptr;
215
+ }
216
+ free() {
217
+ const ptr = this.__destroy_into_raw();
218
+ wasm.__wbg_jsfielddefinition_free(ptr, 0);
219
+ }
220
+ /**
221
+ * @param {number} index
222
+ * @param {string} name
223
+ * @param {FieldType} field_type
224
+ * @param {string | null} [description]
225
+ */
226
+ constructor(index, name, field_type, description) {
227
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
228
+ const len0 = WASM_VECTOR_LEN;
229
+ var ptr1 = isLikeNone(description) ? 0 : passStringToWasm0(description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
230
+ var len1 = WASM_VECTOR_LEN;
231
+ const ret = wasm.jsfielddefinition_new(index, ptr0, len0, field_type, ptr1, len1);
232
+ return FieldDefinition.__wrap(ret);
233
+ }
234
+ }
235
+ if (Symbol.dispose) JsFieldDefinition.prototype[Symbol.dispose] = JsFieldDefinition.prototype.free;
236
+
237
+ export class JsLinderaError {
238
+ __destroy_into_raw() {
239
+ const ptr = this.__wbg_ptr;
240
+ this.__wbg_ptr = 0;
241
+ JsLinderaErrorFinalization.unregister(this);
242
+ return ptr;
243
+ }
244
+ free() {
245
+ const ptr = this.__destroy_into_raw();
246
+ wasm.__wbg_jslinderaerror_free(ptr, 0);
247
+ }
248
+ /**
249
+ * @param {string} message
250
+ */
251
+ constructor(message) {
252
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
253
+ const len0 = WASM_VECTOR_LEN;
254
+ const ret = wasm.jslinderaerror_new(ptr0, len0);
255
+ return LinderaError.__wrap(ret);
256
+ }
257
+ /**
258
+ * @returns {string}
259
+ */
260
+ toString() {
261
+ let deferred1_0;
262
+ let deferred1_1;
263
+ try {
264
+ const ret = wasm.jslinderaerror_toString(this.__wbg_ptr);
265
+ deferred1_0 = ret[0];
266
+ deferred1_1 = ret[1];
267
+ return getStringFromWasm0(ret[0], ret[1]);
268
+ } finally {
269
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
270
+ }
271
+ }
272
+ }
273
+ if (Symbol.dispose) JsLinderaError.prototype[Symbol.dispose] = JsLinderaError.prototype.free;
274
+
275
+ export class JsMetadata {
276
+ __destroy_into_raw() {
277
+ const ptr = this.__wbg_ptr;
278
+ this.__wbg_ptr = 0;
279
+ JsMetadataFinalization.unregister(this);
280
+ return ptr;
281
+ }
282
+ free() {
283
+ const ptr = this.__destroy_into_raw();
284
+ wasm.__wbg_jsmetadata_free(ptr, 0);
285
+ }
286
+ /**
287
+ * @returns {CompressionAlgorithm}
288
+ */
289
+ get compress_algorithm() {
290
+ const ret = wasm.jsmetadata_compress_algorithm(this.__wbg_ptr);
291
+ return ret;
292
+ }
293
+ /**
294
+ * @returns {Metadata}
295
+ */
296
+ static createDefault() {
297
+ const ret = wasm.jsmetadata_createDefault();
298
+ return Metadata.__wrap(ret);
299
+ }
300
+ /**
301
+ * @returns {Schema}
302
+ */
303
+ get dictionary_schema() {
304
+ const ret = wasm.jsmetadata_dictionary_schema(this.__wbg_ptr);
305
+ return Schema.__wrap(ret);
306
+ }
307
+ /**
308
+ * @returns {string}
309
+ */
310
+ get encoding() {
311
+ let deferred1_0;
312
+ let deferred1_1;
313
+ try {
314
+ const ret = wasm.jsmetadata_encoding(this.__wbg_ptr);
315
+ deferred1_0 = ret[0];
316
+ deferred1_1 = ret[1];
317
+ return getStringFromWasm0(ret[0], ret[1]);
318
+ } finally {
319
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
320
+ }
321
+ }
322
+ /**
323
+ * @returns {string}
324
+ */
325
+ get name() {
326
+ let deferred1_0;
327
+ let deferred1_1;
328
+ try {
329
+ const ret = wasm.jsmetadata_name(this.__wbg_ptr);
330
+ deferred1_0 = ret[0];
331
+ deferred1_1 = ret[1];
332
+ return getStringFromWasm0(ret[0], ret[1]);
333
+ } finally {
334
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
335
+ }
336
+ }
337
+ /**
338
+ * @param {string | null} [name]
339
+ * @param {string | null} [encoding]
340
+ * @param {CompressionAlgorithm | null} [compress_algorithm]
341
+ */
342
+ constructor(name, encoding, compress_algorithm) {
343
+ var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
344
+ var len0 = WASM_VECTOR_LEN;
345
+ var ptr1 = isLikeNone(encoding) ? 0 : passStringToWasm0(encoding, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
346
+ var len1 = WASM_VECTOR_LEN;
347
+ const ret = wasm.jsmetadata_new(ptr0, len0, ptr1, len1, isLikeNone(compress_algorithm) ? 4 : compress_algorithm);
348
+ return Metadata.__wrap(ret);
349
+ }
350
+ /**
351
+ * @param {CompressionAlgorithm} algorithm
352
+ */
353
+ set compress_algorithm(algorithm) {
354
+ wasm.jsmetadata_set_compress_algorithm(this.__wbg_ptr, algorithm);
355
+ }
356
+ /**
357
+ * @param {Schema} schema
358
+ */
359
+ set dictionary_schema(schema) {
360
+ _assertClass(schema, Schema);
361
+ var ptr0 = schema.__destroy_into_raw();
362
+ wasm.jsmetadata_set_dictionary_schema(this.__wbg_ptr, ptr0);
363
+ }
364
+ /**
365
+ * @param {string} encoding
366
+ */
367
+ set encoding(encoding) {
368
+ const ptr0 = passStringToWasm0(encoding, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
369
+ const len0 = WASM_VECTOR_LEN;
370
+ wasm.jsmetadata_set_encoding(this.__wbg_ptr, ptr0, len0);
371
+ }
372
+ /**
373
+ * @param {string} name
374
+ */
375
+ set name(name) {
376
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
377
+ const len0 = WASM_VECTOR_LEN;
378
+ wasm.jsmetadata_set_name(this.__wbg_ptr, ptr0, len0);
379
+ }
380
+ /**
381
+ * @param {Schema} schema
382
+ */
383
+ set user_dictionary_schema(schema) {
384
+ _assertClass(schema, Schema);
385
+ var ptr0 = schema.__destroy_into_raw();
386
+ wasm.jsmetadata_set_user_dictionary_schema(this.__wbg_ptr, ptr0);
387
+ }
388
+ /**
389
+ * @returns {Schema}
390
+ */
391
+ get user_dictionary_schema() {
392
+ const ret = wasm.jsmetadata_user_dictionary_schema(this.__wbg_ptr);
393
+ return Schema.__wrap(ret);
394
+ }
395
+ }
396
+ if (Symbol.dispose) JsMetadata.prototype[Symbol.dispose] = JsMetadata.prototype.free;
397
+
398
+ export class JsPenalty {
399
+ __destroy_into_raw() {
400
+ const ptr = this.__wbg_ptr;
401
+ this.__wbg_ptr = 0;
402
+ JsPenaltyFinalization.unregister(this);
403
+ return ptr;
404
+ }
405
+ free() {
406
+ const ptr = this.__destroy_into_raw();
407
+ wasm.__wbg_jspenalty_free(ptr, 0);
408
+ }
409
+ /**
410
+ * @param {number | null} [kanji_penalty_length_threshold]
411
+ * @param {number | null} [kanji_penalty_length_penalty]
412
+ * @param {number | null} [other_penalty_length_threshold]
413
+ * @param {number | null} [other_penalty_length_penalty]
414
+ */
415
+ constructor(kanji_penalty_length_threshold, kanji_penalty_length_penalty, other_penalty_length_threshold, other_penalty_length_penalty) {
416
+ const ret = wasm.jspenalty_new(isLikeNone(kanji_penalty_length_threshold) ? 0x100000001 : (kanji_penalty_length_threshold) >>> 0, isLikeNone(kanji_penalty_length_penalty) ? 0x100000001 : (kanji_penalty_length_penalty) >> 0, isLikeNone(other_penalty_length_threshold) ? 0x100000001 : (other_penalty_length_threshold) >>> 0, isLikeNone(other_penalty_length_penalty) ? 0x100000001 : (other_penalty_length_penalty) >> 0);
417
+ return Penalty.__wrap(ret);
418
+ }
419
+ }
420
+ if (Symbol.dispose) JsPenalty.prototype[Symbol.dispose] = JsPenalty.prototype.free;
421
+
422
+ export class JsSchema {
423
+ __destroy_into_raw() {
424
+ const ptr = this.__wbg_ptr;
425
+ this.__wbg_ptr = 0;
426
+ JsSchemaFinalization.unregister(this);
427
+ return ptr;
428
+ }
429
+ free() {
430
+ const ptr = this.__destroy_into_raw();
431
+ wasm.__wbg_jsschema_free(ptr, 0);
432
+ }
433
+ /**
434
+ * @returns {Schema}
435
+ */
436
+ static create_default() {
437
+ const ret = wasm.jsschema_create_default();
438
+ return Schema.__wrap(ret);
439
+ }
440
+ /**
441
+ * @returns {number}
442
+ */
443
+ field_count() {
444
+ const ret = wasm.jsschema_field_count(this.__wbg_ptr);
445
+ return ret >>> 0;
446
+ }
447
+ /**
448
+ * @returns {string[]}
449
+ */
450
+ get_all_fields() {
451
+ const ret = wasm.jsschema_get_all_fields(this.__wbg_ptr);
452
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
453
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
454
+ return v1;
455
+ }
456
+ /**
457
+ * @returns {string[]}
458
+ */
459
+ get_custom_fields() {
460
+ const ret = wasm.jsschema_get_custom_fields(this.__wbg_ptr);
461
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
462
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
463
+ return v1;
464
+ }
465
+ /**
466
+ * @param {string} name
467
+ * @returns {FieldDefinition | undefined}
468
+ */
469
+ get_field_by_name(name) {
470
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
471
+ const len0 = WASM_VECTOR_LEN;
472
+ const ret = wasm.jsschema_get_field_by_name(this.__wbg_ptr, ptr0, len0);
473
+ return ret === 0 ? undefined : FieldDefinition.__wrap(ret);
474
+ }
475
+ /**
476
+ * @param {string} field_name
477
+ * @returns {number | undefined}
478
+ */
479
+ get_field_index(field_name) {
480
+ const ptr0 = passStringToWasm0(field_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
481
+ const len0 = WASM_VECTOR_LEN;
482
+ const ret = wasm.jsschema_get_field_index(this.__wbg_ptr, ptr0, len0);
483
+ return ret === 0x100000001 ? undefined : ret;
484
+ }
485
+ /**
486
+ * @param {number} index
487
+ * @returns {string | undefined}
488
+ */
489
+ get_field_name(index) {
490
+ const ret = wasm.jsschema_get_field_name(this.__wbg_ptr, index);
491
+ let v1;
492
+ if (ret[0] !== 0) {
493
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
494
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
495
+ }
496
+ return v1;
497
+ }
498
+ /**
499
+ * @param {string[]} fields
500
+ */
501
+ constructor(fields) {
502
+ const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
503
+ const len0 = WASM_VECTOR_LEN;
504
+ const ret = wasm.jsschema_new(ptr0, len0);
505
+ return Schema.__wrap(ret);
506
+ }
507
+ }
508
+ if (Symbol.dispose) JsSchema.prototype[Symbol.dispose] = JsSchema.prototype.free;
509
+
510
+ export class JsToken {
511
+ __destroy_into_raw() {
512
+ const ptr = this.__wbg_ptr;
513
+ this.__wbg_ptr = 0;
514
+ JsTokenFinalization.unregister(this);
515
+ return ptr;
516
+ }
517
+ free() {
518
+ const ptr = this.__destroy_into_raw();
519
+ wasm.__wbg_jstoken_free(ptr, 0);
520
+ }
521
+ /**
522
+ * Returns the detail at the specified index.
523
+ *
524
+ * # Parameters
525
+ *
526
+ * - `index`: Index of the detail to retrieve.
527
+ *
528
+ * # Returns
529
+ *
530
+ * The detail string if found, otherwise undefined.
531
+ * @param {number} index
532
+ * @returns {string | undefined}
533
+ */
534
+ getDetail(index) {
535
+ const ret = wasm.jstoken_getDetail(this.__wbg_ptr, index);
536
+ let v1;
537
+ if (ret[0] !== 0) {
538
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
539
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
540
+ }
541
+ return v1;
542
+ }
543
+ /**
544
+ * @returns {any}
545
+ */
546
+ toJSON() {
547
+ const ret = wasm.jstoken_toJSON(this.__wbg_ptr);
548
+ return ret;
549
+ }
550
+ }
551
+ if (Symbol.dispose) JsToken.prototype[Symbol.dispose] = JsToken.prototype.free;
552
+
553
+ /**
554
+ * Error type for Lindera operations.
555
+ */
556
+ export class LinderaError {
557
+ static __wrap(ptr) {
558
+ ptr = ptr >>> 0;
559
+ const obj = Object.create(LinderaError.prototype);
560
+ obj.__wbg_ptr = ptr;
561
+ LinderaErrorFinalization.register(obj, obj.__wbg_ptr, obj);
562
+ return obj;
563
+ }
564
+ __destroy_into_raw() {
565
+ const ptr = this.__wbg_ptr;
566
+ this.__wbg_ptr = 0;
567
+ LinderaErrorFinalization.unregister(this);
568
+ return ptr;
569
+ }
570
+ free() {
571
+ const ptr = this.__destroy_into_raw();
572
+ wasm.__wbg_linderaerror_free(ptr, 0);
573
+ }
574
+ /**
575
+ * @returns {string}
576
+ */
577
+ get message() {
578
+ let deferred1_0;
579
+ let deferred1_1;
580
+ try {
581
+ const ret = wasm.__wbg_get_linderaerror_message(this.__wbg_ptr);
582
+ deferred1_0 = ret[0];
583
+ deferred1_1 = ret[1];
584
+ return getStringFromWasm0(ret[0], ret[1]);
585
+ } finally {
586
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
587
+ }
588
+ }
589
+ /**
590
+ * @param {string} arg0
591
+ */
592
+ set message(arg0) {
593
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
594
+ const len0 = WASM_VECTOR_LEN;
595
+ wasm.__wbg_set_fielddefinition_name(this.__wbg_ptr, ptr0, len0);
596
+ }
597
+ }
598
+ if (Symbol.dispose) LinderaError.prototype[Symbol.dispose] = LinderaError.prototype.free;
599
+
600
+ /**
601
+ * Dictionary metadata configuration.
602
+ */
603
+ export class Metadata {
604
+ static __wrap(ptr) {
605
+ ptr = ptr >>> 0;
606
+ const obj = Object.create(Metadata.prototype);
607
+ obj.__wbg_ptr = ptr;
608
+ MetadataFinalization.register(obj, obj.__wbg_ptr, obj);
609
+ return obj;
610
+ }
611
+ __destroy_into_raw() {
612
+ const ptr = this.__wbg_ptr;
613
+ this.__wbg_ptr = 0;
614
+ MetadataFinalization.unregister(this);
615
+ return ptr;
616
+ }
617
+ free() {
618
+ const ptr = this.__destroy_into_raw();
619
+ wasm.__wbg_metadata_free(ptr, 0);
620
+ }
621
+ }
622
+ if (Symbol.dispose) Metadata.prototype[Symbol.dispose] = Metadata.prototype.free;
623
+
624
+ /**
625
+ * Tokenization mode.
626
+ *
627
+ * Determines how text is segmented into tokens.
628
+ * @enum {0 | 1}
629
+ */
630
+ export const Mode = Object.freeze({
631
+ /**
632
+ * Standard tokenization based on dictionary cost
633
+ */
634
+ Normal: 0, "0": "Normal",
635
+ /**
636
+ * Decompose compound words using penalty-based segmentation
637
+ */
638
+ Decompose: 1, "1": "Decompose",
639
+ });
640
+
641
+ /**
642
+ * Penalty configuration for decompose mode.
643
+ *
644
+ * Controls how aggressively compound words are decomposed based on
645
+ * character type and length thresholds.
646
+ */
647
+ export class Penalty {
648
+ static __wrap(ptr) {
649
+ ptr = ptr >>> 0;
650
+ const obj = Object.create(Penalty.prototype);
651
+ obj.__wbg_ptr = ptr;
652
+ PenaltyFinalization.register(obj, obj.__wbg_ptr, obj);
653
+ return obj;
654
+ }
655
+ __destroy_into_raw() {
656
+ const ptr = this.__wbg_ptr;
657
+ this.__wbg_ptr = 0;
658
+ PenaltyFinalization.unregister(this);
659
+ return ptr;
660
+ }
661
+ free() {
662
+ const ptr = this.__destroy_into_raw();
663
+ wasm.__wbg_penalty_free(ptr, 0);
664
+ }
665
+ /**
666
+ * @returns {number}
667
+ */
668
+ get kanji_penalty_length_penalty() {
669
+ const ret = wasm.__wbg_get_penalty_kanji_penalty_length_penalty(this.__wbg_ptr);
670
+ return ret;
671
+ }
672
+ /**
673
+ * @returns {number}
674
+ */
675
+ get kanji_penalty_length_threshold() {
676
+ const ret = wasm.__wbg_get_penalty_kanji_penalty_length_threshold(this.__wbg_ptr);
677
+ return ret >>> 0;
678
+ }
679
+ /**
680
+ * @returns {number}
681
+ */
682
+ get other_penalty_length_penalty() {
683
+ const ret = wasm.__wbg_get_penalty_other_penalty_length_penalty(this.__wbg_ptr);
684
+ return ret;
685
+ }
686
+ /**
687
+ * @returns {number}
688
+ */
689
+ get other_penalty_length_threshold() {
690
+ const ret = wasm.__wbg_get_penalty_other_penalty_length_threshold(this.__wbg_ptr);
691
+ return ret >>> 0;
692
+ }
693
+ /**
694
+ * @param {number} arg0
695
+ */
696
+ set kanji_penalty_length_penalty(arg0) {
697
+ wasm.__wbg_set_penalty_kanji_penalty_length_penalty(this.__wbg_ptr, arg0);
698
+ }
699
+ /**
700
+ * @param {number} arg0
701
+ */
702
+ set kanji_penalty_length_threshold(arg0) {
703
+ wasm.__wbg_set_penalty_kanji_penalty_length_threshold(this.__wbg_ptr, arg0);
704
+ }
705
+ /**
706
+ * @param {number} arg0
707
+ */
708
+ set other_penalty_length_penalty(arg0) {
709
+ wasm.__wbg_set_penalty_other_penalty_length_penalty(this.__wbg_ptr, arg0);
710
+ }
711
+ /**
712
+ * @param {number} arg0
713
+ */
714
+ set other_penalty_length_threshold(arg0) {
715
+ wasm.__wbg_set_penalty_other_penalty_length_threshold(this.__wbg_ptr, arg0);
716
+ }
717
+ }
718
+ if (Symbol.dispose) Penalty.prototype[Symbol.dispose] = Penalty.prototype.free;
719
+
720
+ /**
721
+ * Dictionary schema definition.
722
+ */
723
+ export class Schema {
724
+ static __wrap(ptr) {
725
+ ptr = ptr >>> 0;
726
+ const obj = Object.create(Schema.prototype);
727
+ obj.__wbg_ptr = ptr;
728
+ SchemaFinalization.register(obj, obj.__wbg_ptr, obj);
729
+ return obj;
730
+ }
731
+ __destroy_into_raw() {
732
+ const ptr = this.__wbg_ptr;
733
+ this.__wbg_ptr = 0;
734
+ SchemaFinalization.unregister(this);
735
+ return ptr;
736
+ }
737
+ free() {
738
+ const ptr = this.__destroy_into_raw();
739
+ wasm.__wbg_schema_free(ptr, 0);
740
+ }
741
+ }
742
+ if (Symbol.dispose) Schema.prototype[Symbol.dispose] = Schema.prototype.free;
743
+
744
+ /**
745
+ * Core segmenter for morphological analysis.
746
+ */
747
+ export class Segmenter {
748
+ __destroy_into_raw() {
749
+ const ptr = this.__wbg_ptr;
750
+ this.__wbg_ptr = 0;
751
+ SegmenterFinalization.unregister(this);
752
+ return ptr;
753
+ }
754
+ free() {
755
+ const ptr = this.__destroy_into_raw();
756
+ wasm.__wbg_segmenter_free(ptr, 0);
757
+ }
758
+ }
759
+ if (Symbol.dispose) Segmenter.prototype[Symbol.dispose] = Segmenter.prototype.free;
760
+
761
+ /**
762
+ * Token object wrapping the Rust Token data.
763
+ *
764
+ * This class provides robust access to token field and details.
765
+ */
766
+ export class Token {
767
+ static __wrap(ptr) {
768
+ ptr = ptr >>> 0;
769
+ const obj = Object.create(Token.prototype);
770
+ obj.__wbg_ptr = ptr;
771
+ TokenFinalization.register(obj, obj.__wbg_ptr, obj);
772
+ return obj;
773
+ }
774
+ __destroy_into_raw() {
775
+ const ptr = this.__wbg_ptr;
776
+ this.__wbg_ptr = 0;
777
+ TokenFinalization.unregister(this);
778
+ return ptr;
779
+ }
780
+ free() {
781
+ const ptr = this.__destroy_into_raw();
782
+ wasm.__wbg_token_free(ptr, 0);
783
+ }
784
+ /**
785
+ * End byte position in the original text.
786
+ * @returns {number}
787
+ */
788
+ get byte_end() {
789
+ const ret = wasm.__wbg_get_token_byte_end(this.__wbg_ptr);
790
+ return ret >>> 0;
791
+ }
792
+ /**
793
+ * Start byte position in the original text.
794
+ * @returns {number}
795
+ */
796
+ get byte_start() {
797
+ const ret = wasm.__wbg_get_fielddefinition_index(this.__wbg_ptr);
798
+ return ret >>> 0;
799
+ }
800
+ /**
801
+ * Morphological details of the token.
802
+ * @returns {string[]}
803
+ */
804
+ get details() {
805
+ const ret = wasm.__wbg_get_token_details(this.__wbg_ptr);
806
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
807
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
808
+ return v1;
809
+ }
810
+ /**
811
+ * Position index of the token.
812
+ * @returns {number}
813
+ */
814
+ get position() {
815
+ const ret = wasm.__wbg_get_token_position(this.__wbg_ptr);
816
+ return ret >>> 0;
817
+ }
818
+ /**
819
+ * Surface form of the token.
820
+ * @returns {string}
821
+ */
822
+ get surface() {
823
+ let deferred1_0;
824
+ let deferred1_1;
825
+ try {
826
+ const ret = wasm.__wbg_get_token_surface(this.__wbg_ptr);
827
+ deferred1_0 = ret[0];
828
+ deferred1_1 = ret[1];
829
+ return getStringFromWasm0(ret[0], ret[1]);
830
+ } finally {
831
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
832
+ }
833
+ }
834
+ /**
835
+ * Word ID in the dictionary.
836
+ * @returns {number}
837
+ */
838
+ get word_id() {
839
+ const ret = wasm.__wbg_get_token_word_id(this.__wbg_ptr);
840
+ return ret >>> 0;
841
+ }
842
+ /**
843
+ * End byte position in the original text.
844
+ * @param {number} arg0
845
+ */
846
+ set byte_end(arg0) {
847
+ wasm.__wbg_set_token_byte_end(this.__wbg_ptr, arg0);
848
+ }
849
+ /**
850
+ * Start byte position in the original text.
851
+ * @param {number} arg0
852
+ */
853
+ set byte_start(arg0) {
854
+ wasm.__wbg_set_fielddefinition_index(this.__wbg_ptr, arg0);
855
+ }
856
+ /**
857
+ * Morphological details of the token.
858
+ * @param {string[]} arg0
859
+ */
860
+ set details(arg0) {
861
+ const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
862
+ const len0 = WASM_VECTOR_LEN;
863
+ wasm.__wbg_set_token_details(this.__wbg_ptr, ptr0, len0);
864
+ }
865
+ /**
866
+ * Position index of the token.
867
+ * @param {number} arg0
868
+ */
869
+ set position(arg0) {
870
+ wasm.__wbg_set_token_position(this.__wbg_ptr, arg0);
871
+ }
872
+ /**
873
+ * Surface form of the token.
874
+ * @param {string} arg0
875
+ */
876
+ set surface(arg0) {
877
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
878
+ const len0 = WASM_VECTOR_LEN;
879
+ wasm.__wbg_set_fielddefinition_name(this.__wbg_ptr, ptr0, len0);
880
+ }
881
+ /**
882
+ * Word ID in the dictionary.
883
+ * @param {number} arg0
884
+ */
885
+ set word_id(arg0) {
886
+ wasm.__wbg_set_token_word_id(this.__wbg_ptr, arg0);
887
+ }
888
+ }
889
+ if (Symbol.dispose) Token.prototype[Symbol.dispose] = Token.prototype.free;
890
+
891
+ /**
892
+ * A tokenizer for morphological analysis.
893
+ */
894
+ export class Tokenizer {
895
+ static __wrap(ptr) {
896
+ ptr = ptr >>> 0;
897
+ const obj = Object.create(Tokenizer.prototype);
898
+ obj.__wbg_ptr = ptr;
899
+ TokenizerFinalization.register(obj, obj.__wbg_ptr, obj);
900
+ return obj;
901
+ }
902
+ __destroy_into_raw() {
903
+ const ptr = this.__wbg_ptr;
904
+ this.__wbg_ptr = 0;
905
+ TokenizerFinalization.unregister(this);
906
+ return ptr;
907
+ }
908
+ free() {
909
+ const ptr = this.__destroy_into_raw();
910
+ wasm.__wbg_tokenizer_free(ptr, 0);
911
+ }
912
+ /**
913
+ * @param {Dictionary} dictionary
914
+ * @param {string | null} [mode]
915
+ * @param {UserDictionary | null} [user_dictionary]
916
+ */
917
+ constructor(dictionary, mode, user_dictionary) {
918
+ _assertClass(dictionary, Dictionary);
919
+ var ptr0 = dictionary.__destroy_into_raw();
920
+ var ptr1 = isLikeNone(mode) ? 0 : passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
921
+ var len1 = WASM_VECTOR_LEN;
922
+ let ptr2 = 0;
923
+ if (!isLikeNone(user_dictionary)) {
924
+ _assertClass(user_dictionary, UserDictionary);
925
+ ptr2 = user_dictionary.__destroy_into_raw();
926
+ }
927
+ const ret = wasm.tokenizer_new(ptr0, ptr1, len1, ptr2);
928
+ if (ret[2]) {
929
+ throw takeFromExternrefTable0(ret[1]);
930
+ }
931
+ this.__wbg_ptr = ret[0] >>> 0;
932
+ TokenizerFinalization.register(this, this.__wbg_ptr, this);
933
+ return this;
934
+ }
935
+ /**
936
+ * Tokenizes the input text.
937
+ * @param {string} input_text
938
+ * @returns {Token[]}
939
+ */
940
+ tokenize(input_text) {
941
+ const ptr0 = passStringToWasm0(input_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
942
+ const len0 = WASM_VECTOR_LEN;
943
+ const ret = wasm.tokenizer_tokenize(this.__wbg_ptr, ptr0, len0);
944
+ if (ret[3]) {
945
+ throw takeFromExternrefTable0(ret[2]);
946
+ }
947
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
948
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
949
+ return v2;
950
+ }
951
+ }
952
+ if (Symbol.dispose) Tokenizer.prototype[Symbol.dispose] = Tokenizer.prototype.free;
953
+
954
+ /**
955
+ * Builder for creating a [`Tokenizer`] instance.
956
+ *
957
+ * `TokenizerBuilder` provides a fluent API for configuring and building a tokenizer
958
+ * with various options such as dictionary selection, tokenization mode, character filters,
959
+ * and token filters.
960
+ */
961
+ export class TokenizerBuilder {
962
+ __destroy_into_raw() {
963
+ const ptr = this.__wbg_ptr;
964
+ this.__wbg_ptr = 0;
965
+ TokenizerBuilderFinalization.unregister(this);
966
+ return ptr;
967
+ }
968
+ free() {
969
+ const ptr = this.__destroy_into_raw();
970
+ wasm.__wbg_tokenizerbuilder_free(ptr, 0);
971
+ }
972
+ /**
973
+ * Appends a character filter to the tokenization pipeline.
974
+ * @param {string} name
975
+ * @param {any} args
976
+ */
977
+ appendCharacterFilter(name, args) {
978
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
979
+ const len0 = WASM_VECTOR_LEN;
980
+ const ret = wasm.tokenizerbuilder_appendCharacterFilter(this.__wbg_ptr, ptr0, len0, args);
981
+ if (ret[1]) {
982
+ throw takeFromExternrefTable0(ret[0]);
983
+ }
984
+ }
985
+ /**
986
+ * Appends a token filter to the tokenization pipeline.
987
+ * @param {string} name
988
+ * @param {any} args
989
+ */
990
+ appendTokenFilter(name, args) {
991
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
992
+ const len0 = WASM_VECTOR_LEN;
993
+ const ret = wasm.tokenizerbuilder_appendTokenFilter(this.__wbg_ptr, ptr0, len0, args);
994
+ if (ret[1]) {
995
+ throw takeFromExternrefTable0(ret[0]);
996
+ }
997
+ }
998
+ /**
999
+ * @param {string} name
1000
+ * @param {any} args
1001
+ */
1002
+ append_character_filter(name, args) {
1003
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1004
+ const len0 = WASM_VECTOR_LEN;
1005
+ const ret = wasm.tokenizerbuilder_append_character_filter(this.__wbg_ptr, ptr0, len0, args);
1006
+ if (ret[1]) {
1007
+ throw takeFromExternrefTable0(ret[0]);
1008
+ }
1009
+ }
1010
+ /**
1011
+ * @param {string} name
1012
+ * @param {any} args
1013
+ */
1014
+ append_token_filter(name, args) {
1015
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1016
+ const len0 = WASM_VECTOR_LEN;
1017
+ const ret = wasm.tokenizerbuilder_append_token_filter(this.__wbg_ptr, ptr0, len0, args);
1018
+ if (ret[1]) {
1019
+ throw takeFromExternrefTable0(ret[0]);
1020
+ }
1021
+ }
1022
+ /**
1023
+ * Builds and returns a configured [`Tokenizer`] instance.
1024
+ * @returns {Tokenizer}
1025
+ */
1026
+ build() {
1027
+ const ptr = this.__destroy_into_raw();
1028
+ const ret = wasm.tokenizerbuilder_build(ptr);
1029
+ if (ret[2]) {
1030
+ throw takeFromExternrefTable0(ret[1]);
1031
+ }
1032
+ return Tokenizer.__wrap(ret[0]);
1033
+ }
1034
+ /**
1035
+ * Creates a new `TokenizerBuilder` instance.
1036
+ */
1037
+ constructor() {
1038
+ const ret = wasm.tokenizerbuilder_new();
1039
+ if (ret[2]) {
1040
+ throw takeFromExternrefTable0(ret[1]);
1041
+ }
1042
+ this.__wbg_ptr = ret[0] >>> 0;
1043
+ TokenizerBuilderFinalization.register(this, this.__wbg_ptr, this);
1044
+ return this;
1045
+ }
1046
+ /**
1047
+ * Sets the dictionary to use for tokenization.
1048
+ * @param {string} uri
1049
+ */
1050
+ setDictionary(uri) {
1051
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1052
+ const len0 = WASM_VECTOR_LEN;
1053
+ const ret = wasm.tokenizerbuilder_setDictionary(this.__wbg_ptr, ptr0, len0);
1054
+ if (ret[1]) {
1055
+ throw takeFromExternrefTable0(ret[0]);
1056
+ }
1057
+ }
1058
+ /**
1059
+ * Sets whether to keep whitespace tokens in the output.
1060
+ * @param {boolean} keep
1061
+ */
1062
+ setKeepWhitespace(keep) {
1063
+ const ret = wasm.tokenizerbuilder_setKeepWhitespace(this.__wbg_ptr, keep);
1064
+ if (ret[1]) {
1065
+ throw takeFromExternrefTable0(ret[0]);
1066
+ }
1067
+ }
1068
+ /**
1069
+ * Sets the tokenization mode.
1070
+ * @param {string} mode
1071
+ */
1072
+ setMode(mode) {
1073
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1074
+ const len0 = WASM_VECTOR_LEN;
1075
+ const ret = wasm.tokenizerbuilder_setMode(this.__wbg_ptr, ptr0, len0);
1076
+ if (ret[1]) {
1077
+ throw takeFromExternrefTable0(ret[0]);
1078
+ }
1079
+ }
1080
+ /**
1081
+ * Sets a user-defined dictionary.
1082
+ * @param {string} uri
1083
+ */
1084
+ setUserDictionary(uri) {
1085
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1086
+ const len0 = WASM_VECTOR_LEN;
1087
+ const ret = wasm.tokenizerbuilder_setUserDictionary(this.__wbg_ptr, ptr0, len0);
1088
+ if (ret[1]) {
1089
+ throw takeFromExternrefTable0(ret[0]);
1090
+ }
1091
+ }
1092
+ /**
1093
+ * @param {string} uri
1094
+ */
1095
+ set_dictionary(uri) {
1096
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1097
+ const len0 = WASM_VECTOR_LEN;
1098
+ const ret = wasm.tokenizerbuilder_set_dictionary(this.__wbg_ptr, ptr0, len0);
1099
+ if (ret[1]) {
1100
+ throw takeFromExternrefTable0(ret[0]);
1101
+ }
1102
+ }
1103
+ /**
1104
+ * @param {boolean} keep
1105
+ */
1106
+ set_keep_whitespace(keep) {
1107
+ const ret = wasm.tokenizerbuilder_set_keep_whitespace(this.__wbg_ptr, keep);
1108
+ if (ret[1]) {
1109
+ throw takeFromExternrefTable0(ret[0]);
1110
+ }
1111
+ }
1112
+ /**
1113
+ * @param {string} mode
1114
+ */
1115
+ set_mode(mode) {
1116
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1117
+ const len0 = WASM_VECTOR_LEN;
1118
+ const ret = wasm.tokenizerbuilder_set_mode(this.__wbg_ptr, ptr0, len0);
1119
+ if (ret[1]) {
1120
+ throw takeFromExternrefTable0(ret[0]);
1121
+ }
1122
+ }
1123
+ /**
1124
+ * @param {string} uri
1125
+ */
1126
+ set_user_dictionary(uri) {
1127
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1128
+ const len0 = WASM_VECTOR_LEN;
1129
+ const ret = wasm.tokenizerbuilder_set_user_dictionary(this.__wbg_ptr, ptr0, len0);
1130
+ if (ret[1]) {
1131
+ throw takeFromExternrefTable0(ret[0]);
1132
+ }
1133
+ }
1134
+ }
1135
+ if (Symbol.dispose) TokenizerBuilder.prototype[Symbol.dispose] = TokenizerBuilder.prototype.free;
1136
+
1137
+ /**
1138
+ * A user-defined dictionary for custom words.
1139
+ */
1140
+ export class UserDictionary {
1141
+ static __wrap(ptr) {
1142
+ ptr = ptr >>> 0;
1143
+ const obj = Object.create(UserDictionary.prototype);
1144
+ obj.__wbg_ptr = ptr;
1145
+ UserDictionaryFinalization.register(obj, obj.__wbg_ptr, obj);
1146
+ return obj;
1147
+ }
1148
+ __destroy_into_raw() {
1149
+ const ptr = this.__wbg_ptr;
1150
+ this.__wbg_ptr = 0;
1151
+ UserDictionaryFinalization.unregister(this);
1152
+ return ptr;
1153
+ }
1154
+ free() {
1155
+ const ptr = this.__destroy_into_raw();
1156
+ wasm.__wbg_userdictionary_free(ptr, 0);
1157
+ }
1158
+ }
1159
+ if (Symbol.dispose) UserDictionary.prototype[Symbol.dispose] = UserDictionary.prototype.free;
1160
+
1161
+ /**
1162
+ * Builds a dictionary from source files.
1163
+ * @param {string} input_dir
1164
+ * @param {string} output_dir
1165
+ * @param {Metadata} metadata
1166
+ */
1167
+ export function buildDictionary(input_dir, output_dir, metadata) {
1168
+ const ptr0 = passStringToWasm0(input_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1169
+ const len0 = WASM_VECTOR_LEN;
1170
+ const ptr1 = passStringToWasm0(output_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1171
+ const len1 = WASM_VECTOR_LEN;
1172
+ _assertClass(metadata, Metadata);
1173
+ var ptr2 = metadata.__destroy_into_raw();
1174
+ const ret = wasm.buildDictionary(ptr0, len0, ptr1, len1, ptr2);
1175
+ if (ret[1]) {
1176
+ throw takeFromExternrefTable0(ret[0]);
1177
+ }
1178
+ }
1179
+
1180
+ /**
1181
+ * Builds a user dictionary from a CSV file.
1182
+ * @param {string} input_file
1183
+ * @param {string} output_dir
1184
+ * @param {Metadata | null} [metadata]
1185
+ */
1186
+ export function buildUserDictionary(input_file, output_dir, metadata) {
1187
+ const ptr0 = passStringToWasm0(input_file, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1188
+ const len0 = WASM_VECTOR_LEN;
1189
+ const ptr1 = passStringToWasm0(output_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1190
+ const len1 = WASM_VECTOR_LEN;
1191
+ let ptr2 = 0;
1192
+ if (!isLikeNone(metadata)) {
1193
+ _assertClass(metadata, Metadata);
1194
+ ptr2 = metadata.__destroy_into_raw();
1195
+ }
1196
+ const ret = wasm.buildUserDictionary(ptr0, len0, ptr1, len1, ptr2);
1197
+ if (ret[1]) {
1198
+ throw takeFromExternrefTable0(ret[0]);
1199
+ }
1200
+ }
1201
+
1202
+ /**
1203
+ * @param {string} input_dir
1204
+ * @param {string} output_dir
1205
+ * @param {Metadata} metadata
1206
+ */
1207
+ export function build_dictionary(input_dir, output_dir, metadata) {
1208
+ const ptr0 = passStringToWasm0(input_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1209
+ const len0 = WASM_VECTOR_LEN;
1210
+ const ptr1 = passStringToWasm0(output_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1211
+ const len1 = WASM_VECTOR_LEN;
1212
+ _assertClass(metadata, Metadata);
1213
+ var ptr2 = metadata.__destroy_into_raw();
1214
+ const ret = wasm.build_dictionary(ptr0, len0, ptr1, len1, ptr2);
1215
+ if (ret[1]) {
1216
+ throw takeFromExternrefTable0(ret[0]);
1217
+ }
1218
+ }
1219
+
1220
+ /**
1221
+ * @param {string} input_file
1222
+ * @param {string} output_dir
1223
+ * @param {Metadata | null} [metadata]
1224
+ */
1225
+ export function build_user_dictionary(input_file, output_dir, metadata) {
1226
+ const ptr0 = passStringToWasm0(input_file, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1227
+ const len0 = WASM_VECTOR_LEN;
1228
+ const ptr1 = passStringToWasm0(output_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1229
+ const len1 = WASM_VECTOR_LEN;
1230
+ let ptr2 = 0;
1231
+ if (!isLikeNone(metadata)) {
1232
+ _assertClass(metadata, Metadata);
1233
+ ptr2 = metadata.__destroy_into_raw();
1234
+ }
1235
+ const ret = wasm.build_user_dictionary(ptr0, len0, ptr1, len1, ptr2);
1236
+ if (ret[1]) {
1237
+ throw takeFromExternrefTable0(ret[0]);
1238
+ }
1239
+ }
1240
+
1241
+ /**
1242
+ * Gets the version of the lindera-wasm library.
1243
+ * Backward compatibility alias for version().
1244
+ * @returns {string}
1245
+ */
1246
+ export function getVersion() {
1247
+ let deferred1_0;
1248
+ let deferred1_1;
1249
+ try {
1250
+ const ret = wasm.getVersion();
1251
+ deferred1_0 = ret[0];
1252
+ deferred1_1 = ret[1];
1253
+ return getStringFromWasm0(ret[0], ret[1]);
1254
+ } finally {
1255
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1256
+ }
1257
+ }
1258
+
1259
+ /**
1260
+ * Loads a dictionary from the specified URI.
1261
+ * @param {string} uri
1262
+ * @returns {Dictionary}
1263
+ */
1264
+ export function loadDictionary(uri) {
1265
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1266
+ const len0 = WASM_VECTOR_LEN;
1267
+ const ret = wasm.loadDictionary(ptr0, len0);
1268
+ if (ret[2]) {
1269
+ throw takeFromExternrefTable0(ret[1]);
1270
+ }
1271
+ return Dictionary.__wrap(ret[0]);
1272
+ }
1273
+
1274
+ /**
1275
+ * Loads a user dictionary from the specified URI.
1276
+ * @param {string} uri
1277
+ * @param {Metadata} metadata
1278
+ * @returns {UserDictionary}
1279
+ */
1280
+ export function loadUserDictionary(uri, metadata) {
1281
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1282
+ const len0 = WASM_VECTOR_LEN;
1283
+ _assertClass(metadata, Metadata);
1284
+ var ptr1 = metadata.__destroy_into_raw();
1285
+ const ret = wasm.loadUserDictionary(ptr0, len0, ptr1);
1286
+ if (ret[2]) {
1287
+ throw takeFromExternrefTable0(ret[1]);
1288
+ }
1289
+ return UserDictionary.__wrap(ret[0]);
1290
+ }
1291
+
1292
+ /**
1293
+ * @param {string} uri
1294
+ * @returns {Dictionary}
1295
+ */
1296
+ export function load_dictionary(uri) {
1297
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1298
+ const len0 = WASM_VECTOR_LEN;
1299
+ const ret = wasm.load_dictionary(ptr0, len0);
1300
+ if (ret[2]) {
1301
+ throw takeFromExternrefTable0(ret[1]);
1302
+ }
1303
+ return Dictionary.__wrap(ret[0]);
1304
+ }
1305
+
1306
+ /**
1307
+ * @param {string} uri
1308
+ * @param {Metadata} metadata
1309
+ * @returns {UserDictionary}
1310
+ */
1311
+ export function load_user_dictionary(uri, metadata) {
1312
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1313
+ const len0 = WASM_VECTOR_LEN;
1314
+ _assertClass(metadata, Metadata);
1315
+ var ptr1 = metadata.__destroy_into_raw();
1316
+ const ret = wasm.load_user_dictionary(ptr0, len0, ptr1);
1317
+ if (ret[2]) {
1318
+ throw takeFromExternrefTable0(ret[1]);
1319
+ }
1320
+ return UserDictionary.__wrap(ret[0]);
1321
+ }
1322
+
1323
+ /**
1324
+ * Returns the version of the lindera-wasm package.
1325
+ * @returns {string}
1326
+ */
1327
+ export function version() {
1328
+ let deferred1_0;
1329
+ let deferred1_1;
1330
+ try {
1331
+ const ret = wasm.version();
1332
+ deferred1_0 = ret[0];
1333
+ deferred1_1 = ret[1];
1334
+ return getStringFromWasm0(ret[0], ret[1]);
1335
+ } finally {
1336
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1337
+ }
1338
+ }
1339
+
1340
+ function __wbg_get_imports() {
1341
+ const import0 = {
1342
+ __proto__: null,
1343
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
1344
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1345
+ return ret;
1346
+ },
1347
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
1348
+ const ret = String(arg1);
1349
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1350
+ const len1 = WASM_VECTOR_LEN;
1351
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1352
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1353
+ },
1354
+ __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
1355
+ const v = arg1;
1356
+ const ret = typeof(v) === 'bigint' ? v : undefined;
1357
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1358
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1359
+ },
1360
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
1361
+ const v = arg0;
1362
+ const ret = typeof(v) === 'boolean' ? v : undefined;
1363
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1364
+ },
1365
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
1366
+ const ret = debugString(arg1);
1367
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1368
+ const len1 = WASM_VECTOR_LEN;
1369
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1370
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1371
+ },
1372
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
1373
+ const ret = arg0 in arg1;
1374
+ return ret;
1375
+ },
1376
+ __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
1377
+ const ret = typeof(arg0) === 'bigint';
1378
+ return ret;
1379
+ },
1380
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
1381
+ const ret = typeof(arg0) === 'function';
1382
+ return ret;
1383
+ },
1384
+ __wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
1385
+ const ret = arg0 === null;
1386
+ return ret;
1387
+ },
1388
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
1389
+ const val = arg0;
1390
+ const ret = typeof(val) === 'object' && val !== null;
1391
+ return ret;
1392
+ },
1393
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
1394
+ const ret = arg0 === undefined;
1395
+ return ret;
1396
+ },
1397
+ __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
1398
+ const ret = arg0 === arg1;
1399
+ return ret;
1400
+ },
1401
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
1402
+ const ret = arg0 == arg1;
1403
+ return ret;
1404
+ },
1405
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
1406
+ const obj = arg1;
1407
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1408
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1409
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1410
+ },
1411
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
1412
+ const obj = arg1;
1413
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1414
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1415
+ var len1 = WASM_VECTOR_LEN;
1416
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1417
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1418
+ },
1419
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
1420
+ throw new Error(getStringFromWasm0(arg0, arg1));
1421
+ },
1422
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
1423
+ const ret = arg0.call(arg1);
1424
+ return ret;
1425
+ }, arguments); },
1426
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
1427
+ const ret = arg0.done;
1428
+ return ret;
1429
+ },
1430
+ __wbg_entries_58c7934c745daac7: function(arg0) {
1431
+ const ret = Object.entries(arg0);
1432
+ return ret;
1433
+ },
1434
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
1435
+ const ret = arg0[arg1 >>> 0];
1436
+ return ret;
1437
+ },
1438
+ __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
1439
+ const ret = Reflect.get(arg0, arg1);
1440
+ return ret;
1441
+ }, arguments); },
1442
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
1443
+ let result;
1444
+ try {
1445
+ result = arg0 instanceof ArrayBuffer;
1446
+ } catch (_) {
1447
+ result = false;
1448
+ }
1449
+ const ret = result;
1450
+ return ret;
1451
+ },
1452
+ __wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
1453
+ let result;
1454
+ try {
1455
+ result = arg0 instanceof Map;
1456
+ } catch (_) {
1457
+ result = false;
1458
+ }
1459
+ const ret = result;
1460
+ return ret;
1461
+ },
1462
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
1463
+ let result;
1464
+ try {
1465
+ result = arg0 instanceof Uint8Array;
1466
+ } catch (_) {
1467
+ result = false;
1468
+ }
1469
+ const ret = result;
1470
+ return ret;
1471
+ },
1472
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
1473
+ const ret = Array.isArray(arg0);
1474
+ return ret;
1475
+ },
1476
+ __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
1477
+ const ret = Number.isSafeInteger(arg0);
1478
+ return ret;
1479
+ },
1480
+ __wbg_iterator_6ff6560ca1568e55: function() {
1481
+ const ret = Symbol.iterator;
1482
+ return ret;
1483
+ },
1484
+ __wbg_length_32ed9a279acd054c: function(arg0) {
1485
+ const ret = arg0.length;
1486
+ return ret;
1487
+ },
1488
+ __wbg_length_35a7bace40f36eac: function(arg0) {
1489
+ const ret = arg0.length;
1490
+ return ret;
1491
+ },
1492
+ __wbg_new_361308b2356cecd0: function() {
1493
+ const ret = new Object();
1494
+ return ret;
1495
+ },
1496
+ __wbg_new_3eb36ae241fe6f44: function() {
1497
+ const ret = new Array();
1498
+ return ret;
1499
+ },
1500
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
1501
+ const ret = new Uint8Array(arg0);
1502
+ return ret;
1503
+ },
1504
+ __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
1505
+ const ret = arg0.next();
1506
+ return ret;
1507
+ }, arguments); },
1508
+ __wbg_next_418f80d8f5303233: function(arg0) {
1509
+ const ret = arg0.next;
1510
+ return ret;
1511
+ },
1512
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
1513
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1514
+ },
1515
+ __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
1516
+ const ret = arg0.push(arg1);
1517
+ return ret;
1518
+ },
1519
+ __wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
1520
+ const ret = Reflect.set(arg0, arg1, arg2);
1521
+ return ret;
1522
+ }, arguments); },
1523
+ __wbg_token_new: function(arg0) {
1524
+ const ret = Token.__wrap(arg0);
1525
+ return ret;
1526
+ },
1527
+ __wbg_value_0546255b415e96c1: function(arg0) {
1528
+ const ret = arg0.value;
1529
+ return ret;
1530
+ },
1531
+ __wbindgen_cast_0000000000000001: function(arg0) {
1532
+ // Cast intrinsic for `F64 -> Externref`.
1533
+ const ret = arg0;
1534
+ return ret;
1535
+ },
1536
+ __wbindgen_cast_0000000000000002: function(arg0) {
1537
+ // Cast intrinsic for `I64 -> Externref`.
1538
+ const ret = arg0;
1539
+ return ret;
1540
+ },
1541
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1542
+ // Cast intrinsic for `Ref(String) -> Externref`.
1543
+ const ret = getStringFromWasm0(arg0, arg1);
1544
+ return ret;
1545
+ },
1546
+ __wbindgen_cast_0000000000000004: function(arg0) {
1547
+ // Cast intrinsic for `U64 -> Externref`.
1548
+ const ret = BigInt.asUintN(64, arg0);
1549
+ return ret;
1550
+ },
1551
+ __wbindgen_init_externref_table: function() {
1552
+ const table = wasm.__wbindgen_externrefs;
1553
+ const offset = table.grow(4);
1554
+ table.set(0, undefined);
1555
+ table.set(offset + 0, undefined);
1556
+ table.set(offset + 1, null);
1557
+ table.set(offset + 2, true);
1558
+ table.set(offset + 3, false);
1559
+ },
1560
+ };
1561
+ return {
1562
+ __proto__: null,
1563
+ "./lindera_wasm_bg.js": import0,
1564
+ };
1565
+ }
1566
+
1567
+ const DictionaryFinalization = (typeof FinalizationRegistry === 'undefined')
1568
+ ? { register: () => {}, unregister: () => {} }
1569
+ : new FinalizationRegistry(ptr => wasm.__wbg_dictionary_free(ptr >>> 0, 1));
1570
+ const FieldDefinitionFinalization = (typeof FinalizationRegistry === 'undefined')
1571
+ ? { register: () => {}, unregister: () => {} }
1572
+ : new FinalizationRegistry(ptr => wasm.__wbg_fielddefinition_free(ptr >>> 0, 1));
1573
+ const JsDictionaryFinalization = (typeof FinalizationRegistry === 'undefined')
1574
+ ? { register: () => {}, unregister: () => {} }
1575
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsdictionary_free(ptr >>> 0, 1));
1576
+ const JsFieldDefinitionFinalization = (typeof FinalizationRegistry === 'undefined')
1577
+ ? { register: () => {}, unregister: () => {} }
1578
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsfielddefinition_free(ptr >>> 0, 1));
1579
+ const JsLinderaErrorFinalization = (typeof FinalizationRegistry === 'undefined')
1580
+ ? { register: () => {}, unregister: () => {} }
1581
+ : new FinalizationRegistry(ptr => wasm.__wbg_jslinderaerror_free(ptr >>> 0, 1));
1582
+ const JsMetadataFinalization = (typeof FinalizationRegistry === 'undefined')
1583
+ ? { register: () => {}, unregister: () => {} }
1584
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsmetadata_free(ptr >>> 0, 1));
1585
+ const JsPenaltyFinalization = (typeof FinalizationRegistry === 'undefined')
1586
+ ? { register: () => {}, unregister: () => {} }
1587
+ : new FinalizationRegistry(ptr => wasm.__wbg_jspenalty_free(ptr >>> 0, 1));
1588
+ const JsSchemaFinalization = (typeof FinalizationRegistry === 'undefined')
1589
+ ? { register: () => {}, unregister: () => {} }
1590
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsschema_free(ptr >>> 0, 1));
1591
+ const JsTokenFinalization = (typeof FinalizationRegistry === 'undefined')
1592
+ ? { register: () => {}, unregister: () => {} }
1593
+ : new FinalizationRegistry(ptr => wasm.__wbg_jstoken_free(ptr >>> 0, 1));
1594
+ const LinderaErrorFinalization = (typeof FinalizationRegistry === 'undefined')
1595
+ ? { register: () => {}, unregister: () => {} }
1596
+ : new FinalizationRegistry(ptr => wasm.__wbg_linderaerror_free(ptr >>> 0, 1));
1597
+ const MetadataFinalization = (typeof FinalizationRegistry === 'undefined')
1598
+ ? { register: () => {}, unregister: () => {} }
1599
+ : new FinalizationRegistry(ptr => wasm.__wbg_metadata_free(ptr >>> 0, 1));
1600
+ const PenaltyFinalization = (typeof FinalizationRegistry === 'undefined')
1601
+ ? { register: () => {}, unregister: () => {} }
1602
+ : new FinalizationRegistry(ptr => wasm.__wbg_penalty_free(ptr >>> 0, 1));
1603
+ const SchemaFinalization = (typeof FinalizationRegistry === 'undefined')
1604
+ ? { register: () => {}, unregister: () => {} }
1605
+ : new FinalizationRegistry(ptr => wasm.__wbg_schema_free(ptr >>> 0, 1));
1606
+ const SegmenterFinalization = (typeof FinalizationRegistry === 'undefined')
1607
+ ? { register: () => {}, unregister: () => {} }
1608
+ : new FinalizationRegistry(ptr => wasm.__wbg_segmenter_free(ptr >>> 0, 1));
1609
+ const TokenFinalization = (typeof FinalizationRegistry === 'undefined')
1610
+ ? { register: () => {}, unregister: () => {} }
1611
+ : new FinalizationRegistry(ptr => wasm.__wbg_token_free(ptr >>> 0, 1));
1612
+ const TokenizerFinalization = (typeof FinalizationRegistry === 'undefined')
1613
+ ? { register: () => {}, unregister: () => {} }
1614
+ : new FinalizationRegistry(ptr => wasm.__wbg_tokenizer_free(ptr >>> 0, 1));
1615
+ const TokenizerBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
1616
+ ? { register: () => {}, unregister: () => {} }
1617
+ : new FinalizationRegistry(ptr => wasm.__wbg_tokenizerbuilder_free(ptr >>> 0, 1));
1618
+ const UserDictionaryFinalization = (typeof FinalizationRegistry === 'undefined')
1619
+ ? { register: () => {}, unregister: () => {} }
1620
+ : new FinalizationRegistry(ptr => wasm.__wbg_userdictionary_free(ptr >>> 0, 1));
1621
+
1622
+ function addToExternrefTable0(obj) {
1623
+ const idx = wasm.__externref_table_alloc();
1624
+ wasm.__wbindgen_externrefs.set(idx, obj);
1625
+ return idx;
1626
+ }
1627
+
1628
+ function _assertClass(instance, klass) {
1629
+ if (!(instance instanceof klass)) {
1630
+ throw new Error(`expected instance of ${klass.name}`);
1631
+ }
1632
+ }
1633
+
1634
+ function debugString(val) {
1635
+ // primitive types
1636
+ const type = typeof val;
1637
+ if (type == 'number' || type == 'boolean' || val == null) {
1638
+ return `${val}`;
1639
+ }
1640
+ if (type == 'string') {
1641
+ return `"${val}"`;
1642
+ }
1643
+ if (type == 'symbol') {
1644
+ const description = val.description;
1645
+ if (description == null) {
1646
+ return 'Symbol';
1647
+ } else {
1648
+ return `Symbol(${description})`;
1649
+ }
1650
+ }
1651
+ if (type == 'function') {
1652
+ const name = val.name;
1653
+ if (typeof name == 'string' && name.length > 0) {
1654
+ return `Function(${name})`;
1655
+ } else {
1656
+ return 'Function';
1657
+ }
1658
+ }
1659
+ // objects
1660
+ if (Array.isArray(val)) {
1661
+ const length = val.length;
1662
+ let debug = '[';
1663
+ if (length > 0) {
1664
+ debug += debugString(val[0]);
1665
+ }
1666
+ for(let i = 1; i < length; i++) {
1667
+ debug += ', ' + debugString(val[i]);
1668
+ }
1669
+ debug += ']';
1670
+ return debug;
1671
+ }
1672
+ // Test for built-in
1673
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1674
+ let className;
1675
+ if (builtInMatches && builtInMatches.length > 1) {
1676
+ className = builtInMatches[1];
1677
+ } else {
1678
+ // Failed to match the standard '[object ClassName]'
1679
+ return toString.call(val);
1680
+ }
1681
+ if (className == 'Object') {
1682
+ // we're a user defined class or Object
1683
+ // JSON.stringify avoids problems with cycles, and is generally much
1684
+ // easier than looping through ownProperties of `val`.
1685
+ try {
1686
+ return 'Object(' + JSON.stringify(val) + ')';
1687
+ } catch (_) {
1688
+ return 'Object';
1689
+ }
1690
+ }
1691
+ // errors
1692
+ if (val instanceof Error) {
1693
+ return `${val.name}: ${val.message}\n${val.stack}`;
1694
+ }
1695
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1696
+ return className;
1697
+ }
1698
+
1699
+ function getArrayJsValueFromWasm0(ptr, len) {
1700
+ ptr = ptr >>> 0;
1701
+ const mem = getDataViewMemory0();
1702
+ const result = [];
1703
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
1704
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
1705
+ }
1706
+ wasm.__externref_drop_slice(ptr, len);
1707
+ return result;
1708
+ }
1709
+
1710
+ function getArrayU8FromWasm0(ptr, len) {
1711
+ ptr = ptr >>> 0;
1712
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1713
+ }
1714
+
1715
+ let cachedDataViewMemory0 = null;
1716
+ function getDataViewMemory0() {
1717
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1718
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1719
+ }
1720
+ return cachedDataViewMemory0;
1721
+ }
1722
+
1723
+ function getStringFromWasm0(ptr, len) {
1724
+ ptr = ptr >>> 0;
1725
+ return decodeText(ptr, len);
1726
+ }
1727
+
1728
+ let cachedUint8ArrayMemory0 = null;
1729
+ function getUint8ArrayMemory0() {
1730
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1731
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1732
+ }
1733
+ return cachedUint8ArrayMemory0;
1734
+ }
1735
+
1736
+ function handleError(f, args) {
1737
+ try {
1738
+ return f.apply(this, args);
1739
+ } catch (e) {
1740
+ const idx = addToExternrefTable0(e);
1741
+ wasm.__wbindgen_exn_store(idx);
1742
+ }
1743
+ }
1744
+
1745
+ function isLikeNone(x) {
1746
+ return x === undefined || x === null;
1747
+ }
1748
+
1749
+ function passArrayJsValueToWasm0(array, malloc) {
1750
+ const ptr = malloc(array.length * 4, 4) >>> 0;
1751
+ for (let i = 0; i < array.length; i++) {
1752
+ const add = addToExternrefTable0(array[i]);
1753
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
1754
+ }
1755
+ WASM_VECTOR_LEN = array.length;
1756
+ return ptr;
1757
+ }
1758
+
1759
+ function passStringToWasm0(arg, malloc, realloc) {
1760
+ if (realloc === undefined) {
1761
+ const buf = cachedTextEncoder.encode(arg);
1762
+ const ptr = malloc(buf.length, 1) >>> 0;
1763
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1764
+ WASM_VECTOR_LEN = buf.length;
1765
+ return ptr;
1766
+ }
1767
+
1768
+ let len = arg.length;
1769
+ let ptr = malloc(len, 1) >>> 0;
1770
+
1771
+ const mem = getUint8ArrayMemory0();
1772
+
1773
+ let offset = 0;
1774
+
1775
+ for (; offset < len; offset++) {
1776
+ const code = arg.charCodeAt(offset);
1777
+ if (code > 0x7F) break;
1778
+ mem[ptr + offset] = code;
1779
+ }
1780
+ if (offset !== len) {
1781
+ if (offset !== 0) {
1782
+ arg = arg.slice(offset);
1783
+ }
1784
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1785
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1786
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1787
+
1788
+ offset += ret.written;
1789
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1790
+ }
1791
+
1792
+ WASM_VECTOR_LEN = offset;
1793
+ return ptr;
1794
+ }
1795
+
1796
+ function takeFromExternrefTable0(idx) {
1797
+ const value = wasm.__wbindgen_externrefs.get(idx);
1798
+ wasm.__externref_table_dealloc(idx);
1799
+ return value;
1800
+ }
1801
+
1802
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1803
+ cachedTextDecoder.decode();
1804
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1805
+ let numBytesDecoded = 0;
1806
+ function decodeText(ptr, len) {
1807
+ numBytesDecoded += len;
1808
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1809
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1810
+ cachedTextDecoder.decode();
1811
+ numBytesDecoded = len;
1812
+ }
1813
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1814
+ }
1815
+
1816
+ const cachedTextEncoder = new TextEncoder();
1817
+
1818
+ if (!('encodeInto' in cachedTextEncoder)) {
1819
+ cachedTextEncoder.encodeInto = function (arg, view) {
1820
+ const buf = cachedTextEncoder.encode(arg);
1821
+ view.set(buf);
1822
+ return {
1823
+ read: arg.length,
1824
+ written: buf.length
1825
+ };
1826
+ };
1827
+ }
1828
+
1829
+ let WASM_VECTOR_LEN = 0;
1830
+
1831
+ let wasmModule, wasm;
1832
+ function __wbg_finalize_init(instance, module) {
1833
+ wasm = instance.exports;
1834
+ wasmModule = module;
1835
+ cachedDataViewMemory0 = null;
1836
+ cachedUint8ArrayMemory0 = null;
1837
+ wasm.__wbindgen_start();
1838
+ return wasm;
1839
+ }
1840
+
1841
+ async function __wbg_load(module, imports) {
1842
+ if (typeof Response === 'function' && module instanceof Response) {
1843
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1844
+ try {
1845
+ return await WebAssembly.instantiateStreaming(module, imports);
1846
+ } catch (e) {
1847
+ const validResponse = module.ok && expectedResponseType(module.type);
1848
+
1849
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1850
+ 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);
1851
+
1852
+ } else { throw e; }
1853
+ }
1854
+ }
1855
+
1856
+ const bytes = await module.arrayBuffer();
1857
+ return await WebAssembly.instantiate(bytes, imports);
1858
+ } else {
1859
+ const instance = await WebAssembly.instantiate(module, imports);
1860
+
1861
+ if (instance instanceof WebAssembly.Instance) {
1862
+ return { instance, module };
1863
+ } else {
1864
+ return instance;
1865
+ }
1866
+ }
1867
+
1868
+ function expectedResponseType(type) {
1869
+ switch (type) {
1870
+ case 'basic': case 'cors': case 'default': return true;
1871
+ }
1872
+ return false;
1873
+ }
1874
+ }
1875
+
1876
+ function initSync(module) {
1877
+ if (wasm !== undefined) return wasm;
1878
+
1879
+
1880
+ if (module !== undefined) {
1881
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1882
+ ({module} = module)
1883
+ } else {
1884
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1885
+ }
1886
+ }
1887
+
1888
+ const imports = __wbg_get_imports();
1889
+ if (!(module instanceof WebAssembly.Module)) {
1890
+ module = new WebAssembly.Module(module);
1891
+ }
1892
+ const instance = new WebAssembly.Instance(module, imports);
1893
+ return __wbg_finalize_init(instance, module);
1894
+ }
1895
+
1896
+ async function __wbg_init(module_or_path) {
1897
+ if (wasm !== undefined) return wasm;
1898
+
1899
+
1900
+ if (module_or_path !== undefined) {
1901
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1902
+ ({module_or_path} = module_or_path)
1903
+ } else {
1904
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1905
+ }
1906
+ }
1907
+
1908
+ if (module_or_path === undefined) {
1909
+ module_or_path = new URL('lindera_wasm_bg.wasm', import.meta.url);
1910
+ }
1911
+ const imports = __wbg_get_imports();
1912
+
1913
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1914
+ module_or_path = fetch(module_or_path);
1915
+ }
1916
+
1917
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1918
+
1919
+ return __wbg_finalize_init(instance, module);
1920
+ }
1921
+
1922
+ export { initSync, __wbg_init as default };