koishi-plugin-chat-analyse 0.6.1 → 0.6.3
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/lib/index.js +3 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -839,6 +839,7 @@ var Analyse = class {
|
|
|
839
839
|
this.config = config;
|
|
840
840
|
this.renderer = new Renderer(ctx);
|
|
841
841
|
this.nlp = new import_basic.Nlp({ languages: ["zh"], nlu: { log: false } });
|
|
842
|
+
this.nlp.settings.autoSave = false;
|
|
842
843
|
this.nlp.container.register("extract-lang-zh", new import_lang_zh.LangZh());
|
|
843
844
|
this.initializeNlp().catch((err) => {
|
|
844
845
|
this.ctx.logger.error("NLP 语言模型加载失败:", err);
|
|
@@ -870,7 +871,7 @@ var Analyse = class {
|
|
|
870
871
|
if (records.length === 0) return "暂无统计数据";
|
|
871
872
|
const allText = records.map((r) => r.content).join(" ");
|
|
872
873
|
const result = await this.nlp.process("zh", allText);
|
|
873
|
-
const words = result.stems.filter((stem) => stem.length > 1);
|
|
874
|
+
const words = (result.stems || []).filter((stem) => stem.length > 1);
|
|
874
875
|
const wordCounts = words.reduce((map, word) => {
|
|
875
876
|
map.set(word, (map.get(word) || 0) + 1);
|
|
876
877
|
return map;
|
|
@@ -904,7 +905,7 @@ var Analyse = class {
|
|
|
904
905
|
for (const [uid, messages] of messagesByUid.entries()) {
|
|
905
906
|
const allText = messages.join(" ");
|
|
906
907
|
const result = await this.nlp.process("zh", allText);
|
|
907
|
-
const words = result.stems.filter((stem) => stem.length > 1);
|
|
908
|
+
const words = (result.stems || []).filter((stem) => stem.length > 1);
|
|
908
909
|
if (words.length < 50) continue;
|
|
909
910
|
const uniqueWords = new Set(words);
|
|
910
911
|
const richness = uniqueWords.size / words.length;
|