| … | … | @@ -22,9 +22,11 @@ |
| 22 | 22 | ; Below is a toy pair-counting framework. It increments counts |
| 23 | 23 | ; on pairs, as well as on marginals. |
| 24 | 24 | |
| 25 | | ; Counts are located in the third slot of the TV predicate. |
| 25 | ; Counts are located in the third slot of the predicate. |
| 26 | ; Why the third? Historical precedent, plus it makes for a good demo: |
| 27 | ; one can work with vectors of numbers, as one pleases. |
| 26 | 28 | (define cvp (PredicateNode "*-CountingKey-*")) |
| 27 | | (define one (NumberNode 1)) |
| 29 | (define one (NumberNode 0 0 1)) |
| 28 | 30 | |
| 29 | 31 | (define (incr-counts THING-A THING-B) |
| 30 | 32 | (Trigger (IncrementValue |
| … | … | @@ -84,7 +86,7 @@ |
| 84 | 86 | |
| 85 | 87 | ; Get the value |
| 86 | 88 | (define (get-computed-value THING-A THING-B) |
| 87 | | (cog-value (List THING-A THING-B) (Predicate "MI Key"))) |
| 89 | (ValueOf (List THING-A THING-B) (Predicate "MI Key"))) |
| 88 | 90 | |
| 89 | 91 | (define (get-mi-stream STRING-A STRING-B) |
| 90 | 92 | (get-computed-value (Concept STRING-A) (Concept STRING-B))) |
| … | … | @@ -93,7 +95,7 @@ |
| 93 | 95 | ; OK, we're done. Lets see what happens. |
| 94 | 96 | |
| 95 | 97 | (install-mi "hello" "world") |
| 96 | | (get-mi-stream "hello" "world") |
| 98 | (Trigger (get-mi-stream "hello" "world")) |
| 97 | 99 | |
| 98 | 100 | ; Well, that's messy! But it does show the full structure of |
| 99 | 101 | ; what was set up. Note that the formulas were applied to the |
| … | … | @@ -110,7 +112,8 @@ |
| 110 | 112 | |
| 111 | 113 | ; We really only want the third number. So grab that. |
| 112 | 114 | (define (get-mi STRING-A STRING-B) |
| 113 | | (cog-value-ref (get-mi-stream STRING-A STRING-B) 2)) |
| 115 | (Trigger |
| 116 | (ElementOf (Number 2) (get-mi-stream STRING-A STRING-B)))) |
| 114 | 117 | |
| 115 | 118 | (get-mi "hello" "world") |
| 116 | 119 | |