koishi-plugin-chat-analyse 0.6.2 → 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 +2 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -871,7 +871,7 @@ var Analyse = class {
|
|
|
871
871
|
if (records.length === 0) return "暂无统计数据";
|
|
872
872
|
const allText = records.map((r) => r.content).join(" ");
|
|
873
873
|
const result = await this.nlp.process("zh", allText);
|
|
874
|
-
const words = result.stems.filter((stem) => stem.length > 1);
|
|
874
|
+
const words = (result.stems || []).filter((stem) => stem.length > 1);
|
|
875
875
|
const wordCounts = words.reduce((map, word) => {
|
|
876
876
|
map.set(word, (map.get(word) || 0) + 1);
|
|
877
877
|
return map;
|
|
@@ -905,7 +905,7 @@ var Analyse = class {
|
|
|
905
905
|
for (const [uid, messages] of messagesByUid.entries()) {
|
|
906
906
|
const allText = messages.join(" ");
|
|
907
907
|
const result = await this.nlp.process("zh", allText);
|
|
908
|
-
const words = result.stems.filter((stem) => stem.length > 1);
|
|
908
|
+
const words = (result.stems || []).filter((stem) => stem.length > 1);
|
|
909
909
|
if (words.length < 50) continue;
|
|
910
910
|
const uniqueWords = new Set(words);
|
|
911
911
|
const richness = uniqueWords.size / words.length;
|