lindera 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +345 -0
- package/index.d.ts +606 -0
- package/index.js +723 -0
- package/package.json +70 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* A morphological analysis dictionary.
|
|
5
|
+
*
|
|
6
|
+
* Contains the data structures needed for tokenization and morphological analysis.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Dictionary {
|
|
9
|
+
/** Returns the name of the dictionary metadata. */
|
|
10
|
+
metadataName(): string
|
|
11
|
+
/** Returns the character encoding of the dictionary. */
|
|
12
|
+
metadataEncoding(): string
|
|
13
|
+
/** Returns the full metadata object of the dictionary. */
|
|
14
|
+
metadata(): JsMetadata
|
|
15
|
+
}
|
|
16
|
+
export type JsDictionary = Dictionary
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Dictionary metadata configuration.
|
|
20
|
+
*
|
|
21
|
+
* A thin napi wrapper over [`lindera_binding_core::CoreMetadata`], which owns
|
|
22
|
+
* the default values and the schema wiring.
|
|
23
|
+
*/
|
|
24
|
+
export declare class Metadata {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new Metadata with optional configuration.
|
|
27
|
+
*
|
|
28
|
+
* # Arguments
|
|
29
|
+
*
|
|
30
|
+
* * `options` - Optional configuration object. When omitted, all defaults are used.
|
|
31
|
+
*/
|
|
32
|
+
constructor(options?: MetadataOptions | undefined | null)
|
|
33
|
+
/**
|
|
34
|
+
* Creates a Metadata with all default values.
|
|
35
|
+
*
|
|
36
|
+
* # Returns
|
|
37
|
+
*
|
|
38
|
+
* A Metadata instance with default configuration.
|
|
39
|
+
*/
|
|
40
|
+
static createDefault(): Metadata
|
|
41
|
+
/**
|
|
42
|
+
* Loads metadata from a JSON file.
|
|
43
|
+
*
|
|
44
|
+
* # Arguments
|
|
45
|
+
*
|
|
46
|
+
* * `path` - Path to the JSON metadata file.
|
|
47
|
+
*
|
|
48
|
+
* # Returns
|
|
49
|
+
*
|
|
50
|
+
* A Metadata instance loaded from the file.
|
|
51
|
+
*/
|
|
52
|
+
static fromJsonFile(path: string): Metadata
|
|
53
|
+
/** Dictionary name. */
|
|
54
|
+
get name(): string
|
|
55
|
+
/** Sets the dictionary name. */
|
|
56
|
+
set name(name: string)
|
|
57
|
+
/** Character encoding. */
|
|
58
|
+
get encoding(): string
|
|
59
|
+
/** Sets the character encoding. */
|
|
60
|
+
set encoding(encoding: string)
|
|
61
|
+
/** Default word cost. */
|
|
62
|
+
get defaultWordCost(): number
|
|
63
|
+
/** Sets the default word cost. */
|
|
64
|
+
set defaultWordCost(cost: number)
|
|
65
|
+
/** Default left context ID. */
|
|
66
|
+
get defaultLeftContextId(): number
|
|
67
|
+
/** Sets the default left context ID. */
|
|
68
|
+
set defaultLeftContextId(id: number)
|
|
69
|
+
/** Default right context ID. */
|
|
70
|
+
get defaultRightContextId(): number
|
|
71
|
+
/** Sets the default right context ID. */
|
|
72
|
+
set defaultRightContextId(id: number)
|
|
73
|
+
/** Default field value for missing fields. */
|
|
74
|
+
get defaultFieldValue(): string
|
|
75
|
+
/** Sets the default field value. */
|
|
76
|
+
set defaultFieldValue(value: string)
|
|
77
|
+
/** Whether flexible CSV parsing is enabled. */
|
|
78
|
+
get flexibleCsv(): boolean
|
|
79
|
+
/** Sets flexible CSV parsing. */
|
|
80
|
+
set flexibleCsv(value: boolean)
|
|
81
|
+
/** Whether to skip entries with invalid cost or ID. */
|
|
82
|
+
get skipInvalidCostOrId(): boolean
|
|
83
|
+
/** Sets whether to skip invalid entries. */
|
|
84
|
+
set skipInvalidCostOrId(value: boolean)
|
|
85
|
+
/** Whether to normalize morphological details. */
|
|
86
|
+
get normalizeDetails(): boolean
|
|
87
|
+
/** Sets whether to normalize details. */
|
|
88
|
+
set normalizeDetails(value: boolean)
|
|
89
|
+
/**
|
|
90
|
+
* Returns a plain object representation of the metadata.
|
|
91
|
+
*
|
|
92
|
+
* # Returns
|
|
93
|
+
*
|
|
94
|
+
* A HashMap containing all metadata properties as strings.
|
|
95
|
+
*/
|
|
96
|
+
toObject(): Record<string, string>
|
|
97
|
+
}
|
|
98
|
+
export type JsMetadata = Metadata
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Dictionary schema definition.
|
|
102
|
+
*
|
|
103
|
+
* A thin napi wrapper over [`lindera_binding_core::CoreSchema`], which owns the
|
|
104
|
+
* field storage, the name-to-index map, and the field lookups.
|
|
105
|
+
*/
|
|
106
|
+
export declare class Schema {
|
|
107
|
+
/**
|
|
108
|
+
* Creates a new schema with the specified field names.
|
|
109
|
+
*
|
|
110
|
+
* # Arguments
|
|
111
|
+
*
|
|
112
|
+
* * `fields` - Array of field name strings.
|
|
113
|
+
*/
|
|
114
|
+
constructor(fields: Array<string>)
|
|
115
|
+
/**
|
|
116
|
+
* Creates a default schema matching the IPADIC format (13 fields).
|
|
117
|
+
*
|
|
118
|
+
* # Returns
|
|
119
|
+
*
|
|
120
|
+
* A schema with the standard IPADIC field definitions.
|
|
121
|
+
*/
|
|
122
|
+
static createDefault(): Schema
|
|
123
|
+
/** Returns the field names in the schema. */
|
|
124
|
+
get fields(): Array<string>
|
|
125
|
+
/**
|
|
126
|
+
* Returns the index of the specified field name.
|
|
127
|
+
*
|
|
128
|
+
* # Arguments
|
|
129
|
+
*
|
|
130
|
+
* * `field_name` - Name of the field to look up.
|
|
131
|
+
*
|
|
132
|
+
* # Returns
|
|
133
|
+
*
|
|
134
|
+
* The zero-based index of the field, or `undefined` if not found.
|
|
135
|
+
*/
|
|
136
|
+
getFieldIndex(fieldName: string): number | null
|
|
137
|
+
/** Returns the total number of fields in the schema. */
|
|
138
|
+
fieldCount(): number
|
|
139
|
+
/**
|
|
140
|
+
* Returns the field name at the specified index.
|
|
141
|
+
*
|
|
142
|
+
* # Arguments
|
|
143
|
+
*
|
|
144
|
+
* * `index` - Zero-based index.
|
|
145
|
+
*
|
|
146
|
+
* # Returns
|
|
147
|
+
*
|
|
148
|
+
* The field name, or `undefined` if the index is out of range.
|
|
149
|
+
*/
|
|
150
|
+
getFieldName(index: number): string | null
|
|
151
|
+
/**
|
|
152
|
+
* Returns the custom fields (index 4 and above).
|
|
153
|
+
*
|
|
154
|
+
* # Returns
|
|
155
|
+
*
|
|
156
|
+
* An array of custom field names.
|
|
157
|
+
*/
|
|
158
|
+
getCustomFields(): Array<string>
|
|
159
|
+
/**
|
|
160
|
+
* Returns all field names in the schema.
|
|
161
|
+
*
|
|
162
|
+
* # Returns
|
|
163
|
+
*
|
|
164
|
+
* An array of all field names.
|
|
165
|
+
*/
|
|
166
|
+
getAllFields(): Array<string>
|
|
167
|
+
/**
|
|
168
|
+
* Returns the field definition for the specified field name.
|
|
169
|
+
*
|
|
170
|
+
* # Arguments
|
|
171
|
+
*
|
|
172
|
+
* * `name` - Name of the field to look up.
|
|
173
|
+
*
|
|
174
|
+
* # Returns
|
|
175
|
+
*
|
|
176
|
+
* The field definition, or `undefined` if not found.
|
|
177
|
+
*/
|
|
178
|
+
getFieldByName(name: string): JsFieldDefinition | null
|
|
179
|
+
/**
|
|
180
|
+
* Validates that a CSV record matches the schema.
|
|
181
|
+
*
|
|
182
|
+
* # Arguments
|
|
183
|
+
*
|
|
184
|
+
* * `record` - Array of field values to validate.
|
|
185
|
+
*/
|
|
186
|
+
validateRecord(record: Array<string>): void
|
|
187
|
+
}
|
|
188
|
+
export type JsSchema = Schema
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Tokenizer for performing morphological analysis.
|
|
192
|
+
*
|
|
193
|
+
* The tokenizer processes text and returns tokens with their morphological features.
|
|
194
|
+
*/
|
|
195
|
+
export declare class Tokenizer {
|
|
196
|
+
/**
|
|
197
|
+
* Creates a new tokenizer with the given dictionary and mode.
|
|
198
|
+
*
|
|
199
|
+
* # Arguments
|
|
200
|
+
*
|
|
201
|
+
* * `dictionary` - Dictionary to use for tokenization.
|
|
202
|
+
* * `mode` - Tokenization mode ("normal" or "decompose"). Default: "normal".
|
|
203
|
+
* * `user_dictionary` - Optional user dictionary for custom words.
|
|
204
|
+
*/
|
|
205
|
+
constructor(dictionary: Dictionary, mode?: string | undefined | null, userDictionary?: UserDictionary | undefined | null)
|
|
206
|
+
/**
|
|
207
|
+
* Tokenizes the given text.
|
|
208
|
+
*
|
|
209
|
+
* Tokens are returned as plain JS objects owned by the JS heap, so
|
|
210
|
+
* they are reclaimed by ordinary GC and survive `JSON.stringify` /
|
|
211
|
+
* `structuredClone` / worker transfer without conversion.
|
|
212
|
+
*
|
|
213
|
+
* # Arguments
|
|
214
|
+
*
|
|
215
|
+
* * `text` - Text to tokenize.
|
|
216
|
+
*
|
|
217
|
+
* # Returns
|
|
218
|
+
*
|
|
219
|
+
* An array of token objects containing morphological features, in
|
|
220
|
+
* reading order.
|
|
221
|
+
*/
|
|
222
|
+
tokenize(text: string): Array<Token>
|
|
223
|
+
/**
|
|
224
|
+
* Tokenizes the given text and returns only the token surfaces.
|
|
225
|
+
*
|
|
226
|
+
* This is the fast path for wakati-style use: no Token objects are
|
|
227
|
+
* created and no morphological details are loaded, so it is
|
|
228
|
+
* significantly faster than `tokenize` when only the surface strings
|
|
229
|
+
* are needed. The surfaces equal `tokenize(text).map((t) => t.surface)`.
|
|
230
|
+
*
|
|
231
|
+
* # Arguments
|
|
232
|
+
*
|
|
233
|
+
* * `text` - Text to tokenize.
|
|
234
|
+
*
|
|
235
|
+
* # Returns
|
|
236
|
+
*
|
|
237
|
+
* An array of surface strings, in reading order.
|
|
238
|
+
*/
|
|
239
|
+
tokenizeSurfaces(text: string): Array<string>
|
|
240
|
+
/**
|
|
241
|
+
* Tokenizes the given text and returns N-best results.
|
|
242
|
+
*
|
|
243
|
+
* # Arguments
|
|
244
|
+
*
|
|
245
|
+
* * `text` - Text to tokenize.
|
|
246
|
+
* * `n` - Number of N-best results to return.
|
|
247
|
+
* * `unique` - If true, deduplicate results (default: false).
|
|
248
|
+
* * `cost_threshold` - Maximum cost difference from the best path (default: undefined).
|
|
249
|
+
*
|
|
250
|
+
* # Returns
|
|
251
|
+
*
|
|
252
|
+
* An array of NbestResult objects, each containing tokens and their cost.
|
|
253
|
+
*/
|
|
254
|
+
tokenizeNbest(text: string, n: number, unique?: boolean | undefined | null, costThreshold?: number | undefined | null): Array<NbestResult>
|
|
255
|
+
}
|
|
256
|
+
export type JsTokenizer = Tokenizer
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Builder for creating a Tokenizer with custom configuration.
|
|
260
|
+
*
|
|
261
|
+
* The builder pattern allows for fluent configuration of tokenizer parameters including
|
|
262
|
+
* dictionaries, modes, and filter pipelines.
|
|
263
|
+
*/
|
|
264
|
+
export declare class TokenizerBuilder {
|
|
265
|
+
/** Creates a new TokenizerBuilder with default configuration. */
|
|
266
|
+
constructor()
|
|
267
|
+
/**
|
|
268
|
+
* Loads configuration from a JSON file.
|
|
269
|
+
*
|
|
270
|
+
* # Arguments
|
|
271
|
+
*
|
|
272
|
+
* * `file_path` - Path to the configuration file.
|
|
273
|
+
*
|
|
274
|
+
* # Returns
|
|
275
|
+
*
|
|
276
|
+
* A new TokenizerBuilder with the loaded configuration.
|
|
277
|
+
*/
|
|
278
|
+
fromFile(filePath: string): TokenizerBuilder
|
|
279
|
+
/**
|
|
280
|
+
* Sets the tokenization mode.
|
|
281
|
+
*
|
|
282
|
+
* # Arguments
|
|
283
|
+
*
|
|
284
|
+
* * `mode` - Mode string ("normal" or "decompose").
|
|
285
|
+
*
|
|
286
|
+
* # Returns
|
|
287
|
+
*
|
|
288
|
+
* The builder itself (`this`), enabling method chaining.
|
|
289
|
+
*/
|
|
290
|
+
setMode(mode: string): this
|
|
291
|
+
/**
|
|
292
|
+
* Sets the dictionary path or URI.
|
|
293
|
+
*
|
|
294
|
+
* # Arguments
|
|
295
|
+
*
|
|
296
|
+
* * `path` - Path to the dictionary directory or embedded URI (e.g. "embedded://ipadic").
|
|
297
|
+
*
|
|
298
|
+
* # Returns
|
|
299
|
+
*
|
|
300
|
+
* The builder itself (`this`), enabling method chaining.
|
|
301
|
+
*/
|
|
302
|
+
setDictionary(path: string): this
|
|
303
|
+
/**
|
|
304
|
+
* Sets the user dictionary URI.
|
|
305
|
+
*
|
|
306
|
+
* # Arguments
|
|
307
|
+
*
|
|
308
|
+
* * `uri` - URI to the user dictionary.
|
|
309
|
+
*
|
|
310
|
+
* # Returns
|
|
311
|
+
*
|
|
312
|
+
* The builder itself (`this`), enabling method chaining.
|
|
313
|
+
*/
|
|
314
|
+
setUserDictionary(uri: string): this
|
|
315
|
+
/**
|
|
316
|
+
* Sets whether to keep whitespace in tokenization results.
|
|
317
|
+
*
|
|
318
|
+
* # Arguments
|
|
319
|
+
*
|
|
320
|
+
* * `keep_whitespace` - If true, whitespace tokens will be included in results.
|
|
321
|
+
*
|
|
322
|
+
* # Returns
|
|
323
|
+
*
|
|
324
|
+
* The builder itself (`this`), enabling method chaining.
|
|
325
|
+
*/
|
|
326
|
+
setKeepWhitespace(keepWhitespace: boolean): this
|
|
327
|
+
/**
|
|
328
|
+
* Appends a character filter to the preprocessing pipeline.
|
|
329
|
+
*
|
|
330
|
+
* # Arguments
|
|
331
|
+
*
|
|
332
|
+
* * `kind` - Type of character filter to add (e.g. "unicode_normalize", "mapping").
|
|
333
|
+
* * `args` - Optional filter arguments as a JSON-compatible object.
|
|
334
|
+
*
|
|
335
|
+
* # Returns
|
|
336
|
+
*
|
|
337
|
+
* The builder itself (`this`), enabling method chaining.
|
|
338
|
+
*/
|
|
339
|
+
appendCharacterFilter(kind: string, args?: any | undefined | null): this
|
|
340
|
+
/**
|
|
341
|
+
* Appends a token filter to the postprocessing pipeline.
|
|
342
|
+
*
|
|
343
|
+
* # Arguments
|
|
344
|
+
*
|
|
345
|
+
* * `kind` - Type of token filter to add (e.g. "lowercase", "japanese_stop_tags").
|
|
346
|
+
* * `args` - Optional filter arguments as a JSON-compatible object.
|
|
347
|
+
*
|
|
348
|
+
* # Returns
|
|
349
|
+
*
|
|
350
|
+
* The builder itself (`this`), enabling method chaining.
|
|
351
|
+
*/
|
|
352
|
+
appendTokenFilter(kind: string, args?: any | undefined | null): this
|
|
353
|
+
/**
|
|
354
|
+
* Builds the tokenizer with the configured settings.
|
|
355
|
+
*
|
|
356
|
+
* # Returns
|
|
357
|
+
*
|
|
358
|
+
* A configured Tokenizer instance ready for use.
|
|
359
|
+
*/
|
|
360
|
+
build(): JsTokenizer
|
|
361
|
+
}
|
|
362
|
+
export type JsTokenizerBuilder = TokenizerBuilder
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* A user-defined dictionary for custom words.
|
|
366
|
+
*
|
|
367
|
+
* User dictionaries allow you to add custom words and their morphological features
|
|
368
|
+
* that are not present in the main dictionary.
|
|
369
|
+
*/
|
|
370
|
+
export declare class UserDictionary {
|
|
371
|
+
|
|
372
|
+
}
|
|
373
|
+
export type JsUserDictionary = UserDictionary
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Builds a dictionary from source files.
|
|
377
|
+
*
|
|
378
|
+
* # Arguments
|
|
379
|
+
*
|
|
380
|
+
* * `input_dir` - Directory containing dictionary source files.
|
|
381
|
+
* * `output_dir` - Directory where the built dictionary will be saved.
|
|
382
|
+
* * `metadata` - Metadata configuration for the dictionary.
|
|
383
|
+
*/
|
|
384
|
+
export declare function buildDictionary(inputDir: string, outputDir: string, metadata: JsMetadata): void
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Builds a user dictionary from a CSV file.
|
|
388
|
+
*
|
|
389
|
+
* # Arguments
|
|
390
|
+
*
|
|
391
|
+
* * `kind` - Dictionary kind (reserved for future use).
|
|
392
|
+
* * `input_file` - Path to the CSV file containing user dictionary entries.
|
|
393
|
+
* * `output_dir` - Directory where the built user dictionary will be saved.
|
|
394
|
+
* * `metadata` - Optional metadata configuration. If omitted, default values are used.
|
|
395
|
+
*/
|
|
396
|
+
export declare function buildUserDictionary(kind: string, inputFile: string, outputDir: string, metadata?: JsMetadata | undefined | null): void
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Exports dictionary files from a trained model.
|
|
400
|
+
*
|
|
401
|
+
* # Arguments
|
|
402
|
+
*
|
|
403
|
+
* * `options` - Export options containing file paths.
|
|
404
|
+
*/
|
|
405
|
+
export declare function exportModel(options: ExportOptions): void
|
|
406
|
+
|
|
407
|
+
/** Options for exporting a trained model. */
|
|
408
|
+
export interface ExportOptions {
|
|
409
|
+
/** Path to the trained model file (.dat). */
|
|
410
|
+
model: string
|
|
411
|
+
/** Output directory for dictionary source files. */
|
|
412
|
+
output: string
|
|
413
|
+
/** Optional path to a base metadata.json file. */
|
|
414
|
+
metadata?: string
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Field definition in dictionary schema.
|
|
419
|
+
*
|
|
420
|
+
* Describes a single field in the dictionary entry format.
|
|
421
|
+
*/
|
|
422
|
+
export interface JsFieldDefinition {
|
|
423
|
+
/** Field index in the record. */
|
|
424
|
+
index: number
|
|
425
|
+
/** Field name. */
|
|
426
|
+
name: string
|
|
427
|
+
/** Field type. */
|
|
428
|
+
fieldType: JsFieldType
|
|
429
|
+
/** Optional description of the field. */
|
|
430
|
+
description?: string
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Field type in dictionary schema.
|
|
435
|
+
*
|
|
436
|
+
* Defines the type of a field in the dictionary entry.
|
|
437
|
+
*/
|
|
438
|
+
export declare const enum JsFieldType {
|
|
439
|
+
/** Surface form (word text) */
|
|
440
|
+
Surface = 'Surface',
|
|
441
|
+
/** Left context ID for morphological analysis */
|
|
442
|
+
LeftContextId = 'LeftContextId',
|
|
443
|
+
/** Right context ID for morphological analysis */
|
|
444
|
+
RightContextId = 'RightContextId',
|
|
445
|
+
/** Word cost (used in path selection) */
|
|
446
|
+
Cost = 'Cost',
|
|
447
|
+
/** Custom field (morphological features) */
|
|
448
|
+
Custom = 'Custom'
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Tokenization mode.
|
|
453
|
+
*
|
|
454
|
+
* Determines how text is segmented into tokens.
|
|
455
|
+
*
|
|
456
|
+
* - `Normal`: Standard tokenization based on dictionary cost.
|
|
457
|
+
* - `Decompose`: Decomposes compound words using penalty-based segmentation.
|
|
458
|
+
*/
|
|
459
|
+
export declare const enum JsMode {
|
|
460
|
+
/** Standard tokenization based on dictionary cost */
|
|
461
|
+
Normal = 'Normal',
|
|
462
|
+
/** Decompose compound words using penalty-based segmentation */
|
|
463
|
+
Decompose = 'Decompose'
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Penalty configuration for decompose mode.
|
|
468
|
+
*
|
|
469
|
+
* Controls how aggressively compound words are decomposed based on
|
|
470
|
+
* character type and length thresholds.
|
|
471
|
+
*/
|
|
472
|
+
export interface JsPenalty {
|
|
473
|
+
/** Length threshold for kanji sequences before applying penalty (default: 2). */
|
|
474
|
+
kanjiPenaltyLengthThreshold: number
|
|
475
|
+
/** Penalty value for long kanji sequences (default: 3000). */
|
|
476
|
+
kanjiPenaltyLengthPenalty: number
|
|
477
|
+
/** Length threshold for other character sequences before applying penalty (default: 7). */
|
|
478
|
+
otherPenaltyLengthThreshold: number
|
|
479
|
+
/** Penalty value for long other-character sequences (default: 1700). */
|
|
480
|
+
otherPenaltyLengthPenalty: number
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Loads a dictionary from the specified URI.
|
|
485
|
+
*
|
|
486
|
+
* # Arguments
|
|
487
|
+
*
|
|
488
|
+
* * `uri` - URI to the dictionary. Can be a file path or embedded dictionary URI
|
|
489
|
+
* (e.g. "embedded://ipadic").
|
|
490
|
+
*
|
|
491
|
+
* # Returns
|
|
492
|
+
*
|
|
493
|
+
* A loaded Dictionary object.
|
|
494
|
+
*/
|
|
495
|
+
export declare function loadDictionary(uri: string): Dictionary
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Loads a user dictionary from the specified URI.
|
|
499
|
+
*
|
|
500
|
+
* # Arguments
|
|
501
|
+
*
|
|
502
|
+
* * `uri` - URI to the user dictionary directory.
|
|
503
|
+
* * `metadata` - Metadata configuration for the user dictionary.
|
|
504
|
+
*
|
|
505
|
+
* # Returns
|
|
506
|
+
*
|
|
507
|
+
* A loaded UserDictionary object.
|
|
508
|
+
*/
|
|
509
|
+
export declare function loadUserDictionary(uri: string, metadata: JsMetadata): UserDictionary
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Options for creating a Metadata instance.
|
|
513
|
+
*
|
|
514
|
+
* All fields are optional. When omitted, default values are used.
|
|
515
|
+
*/
|
|
516
|
+
export interface MetadataOptions {
|
|
517
|
+
/** Dictionary name (default: "default"). */
|
|
518
|
+
name?: string
|
|
519
|
+
/** Character encoding (default: "UTF-8"). */
|
|
520
|
+
encoding?: string
|
|
521
|
+
/** Default cost for unknown words (default: -10000). */
|
|
522
|
+
defaultWordCost?: number
|
|
523
|
+
/** Default left context ID (default: 1288). */
|
|
524
|
+
defaultLeftContextId?: number
|
|
525
|
+
/** Default right context ID (default: 1288). */
|
|
526
|
+
defaultRightContextId?: number
|
|
527
|
+
/** Default value for missing fields (default: "*"). */
|
|
528
|
+
defaultFieldValue?: string
|
|
529
|
+
/** Allow flexible CSV parsing (default: false). */
|
|
530
|
+
flexibleCsv?: boolean
|
|
531
|
+
/** Skip entries with invalid cost or ID (default: false). */
|
|
532
|
+
skipInvalidCostOrId?: boolean
|
|
533
|
+
/** Normalize morphological details (default: false). */
|
|
534
|
+
normalizeDetails?: boolean
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* N-best tokenization result.
|
|
539
|
+
*
|
|
540
|
+
* Contains a list of tokens and their total path cost.
|
|
541
|
+
*/
|
|
542
|
+
export interface NbestResult {
|
|
543
|
+
/** Tokens in this result. */
|
|
544
|
+
tokens: Array<Token>
|
|
545
|
+
/** Total path cost of this tokenization. */
|
|
546
|
+
cost: number
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* A morphological token.
|
|
551
|
+
*
|
|
552
|
+
* Represents a single token from morphological analysis with its surface
|
|
553
|
+
* form, position information, and morphological details.
|
|
554
|
+
*/
|
|
555
|
+
export interface Token {
|
|
556
|
+
/** Surface form of the token. */
|
|
557
|
+
surface: string
|
|
558
|
+
/** Start byte position in the original text. */
|
|
559
|
+
byteStart: number
|
|
560
|
+
/** End byte position in the original text. */
|
|
561
|
+
byteEnd: number
|
|
562
|
+
/** Position index of the token. */
|
|
563
|
+
position: number
|
|
564
|
+
/** Word ID in the dictionary. */
|
|
565
|
+
wordId: number
|
|
566
|
+
/** Whether this token is an unknown word. */
|
|
567
|
+
isUnknown: boolean
|
|
568
|
+
/** Morphological details of the token. */
|
|
569
|
+
details: Array<string>
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Trains a morphological analysis model from an annotated corpus.
|
|
574
|
+
*
|
|
575
|
+
* # Arguments
|
|
576
|
+
*
|
|
577
|
+
* * `options` - Training options containing file paths and parameters.
|
|
578
|
+
*/
|
|
579
|
+
export declare function train(options: TrainOptions): void
|
|
580
|
+
|
|
581
|
+
/** Options for training a CRF model. */
|
|
582
|
+
export interface TrainOptions {
|
|
583
|
+
/** Path to the seed lexicon file (CSV format). */
|
|
584
|
+
seed: string
|
|
585
|
+
/** Path to the annotated training corpus. */
|
|
586
|
+
corpus: string
|
|
587
|
+
/** Path to the character definition file (char.def). */
|
|
588
|
+
charDef: string
|
|
589
|
+
/** Path to the unknown word definition file (unk.def). */
|
|
590
|
+
unkDef: string
|
|
591
|
+
/** Path to the feature definition file (feature.def). */
|
|
592
|
+
featureDef: string
|
|
593
|
+
/** Path to the rewrite rule definition file (rewrite.def). */
|
|
594
|
+
rewriteDef: string
|
|
595
|
+
/** Output path for the trained model file. */
|
|
596
|
+
output: string
|
|
597
|
+
/** L1 regularization cost (0.0-1.0, default: 0.01). */
|
|
598
|
+
lambda?: number
|
|
599
|
+
/** Maximum number of training iterations (default: 100). */
|
|
600
|
+
maxIter?: number
|
|
601
|
+
/** Number of threads (undefined = auto-detect CPU cores). */
|
|
602
|
+
maxThreads?: number
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** Returns the version of the lindera-nodejs package. */
|
|
606
|
+
export declare function version(): string
|