MCPcopy Create free account
hub / github.com/astercloud/aster / detectContradictions

Method detectContradictions

pkg/memory/quality_analyzer.go:74–97  ·  view source on GitHub ↗

detectContradictions 检测矛盾信息

(memories []MemoryWithScore)

Source from the content-addressed store, hash-verified

72
73// detectContradictions 检测矛盾信息
74func (qa *QualityAnalyzer) detectContradictions(memories []MemoryWithScore) []Inconsistency {
75 inconsistencies := []Inconsistency{}
76
77 // 简化版:检查内容中的否定关系
78 for i := range memories {
79 for j := i + 1; j < len(memories); j++ {
80 if qa.areContradictory(memories[i], memories[j]) {
81 severity := qa.calculateContradictionSeverity(memories[i], memories[j])
82 inconsistencies = append(inconsistencies, Inconsistency{
83 Type: InconsistencyContradiction,
84 MemoryID1: memories[i].DocID,
85 MemoryID2: memories[j].DocID,
86 Description: fmt.Sprintf("记忆存在矛盾:'%s' vs '%s'",
87 truncate(memories[i].Text, 50),
88 truncate(memories[j].Text, 50)),
89 Severity: severity,
90 DetectedAt: time.Now(),
91 })
92 }
93 }
94 }
95
96 return inconsistencies
97}
98
99// areContradictory 检查两个记忆是否矛盾
100func (qa *QualityAnalyzer) areContradictory(mem1, mem2 MemoryWithScore) bool {

Callers 3

TestDetectContradictionsFunction · 0.95
DetectInconsistenciesMethod · 0.95

Calls 3

areContradictoryMethod · 0.95
truncateFunction · 0.70

Tested by 2

TestDetectContradictionsFunction · 0.76