mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
chore: change tokenizer to @node-rs/jieba
This commit is contained in:
parent
cd228128ba
commit
db72462b8e
2 changed files with 5 additions and 4 deletions
|
|
@ -25,12 +25,12 @@
|
|||
"ws": "^8.13.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@node-rs/jieba": "^1.6.2",
|
||||
"jimp": "^0.22.7",
|
||||
"node-silk": "^0.1.0",
|
||||
"puppeteer-extra": "^3.3.6",
|
||||
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
||||
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
||||
"sharp": "^0.31.3",
|
||||
"nodejieba": "^2.6.0"
|
||||
"sharp": "^0.31.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import { Config } from '../config.js'
|
|||
|
||||
let nodejieba
|
||||
try {
|
||||
nodejieba = (await import('nodejieba')).default
|
||||
nodejieba = (await import('@node-rs/jieba')).default
|
||||
} catch (err) {
|
||||
logger.info('未安装nodejieba,娱乐功能-词云统计不可用')
|
||||
}
|
||||
|
|
@ -60,6 +60,7 @@ export class Tokenizer {
|
|||
}
|
||||
let chats = await this.getTodayHistory(groupId)
|
||||
logger.mark(`聊天记录拉去完成,获取到今日内${chats.length}条聊天记录,准备分词中`)
|
||||
nodejieba.load()
|
||||
let chatContent = chats
|
||||
.map(c => c.raw_message
|
||||
.replaceAll('[图片]', '')
|
||||
|
|
@ -69,7 +70,7 @@ export class Tokenizer {
|
|||
)
|
||||
.map(c => nodejieba.extract(c, 10))
|
||||
.reduce((acc, curr) => acc.concat(curr), [])
|
||||
.map(c => c.word)
|
||||
.map(c => c.keyword)
|
||||
if (Config.debug) {
|
||||
logger.info(chatContent)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue