libchai 0.1.7 → 0.1.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # chai: 汉字自动拆分系统[命令行版]
2
2
 
3
- `chai` 是一个使用 Rust 编写的命令行程序。用户提供拆分表以及方案配置文件,本程序能够生成单字、词组的编码并评测一系列指标,以及基于退火算法优化元素的布局。
3
+ `chai` 是一个使用 Rust 编写的命令行程序。用户提供拆分表以及方案配置文件,本程序能够生成编码并评测一系列指标,以及基于退火算法优化元素的布局。
4
4
 
5
5
  ## 使用
6
6
 
@@ -18,26 +18,19 @@
18
18
 
19
19
  压缩包中有以下的示例文件:
20
20
 
21
- - `config.yaml`: 方案文件(米十五笔),具体的格式解释参见 [config.md](./config.md);这个文件也可以由[汉字自动拆分系统](https://chaifen.app/)生成;
21
+ - `config.yaml`: 方案文件(米十五笔),具体的格式解释参见 [config.md](https://github.com/hanzi-chai/docs/blob/main/docs/tutorial/config.md);这个文件也可以由[汉字自动拆分系统](https://chaifen.app/)生成;
22
22
  - `elements.txt`: 拆分表文件(米十五笔),每个字一行,每行的内容依次为汉字、制表符和以空格分隔的汉字拆分序列;这个文件也可由自动拆分系统生成;
23
- - `assets/character_frequency.txt`:字频文件,每个字一行,每行的内容为以制表符分隔的字和字频;
24
- - `assets/word_frequency.txt`:词频文件,每个字一行,每行的内容为以制表符分隔的词和词频;
25
- - `assets/key_equivalence.txt`:单键用指当量文件,每个按键一行,每行的内容为以制表符分隔的按键和当量;
23
+ - `assets/frequency.txt`:词频文件,每个字一行,每行的内容为以制表符分隔的词和词频;
24
+ - `assets/key_distribution.txt`:用指分布文件,每个按键一行,每行的内容为以制表符分隔的按键、目标频率、低频率惩罚系数、高频率惩罚系数;
26
25
  - `assets/pair_equivalence.txt`:双键速度当量文件,每个按键组合一行,每行的内容为以制表符分隔的按键组合和当量;
27
26
 
28
- 可执行文件支持两个不同的命令:`encode` 和 `optimize`,例如
27
+ 可执行文件支持三个不同的命令:`encode`, `evaluate` 和 `optimize`,例如
29
28
 
30
- ```bash
31
- ./chai encode
32
- ```
33
-
34
- 将使用方案文件和拆分表计算出字词编码并统计各类评测指标,而
35
-
36
- ```bash
37
- ./chai optimize
38
- ```
29
+ - `encode`:将使用方案文件和拆分表计算出字词编码
30
+ - `evaluate`:统计各类评测指标
31
+ - `optimize`:将基于拆分表和方案文件中的配置优化元素布局
39
32
 
40
- 将基于拆分表和方案文件中的配置优化元素布局。另外,如果方案文件和拆分表文件的路径不为以上的默认值,可以通过命令行参数提供,例如
33
+ 另外,如果方案文件和拆分表文件的路径不为以上的默认值,可以通过命令行参数提供,例如
41
34
 
42
35
  ```bash
43
36
  ./chai yima.yaml -e yima.txt optimize
package/chai.js CHANGED
@@ -20,6 +20,33 @@ function takeObject(idx) {
20
20
  return ret;
21
21
  }
22
22
 
23
+ function addHeapObject(obj) {
24
+ if (heap_next === heap.length) heap.push(heap.length + 1);
25
+ const idx = heap_next;
26
+ heap_next = heap[idx];
27
+
28
+ heap[idx] = obj;
29
+ return idx;
30
+ }
31
+
32
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
33
+
34
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
35
+
36
+ let cachedUint8Memory0 = null;
37
+
38
+ function getUint8Memory0() {
39
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
40
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
41
+ }
42
+ return cachedUint8Memory0;
43
+ }
44
+
45
+ function getStringFromWasm0(ptr, len) {
46
+ ptr = ptr >>> 0;
47
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
48
+ }
49
+
23
50
  function isLikeNone(x) {
24
51
  return x === undefined || x === null;
25
52
  }
@@ -44,15 +71,6 @@ function getInt32Memory0() {
44
71
 
45
72
  let WASM_VECTOR_LEN = 0;
46
73
 
47
- let cachedUint8Memory0 = null;
48
-
49
- function getUint8Memory0() {
50
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
51
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
52
- }
53
- return cachedUint8Memory0;
54
- }
55
-
56
74
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
57
75
 
58
76
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -107,24 +125,6 @@ function passStringToWasm0(arg, malloc, realloc) {
107
125
  return ptr;
108
126
  }
109
127
 
110
- function addHeapObject(obj) {
111
- if (heap_next === heap.length) heap.push(heap.length + 1);
112
- const idx = heap_next;
113
- heap_next = heap[idx];
114
-
115
- heap[idx] = obj;
116
- return idx;
117
- }
118
-
119
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
120
-
121
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
122
-
123
- function getStringFromWasm0(ptr, len) {
124
- ptr = ptr >>> 0;
125
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
126
- }
127
-
128
128
  let cachedBigInt64Memory0 = null;
129
129
 
130
130
  function getBigInt64Memory0() {
@@ -347,6 +347,22 @@ function __wbg_get_imports() {
347
347
  const ret = typeof(getObject(arg0)) === 'bigint';
348
348
  return ret;
349
349
  };
350
+ imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
351
+ const ret = arg0;
352
+ return addHeapObject(ret);
353
+ };
354
+ imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
355
+ const ret = getObject(arg0) === getObject(arg1);
356
+ return ret;
357
+ };
358
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
359
+ const ret = BigInt.asUintN(64, arg0);
360
+ return addHeapObject(ret);
361
+ };
362
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
363
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
364
+ return addHeapObject(ret);
365
+ };
350
366
  imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
351
367
  const obj = getObject(arg1);
352
368
  const ret = typeof(obj) === 'number' ? obj : undefined;
@@ -370,22 +386,6 @@ function __wbg_get_imports() {
370
386
  const ret = getObject(arg0) in getObject(arg1);
371
387
  return ret;
372
388
  };
373
- imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
374
- const ret = arg0;
375
- return addHeapObject(ret);
376
- };
377
- imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
378
- const ret = getObject(arg0) === getObject(arg1);
379
- return ret;
380
- };
381
- imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
382
- const ret = BigInt.asUintN(64, arg0);
383
- return addHeapObject(ret);
384
- };
385
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
386
- const ret = new Error(getStringFromWasm0(arg0, arg1));
387
- return addHeapObject(ret);
388
- };
389
389
  imports.wbg.__wbindgen_is_string = function(arg0) {
390
390
  const ret = typeof(getObject(arg0)) === 'string';
391
391
  return ret;
@@ -402,6 +402,18 @@ function __wbg_get_imports() {
402
402
  const ret = +getObject(arg0);
403
403
  return ret;
404
404
  };
405
+ imports.wbg.__wbindgen_number_new = function(arg0) {
406
+ const ret = arg0;
407
+ return addHeapObject(ret);
408
+ };
409
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
410
+ const ret = getObject(arg0);
411
+ return addHeapObject(ret);
412
+ };
413
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
414
+ const ret = getStringFromWasm0(arg0, arg1);
415
+ return addHeapObject(ret);
416
+ };
405
417
  imports.wbg.__wbg_getwithrefkey_4a92a5eca60879b9 = function(arg0, arg1) {
406
418
  const ret = getObject(arg0)[getObject(arg1)];
407
419
  return addHeapObject(ret);
@@ -409,10 +421,6 @@ function __wbg_get_imports() {
409
421
  imports.wbg.__wbg_set_9182712abebf82ef = function(arg0, arg1, arg2) {
410
422
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
411
423
  };
412
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
413
- const ret = getObject(arg0);
414
- return addHeapObject(ret);
415
- };
416
424
  imports.wbg.__wbg_String_389b54bd9d25375f = function(arg0, arg1) {
417
425
  const ret = String(getObject(arg1));
418
426
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -420,14 +428,6 @@ function __wbg_get_imports() {
420
428
  getInt32Memory0()[arg0 / 4 + 1] = len1;
421
429
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
422
430
  };
423
- imports.wbg.__wbindgen_number_new = function(arg0) {
424
- const ret = arg0;
425
- return addHeapObject(ret);
426
- };
427
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
428
- const ret = getStringFromWasm0(arg0, arg1);
429
- return addHeapObject(ret);
430
- };
431
431
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
432
432
  const ret = new Error();
433
433
  return addHeapObject(ret);
@@ -474,6 +474,10 @@ function __wbg_get_imports() {
474
474
  const ret = getObject(arg0).node;
475
475
  return addHeapObject(ret);
476
476
  };
477
+ imports.wbg.__wbg_msCrypto_10fc94afee92bd76 = function(arg0) {
478
+ const ret = getObject(arg0).msCrypto;
479
+ return addHeapObject(ret);
480
+ };
477
481
  imports.wbg.__wbg_require_9a7e0f667ead4995 = function() { return handleError(function () {
478
482
  const ret = module.require;
479
483
  return addHeapObject(ret);
@@ -482,10 +486,6 @@ function __wbg_get_imports() {
482
486
  const ret = typeof(getObject(arg0)) === 'function';
483
487
  return ret;
484
488
  };
485
- imports.wbg.__wbg_msCrypto_10fc94afee92bd76 = function(arg0) {
486
- const ret = getObject(arg0).msCrypto;
487
- return addHeapObject(ret);
488
- };
489
489
  imports.wbg.__wbg_randomFillSync_b70ccbdf4926a99d = function() { return handleError(function (arg0, arg1) {
490
490
  getObject(arg0).randomFillSync(takeObject(arg1));
491
491
  }, arguments) };
package/chai_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "Songchen Tan <i@tansongchen.com>"
5
5
  ],
6
- "version": "0.1.7",
6
+ "version": "0.1.9",
7
7
  "files": [
8
8
  "chai_bg.wasm",
9
9
  "chai.js",