OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-agents commits / 453ac4a

Continue with the example demo
453ac4a3924affd9b3f37668d42125f037246612
by Linas Vepštas <linasvepstas@gmail.com> · 2024-05-03T04:29:57.000Z

Changed files (1) +18 -12

examples/pair-count.scm +18 -12
……@@ -79,13 +79,12 @@
7979; Run it and see.
8080(cog-execute! exo)
8181
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)
8485
8586(define (debug-prt x)
86 (ExecutionOutput
87 (GroundedSchema "scm: print-atom")
88 (List x)))
87 (ExecutionOutput (GroundedSchema "scm: print-atom") x))
8988
9089; --------------------------------------------------------------
9190; Create a filter that will extract just the edges from the compound
……@@ -166,24 +165,31 @@
166165; Run it.
167166(cog-execute! demo-filter)
168167
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
171172 (Filter
172173 (Rule
173174 ; 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.
174177 (LinkSignature
175178 (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
177183
178 ; Output
179 (debug-prt (Glob "$ftuff")))
184 ; Output clause
185 (debug-prt (Glob "$words")))
180186
181187 (LgParseBonds (Phrase "this is a test") (LgDict "any") (Number 1))))
182188
183189; Run it.
184(cog-execute! demo-filter)
185
190(cog-execute! word-filter)
186191
192; Same as above, but this time, ignore the words, and get the edges.
187193(define edge-filter
188194 (Filter
189195 (Rule