update package;fix: input data model ui (#4181)

* update package

* fix: ts

* update config

* update jieba package

* add type sign

* fix: input data ui
This commit is contained in:
Archer
2025-03-15 23:49:32 +08:00
committed by GitHub
parent f406c64d3c
commit e3eb05beed
34 changed files with 5090 additions and 5376 deletions

View File

@@ -1,4 +1,13 @@
import { cut } from '@node-rs/jieba';
import { Jieba } from '@node-rs/jieba';
import fs from 'fs';
import path from 'path';
// 使用 require.resolve 获取包的路径,然后拼接字典文件路径
const jiebaPath = path.dirname(require.resolve('@node-rs/jieba/package.json'));
const dictPath = path.join(jiebaPath, 'dict.txt');
// 使用正确的文件路径加载字典
const jieba = Jieba.withDict(fs.readFileSync(dictPath));
const stopWords = new Set([
'--',
@@ -1509,8 +1518,8 @@ const stopWords = new Set([
]
]);
export function jiebaSplit({ text }: { text: string }) {
const tokens = cut(text, true);
export async function jiebaSplit({ text }: { text: string }) {
const tokens = (await jieba.cutAsync(text, true)) as string[];
return (
tokens