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

Function TestDetectContradictions

pkg/memory/quality_analyzer_test.go:24–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func TestDetectContradictions(t *testing.T) {
25 config := DefaultQualityMetricsConfig()
26 qm := NewQualityMetrics(config)
27 qa := NewQualityAnalyzer(qm, nil)
28
29 memories := []MemoryWithScore{
30 {
31 DocID: "mem1",
32 Text: "The user is online",
33 Provenance: NewProvenance(SourceUserInput, "user-1"),
34 },
35 {
36 DocID: "mem2",
37 Text: "The user is not online",
38 Provenance: NewProvenance(SourceUserInput, "user-2"),
39 },
40 {
41 DocID: "mem3",
42 Text: "The weather is nice",
43 Provenance: NewProvenance(SourceUserInput, "user-3"),
44 },
45 }
46
47 contradictions := qa.detectContradictions(memories)
48
49 // 应该检测到至少 1 个矛盾(mem1 vs mem2)
50 if len(contradictions) == 0 {
51 t.Error("should detect at least one contradiction")
52 }
53
54 // 验证矛盾信息
55 found := false
56 for _, inc := range contradictions {
57 if inc.Type == InconsistencyContradiction {
58 if (inc.MemoryID1 == "mem1" && inc.MemoryID2 == "mem2") ||
59 (inc.MemoryID1 == "mem2" && inc.MemoryID2 == "mem1") {
60 found = true
61 break
62 }
63 }
64 }
65
66 if !found {
67 t.Error("should detect contradiction between mem1 and mem2")
68 }
69}
70
71func TestDetectContradictions_Chinese(t *testing.T) {
72 config := DefaultQualityMetricsConfig()

Callers

nothing calls this directly

Calls 6

detectContradictionsMethod · 0.95
NewQualityMetricsFunction · 0.85
NewQualityAnalyzerFunction · 0.85
NewProvenanceFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected