OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-agents commits / ae8afd6

Onwards ho through the demo
ae8afd614930186016fce51bbebb6cc8edfefdb8
by Linas Vepštas <linasvepstas@gmail.com> · 2024-05-03T05:53:26.000Z

Changed files (1) +19 -13

examples/pair-count.scm +19 -13
……@@ -173,8 +173,15 @@
173173(cog-execute! demo-filter)
174174
175175; Same as above, but this time, ignore the words, and get the edges.
176; Also, apply the function FUNKY to the edge-list. This will be a handy
177; place to wire in further processing.
176; Also, apply the function FUNKY to the edge-list.
177; This function is meant to be a handy place to wire in more processing,
178;
179; Note that the result of parsing appears to be double-wrapped in
180; LinkValue. The reason becomes more apparent if one asks for more
181; than just one parse: the outer LinkValue groups all of the parses,
182; while the inner one groups the edges in one parse. Thus, the
183; function FUNKY will be called once per parse, and its argument
184; will be the list of words in that parse.
178185(define (edge-filter FUNKY)
179186 (Filter
180187 (Rule
……@@ -201,7 +208,9 @@
201208(define (incr-cnt edge)
202209 (SetValue edge (Predicate "count")
203210 (Plus (Number 0 0 1)
204 (FloatValueOf edge (Predicate "count") (FloatValueOf (Number 0 0 0))))))
211 (FloatValueOf edge (Predicate "count")
212 ; The all-zeros provides an initial value, if not set.
213 (FloatValueOf (Number 0 0 0))))))
205214
206215; Try it:
207216(cog-execute! (incr-cnt (Concept "foobar")))
……@@ -213,21 +222,18 @@
213222; ... or, equivalently, in Atomese:
214223(cog-execute! (ValueOf (Concept "foobar") (Predicate "count")))
215224
216; Wire it into the earlier pipelines
217(define (edge-counter ITEM)
225; Use the previous utility function to wire the counter into
226; the parsing pipeline.
227(define (edge-counter EDGE-LIST)
218228 (Filter
219229 (Rule
220 ; (TypedVariable (Variable "$edge") (Type 'Edge))
221 (LinkSignature
222 (Type 'LinkValue)
230 (TypedVariable (Variable "$edge") (Type 'Edge))
223231 (Variable "$edge")
224)
225 (debug-prt (Variable "$edge")))
226 ITEM))
232 (incr-cnt (Variable "$edge")))
233 EDGE-LIST))
227234
228 ; (incr-cnt (Variable "$edge")))
235; Run it. Watch the counts increment
229236(cog-execute! (edge-filter edge-counter))
230(cog-execute! (edge-filter debug-prt))
231237
232238
233239; --------------------------------------------------------------