OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-sensory commits / 4860778

Start counting edges in the demo
48607780fa982d1767bb680b36affdc014139a3f
by Linas Vepštas <linasvepstas@gmail.com> · 2025-10-29T05:22:06.000Z

Changed files (1) +29 -2

examples/parse-pipeline.scm +29 -2
……@@ -26,7 +26,7 @@
2626; using nothing but a pure Atomese pipeline, continuing the below.
2727;
2828(use-modules (opencog) (opencog exec) (opencog sensory))
29(use-modules (opencog nlp) (opencog nlp lg-parse))
29(use-modules (opencog lg))
3030
3131; Before running this demo, copy `demo.txt` to the /tmp directory.
3232; (copy-file "demo.txt" "/tmp/demo.txt")
……@@ -135,10 +135,18 @@
135135; Sniff test. Does it work?
136136; (cog-execute! bonder)
137137
138; The above creates a double-wrapped list. Peel off one layer.
139(define unwrapper
140 (CollectionOfLink (Type 'FlatStream)
141 (OrderedLink bonder)))
142
143; Sniff test. Does it work?
144; (cog-value->list (cog-execute! unwrapper))
145
138146; Create the anchor for the word bonds
139147(cog-execute!
140148 (SetValue (Anchor "parse pipe") (Predicate "word bonds")
141 (DontExec bonder)))
149 (DontExec unwrapper)))
142150
143151; Anchor reference
144152(define bond-stream
……@@ -147,6 +155,25 @@
147155; Sniff test. Does it work?
148156; (cog-execute! bond-stream)
149157
158; --------------------------------------------------------
159; With the bonds between word-pairs available, one may now begin
160; statistical analysis. A good place to begin is simply counting
161; word-pairs.
162
163(define counter
164 (Filter
165 (Rule
166 (TypedVariable (Variable "$edge") (Type 'Edge))
167 (Variable "$edge")
168 (IncrementValueOn
169 (Variable "$edge")
170 (Predicate ":edge-count:")
171 (Number 1)))
172 bond-stream))
173
174; Sniff test. Does it work?
175; (cog-execute! counter)
176
150177
151178; --------------------------------------------------------
152179; The End! That's All, Folks!