diff --git a/modules/story-summary/vector/retrieval/entity-lexicon.js b/modules/story-summary/vector/retrieval/entity-lexicon.js index 2df503d..c78b29e 100644 --- a/modules/story-summary/vector/retrieval/entity-lexicon.js +++ b/modules/story-summary/vector/retrieval/entity-lexicon.js @@ -10,6 +10,15 @@ import { getStateAtoms } from '../storage/state-store.js'; +// 人名词典黑名单:代词、标签词、明显非人物词 +const PERSON_LEXICON_BLACKLIST = new Set([ + '我', '你', '他', '她', '它', '我们', '你们', '他们', '她们', '它们', + '自己', '对方', '用户', '助手', 'user', 'assistant', + '男人', '女性', '成熟女性', '主人', '主角', + '龟头', '子宫', '阴道', '阴茎', + '电脑', '电脑屏幕', '手机', '监控画面', '摄像头', '阳光', '折叠床', '书房', '卫生间隔间', +]); + /** * 标准化字符串(用于实体匹配) * @param {string} s @@ -23,6 +32,10 @@ function normalize(s) { .toLowerCase(); } +function isBlacklistedPersonTerm(raw) { + return PERSON_LEXICON_BLACKLIST.has(normalize(raw)); +} + /** * 构建实体词典 * @@ -45,7 +58,9 @@ export function buildEntityLexicon(store, context) { // 内部辅助:添加非空实体 const add = (raw) => { const n = normalize(raw); - if (n && n.length >= 2) lexicon.add(n); + if (!n || n.length < 2) return; + if (isBlacklistedPersonTerm(n)) return; + lexicon.add(n); }; // 1. 主要角色 @@ -103,7 +118,9 @@ export function buildDisplayNameMap(store, context) { const register = (raw) => { const n = normalize(raw); - if (n && n.length >= 2 && !map.has(n)) { + if (!n || n.length < 2) return; + if (isBlacklistedPersonTerm(n)) return; + if (!map.has(n)) { map.set(n, String(raw).trim()); } };