ow
This commit is contained in:
1 parent
bcd8ebab67
commit
5f222a23b3
6 files changed
+207
-44
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using CloudBuilder.AI.Entity;
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using CloudBuilder.Topshelf.Python;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -184,7 +185,35 @@ namespace CloudBuilder.Topshelf.Utility
|
||||
return arg0;
|
||||
}
|
||||
|
||||
//public AiSentenceEntity[] AiParagraphs { get; set; }
|
||||
public void MatchPerson(AiSentenceViewEntity[] aiSentences, IRepository<AiSentenceEntity> repositoryAiSentenceEntity)
|
||||
{
|
||||
if (AiChapterPersons == null || AiChapterPersons.Length == 0) return;
|
||||
|
||||
AiSentenceEntity aiSentence;
|
||||
string dialogueName = string.Empty;
|
||||
foreach (AiSentenceViewEntity aiSentenceView in aiSentences)
|
||||
{
|
||||
dialogueName= string.Empty;
|
||||
if (aiSentenceView.DialogueIndc != YesNoPolicy.YES) continue;
|
||||
|
||||
if (aiSentences.Where(x => x.ChapterId == aiSentenceView.ChapterId && x.ParagraphId == aiSentenceView.ParagraphId).Count() > 1)
|
||||
{
|
||||
if (AiChapterPersons.Where(x => x.ChapterId == aiSentenceView.ChapterId && x.ParagraphIndex == aiSentenceView.ParagraphId && aiSentenceView.SentenceIndex == x.SentenceIndex).Any())
|
||||
{
|
||||
dialogueName = AiChapterPersons.Where(x => x.ChapterId == aiSentenceView.ChapterId && x.ParagraphIndex == aiSentenceView.ParagraphId && aiSentenceView.SentenceIndex == x.SentenceIndex).FirstOrDefault().PersonName;
|
||||
}
|
||||
|
||||
if (AiChapterPersons.Where(x => x.ChapterId == aiSentenceView.ChapterId && x.ParagraphIndex == aiSentenceView.ParagraphId && aiSentenceView.SentenceIndex != x.SentenceIndex && x.PersonName != dialogueName).Any())
|
||||
{
|
||||
aiSentenceView.PersonName = AiChapterPersons.Where(x =>x.ChapterId==aiSentenceView.ChapterId && x.ParagraphIndex == aiSentenceView.ParagraphId && aiSentenceView.SentenceIndex != x.SentenceIndex && x.PersonName != dialogueName).OrderBy(x => x.OrderIndex).FirstOrDefault().PersonName;
|
||||
}
|
||||
}
|
||||
|
||||
aiSentence = new AiSentenceEntity();
|
||||
ObjectCopyHelper.Copy(aiSentenceView, aiSentence);
|
||||
repositoryAiSentenceEntity.UpdateNow(aiSentence);
|
||||
}
|
||||
}
|
||||
|
||||
public AiSentenceEntity[] AiSentences { get; set; }
|
||||
|
||||
@@ -203,37 +232,4 @@ D -->|匹配失败| E{规则3:段落内最近人物};
|
||||
E -->|匹配成功| C;
|
||||
E -->|匹配失败| F[赋值默认值+标记异常];
|
||||
|
||||
规则 1:文本特征精准匹配(最高优先级)
|
||||
基于对话内容中的 “专属特征” 直接匹配说话者,避免上下文干扰:
|
||||
示例规则:
|
||||
对话内容特征 匹配的说话者
|
||||
包含 “第二元婴” 韩立
|
||||
包含 “银月所化” 银月
|
||||
包含 “本座 / 本尊” 反派角色
|
||||
|
||||
落地:维护一个 “特征 - 人物” 映射字典,匹配时优先使用:
|
||||
规则 2:紧邻旁白匹配(次高优先级)只找对话行 “紧邻的前 1-2 行旁白”,而非整个段落的旁白,避免跨越多个人物导致匹配错误:
|
||||
规则:仅检查对话行的前 1 行、前 2 行旁白(最多前 3 行),超过则停止;
|
||||
落地:修改向前查找的逻辑,限制查找范围
|
||||
|
||||
规则 3:排除无效人物(避免干扰)从旁白中提取人物时,过滤掉 “非核心人物”(如 “店小二”“路人”),只保留主要人物:
|
||||
落地:维护 “核心人物白名单”,提取人物时只保留白名单内的名称
|
||||
|
||||
3. 增加异常处理和人工校验(兜底保障)
|
||||
即使逻辑再完善,也会有边缘场景匹配错误,需通过 “异常标记 + 人工复核” 兜底:
|
||||
|
||||
步骤 1:标记可疑匹配结果对以下情况标记为 “可疑”,存入日志或单独字段:
|
||||
匹配到的人物在旁白中出现次数≥2(比如同一段落有韩立和银月,无法确定);
|
||||
对话行前后 3 行都没有找到人物,最终赋值为 “未知人物”;
|
||||
对话内容无任何特征,且段落内人物数量≥3;
|
||||
落地:为实体增加扩展字段(如IsSuspected),或生成异常日志
|
||||
|
||||
步骤 2:人工复核可疑数据
|
||||
规则:所有标记为 “可疑” 的匹配结果,必须经过人工复核后再更新到数据库;
|
||||
落地:生成 “可疑数据清单”(包含Guid、Content、PersonName),供运营 / 编辑人员校验,修正错误后重新填充。
|
||||
|
||||
|
||||
收集错误案例:记录每次匹配错误的场景(如 “银月的对话匹配给韩立”),分析错误原因;
|
||||
迭代特征字典:将错误案例转化为新的特征规则(如新增 “乌云”→银月,“元婴”→韩立);
|
||||
A/B 测试:对优化后的规则做小范围测试,对比匹配准确率,确认有效后全量上线。
|
||||
*/
|
||||
Reference in new issue
Block a user