| … | … | @@ -11,6 +11,10 @@ |
| 11 | 11 | |
| 12 | 12 | (use-modules (opencog matrix)) |
| 13 | 13 | |
| 14 | (define tvkey (Predicate "*-TruthValueKey-*")) |
| 15 | (define (get-count ATOM) |
| 16 | (cog-value-ref ATOM tvkey 2)) |
| 17 | |
| 14 | 18 | (opencog-test-runner) |
| 15 | 19 | |
| 16 | 20 | ; --------------------------------------------------------------- |
| … | … | @@ -32,20 +36,20 @@ |
| 32 | 36 | |
| 33 | 37 | ; Add one atom, verify that the marginals are updated. |
| 34 | 38 | (mgi 'pair-inc (Concept "foo") (Concept "bar") 42) |
| 35 | | (test-equal "left-marg" 42.0 (cog-count (epa 'left-wildcard (Concept "bar")))) |
| 36 | | (test-equal "right-marg" 42.0 (cog-count (epa 'right-wildcard (Concept "foo")))) |
| 37 | | (test-equal "tot" 42.0 (cog-count (epa 'wild-wild))) |
| 39 | (test-equal "left-marg" 42.0 (get-count (epa 'left-wildcard (Concept "bar")))) |
| 40 | (test-equal "right-marg" 42.0 (get-count (epa 'right-wildcard (Concept "foo")))) |
| 41 | (test-equal "tot" 42.0 (get-count (epa 'wild-wild))) |
| 38 | 42 | |
| 39 | 43 | ; Add a few more atoms. |
| 40 | 44 | (mgi 'pair-inc (Concept "foo") (Concept "bar2") 0.5) |
| 41 | 45 | (mgi 'pair-inc (Concept "foo2") (Concept "bar") 1.5) |
| 42 | 46 | |
| 43 | 47 | ; The original pair is untouched. |
| 44 | | (test-equal "pair" 42.0 (cog-count (epa 'make-pair (Concept "foo") (Concept "bar")))) |
| 48 | (test-equal "pair" 42.0 (get-count (epa 'make-pair (Concept "foo") (Concept "bar")))) |
| 45 | 49 | |
| 46 | 50 | ; The marginals should be accumulating. |
| 47 | | (test-equal "left-marg" 43.5 (cog-count (epa 'left-wildcard (Concept "bar")))) |
| 48 | | (test-equal "right-marg" 42.5 (cog-count (epa 'right-wildcard (Concept "foo")))) |
| 49 | | (test-equal "tot" 44.0 (cog-count (epa 'wild-wild))) |
| 51 | (test-equal "left-marg" 43.5 (get-count (epa 'left-wildcard (Concept "bar")))) |
| 52 | (test-equal "right-marg" 42.5 (get-count (epa 'right-wildcard (Concept "foo")))) |
| 53 | (test-equal "tot" 44.0 (get-count (epa 'wild-wild))) |
| 50 | 54 | |
| 51 | 55 | (test-end tmarg) |