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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user