| … | … | @@ -79,13 +79,12 @@ |
| 79 | 79 | ; Run it and see. |
| 80 | 80 | (cog-execute! exo) |
| 81 | 81 | |
| 82 | | ; Now, define the utility printer we actually need: |
| 83 | | (define (print-atom x) (format #t "Got ~A" x)) |
| 82 | ; Now, define the utility printer we actually need. |
| 83 | ; Use `x` as the return value, so that the printer is just a pass-thru. |
| 84 | (define (print-atom x) (format #t "Got ~A" x) x) |
| 84 | 85 | |
| 85 | 86 | (define (debug-prt x) |
| 86 | | (ExecutionOutput |
| 87 | | (GroundedSchema "scm: print-atom") |
| 88 | | (List x))) |
| 87 | (ExecutionOutput (GroundedSchema "scm: print-atom") x)) |
| 89 | 88 | |
| 90 | 89 | ; -------------------------------------------------------------- |
| 91 | 90 | ; Create a filter that will extract just the edges from the compound |
| … | … | @@ -166,24 +165,31 @@ |
| 166 | 165 | ; Run it. |
| 167 | 166 | (cog-execute! demo-filter) |
| 168 | 167 | |
| 169 | | ;Pair |
| 170 | | (define demo-filter |
| 168 | ; Extracting the desired components is easier if a printer is used for |
| 169 | ; debugging. This allows the innards of the match clause to be viewed |
| 170 | ; directly. |
| 171 | (define word-filter |
| 171 | 172 | (Filter |
| 172 | 173 | (Rule |
| 173 | 174 | ; Match clause - one per parse. |
| 175 | ; The LinkValue wraps two more: one holding the words |
| 176 | ; in the sentence, and another holding the word-pairs. |
| 174 | 177 | (LinkSignature |
| 175 | 178 | (Type 'LinkValue) |
| 176 | | (Glob "$stuff")) |
| 179 | (LinkSignature |
| 180 | (Type 'LinkValue) ; This matches the word-list |
| 181 | (Glob "$words")) |
| 182 | (Type 'LinkValue)) ; This matches the edge-list |
| 177 | 183 | |
| 178 | | ; Output |
| 179 | | (debug-prt (Glob "$ftuff"))) |
| 184 | ; Output clause |
| 185 | (debug-prt (Glob "$words"))) |
| 180 | 186 | |
| 181 | 187 | (LgParseBonds (Phrase "this is a test") (LgDict "any") (Number 1)))) |
| 182 | 188 | |
| 183 | 189 | ; Run it. |
| 184 | | (cog-execute! demo-filter) |
| 185 | | |
| 190 | (cog-execute! word-filter) |
| 186 | 191 | |
| 192 | ; Same as above, but this time, ignore the words, and get the edges. |
| 187 | 193 | (define edge-filter |
| 188 | 194 | (Filter |
| 189 | 195 | (Rule |