@dinoxx/dinox-cli 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/tokenize.js +6 -17
- package/package.json +5 -6
package/dist/utils/tokenize.js
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
let jiebaReady = false;
|
|
1
|
+
import { Jieba } from '@node-rs/jieba';
|
|
2
|
+
import { dict } from '@node-rs/jieba/dict.js';
|
|
4
3
|
let jieba = null;
|
|
5
4
|
function ensureJiebaReady() {
|
|
6
|
-
if (
|
|
7
|
-
try {
|
|
8
|
-
jieba = require('nodejieba');
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
12
|
-
throw new Error(`Failed to load nodejieba module: ${message}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (jiebaReady) {
|
|
5
|
+
if (jieba) {
|
|
16
6
|
return;
|
|
17
7
|
}
|
|
18
8
|
try {
|
|
19
|
-
jieba.
|
|
20
|
-
jiebaReady = true;
|
|
9
|
+
jieba = Jieba.withDict(dict);
|
|
21
10
|
}
|
|
22
11
|
catch (error) {
|
|
23
12
|
const message = error instanceof Error ? error.message : String(error);
|
|
24
|
-
throw new Error(`Failed to initialize
|
|
13
|
+
throw new Error(`Failed to initialize @node-rs/jieba: ${message}`);
|
|
25
14
|
}
|
|
26
15
|
}
|
|
27
16
|
function normalizeToken(token) {
|
|
@@ -40,7 +29,7 @@ export function tokenizeWithJieba(text, limit = 500) {
|
|
|
40
29
|
return [];
|
|
41
30
|
}
|
|
42
31
|
ensureJiebaReady();
|
|
43
|
-
const raw = jieba.
|
|
32
|
+
const raw = jieba.cutForSearch(text, false);
|
|
44
33
|
const tokens = [];
|
|
45
34
|
for (const token of raw) {
|
|
46
35
|
const normalized = normalizeToken(token);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dinoxx/dinox-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Dinox CLI",
|
|
5
5
|
"main": "dist/dinox.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"node": ">=20"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@powersync/
|
|
33
|
+
"@node-rs/jieba": "^2.0.1",
|
|
34
|
+
"@powersync/common": "^1.47.0",
|
|
35
|
+
"@powersync/node": "^0.17.1",
|
|
35
36
|
"@tiptap/core": "^3.20.0",
|
|
36
37
|
"@tiptap/extension-image": "^3.20.0",
|
|
37
38
|
"@tiptap/extension-list": "^3.20.0",
|
|
@@ -41,7 +42,6 @@
|
|
|
41
42
|
"@tiptap/starter-kit": "^3.20.0",
|
|
42
43
|
"better-sqlite3": "^12.6.2",
|
|
43
44
|
"commander": "^14.0.3",
|
|
44
|
-
"nodejieba": "^3.5.2",
|
|
45
45
|
"remark-gfm": "^4.0.1",
|
|
46
46
|
"remark-parse": "^11.0.0",
|
|
47
47
|
"remark-stringify": "^11.0.0",
|
|
@@ -58,8 +58,7 @@
|
|
|
58
58
|
"pnpm": {
|
|
59
59
|
"onlyBuiltDependencies": [
|
|
60
60
|
"better-sqlite3",
|
|
61
|
-
"esbuild"
|
|
62
|
-
"nodejieba"
|
|
61
|
+
"esbuild"
|
|
63
62
|
]
|
|
64
63
|
}
|
|
65
64
|
}
|