OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-sensory commits / 4e86ab9

Sandbox prototyping
4e86ab969392c726bde45434fb07b52183ccef8a
by Linas Vepstas <linas@linas.org> · 2026-01-09T02:15:05.000Z

Changed files (1) +142 -8

sandbox/count.scm +142 -8
……@@ -1,6 +1,8 @@
11;
22; count.scm
3; Attempt to count things.
3; Attempt to count things. Scratchpad.
4; Final clean version in atomspace/examples/flow/count-pipeline.scm
5;
46(use-modules (opencog))
57
68(define get-all-types
……@@ -98,17 +100,20 @@
98100 (Lambda
99101 (VariableList (Variable "left") (Variable "right"))
100102 (Not
101 (GreaterThan
103 (LessThan
102104 (ElementOf (Number 2)
103105 (ValueOf (Variable "left") (Predicate "cnt")))
104106 (ElementOf (Number 2)
105107 (ValueOf (Variable "right") (Predicate "cnt")))))))
106108
107(define x
108 (SortedValue
109(Pipe
110 (Name "sorted-types")
111 (LinkSignature
112 (TypeNode 'SortedValue)
109113 (DefinedPredicate "count-order")
110114 (Name "unique-types")))
111115
116(cog-execute! (Name "sorted-types"))
112117
113118; Debug print
114119(cog-execute!
……@@ -119,11 +124,140 @@
119124 (LinkSignature (Type 'LinkValue)
120125 (Variable "$typ")
121126 (ValueOf (Variable "$typ") (Predicate "cnt"))))
122 (Name "unique-types")))
127 (Name "sorted-types")))
123128
129; --------------------
130(define (data-printer NAME COUNT)
131 (StringValue
132 (format #f "Usage count of type: ~A ~A"
133 (cog-value-ref COUNT 2)
134 (cog-name NAME))))
124135
136; --------------------
125137(cog-execute!
126 (CollectionOf
127(TypeNode 'SortedValue)
128 (Name "unique-types")))
138 (Filter
139 (Rule
140 (TypedVariable (Variable "$typ") (Type 'Type)) ; vardecl
141 (Variable "$typ") ; body - accept everything
142 (ExecutionOutput
143 (GroundedSchema "scm:data-printer")
144 (LinkSignature (Type 'LinkValue)
145 (Variable "$typ")
146 (ValueOf (Variable "$typ") (Predicate "cnt")))))
147 (Name "sorted-types")))
148
149(cog-execute!
150 (Filter
151 (Rule
152 (TypedVariable (Variable "$typ") (Type 'Type)) ; vardecl
153 ; Specify a body that rejects types without counts.
154 (And
155 (Present (Variable "$typ"))
156 (Equal
157 (Type 'FloatValue)
158 (TypeOf (ValueOf (Variable "$typ") (Predicate "cnt")))))
159 (ExecutionOutput
160 (GroundedSchema "scm:data-printer")
161 (LinkSignature (Type 'LinkValue)
162 (Variable "$typ")
163 (ValueOf (Variable "$typ") (Predicate "cnt")))))
164 (Name "sorted-types")))
165
166(cog-execute!
167 (Filter
168 (Rule
169 (TypedVariable (Variable "$typ") (Type 'Type)) ; vardecl
170 ; Specify a body that rejects types without counts.
171 (And
172 (Present (Variable "$typ"))
173 (Equal
174 (Type 'FloatValue)
175 (TypeOf (ValueOf (Variable "$typ") (Predicate "cnt")))))
176 (LinkSignature (Type 'LinkValue)
177 (Node "Usage count of type: ")
178 (Variable "$typ")
179 (Node " is equal to ")
180 (ElementOf (Number 2)
181 (ValueOf (Variable "$typ") (Predicate "cnt")))))
182 (Name "sorted-types")))
183
184(cog-execute!
185 (Filter
186 (Rule
187 (TypedVariable (Variable "$typ") (Type 'Type)) ; vardecl
188 ; Specify a body that rejects types without counts.
189 (And
190 (Present (Variable "$typ"))
191 (Equal
192 (Type 'FloatValue)
193 (TypeOf (ValueOf (Variable "$typ") (Predicate "cnt")))))
194 (LinkSignature (Type 'LinkValue)
195 (Node "Usage count of type: ")
196 (Variable "$typ")
197 (Node " is equal to ")
198 (ElementOf (Number 2)
199 (ValueOf (Variable "$typ") (Predicate "cnt")))))
200 (Name "sorted-types")))
201
202
203(cog-execute!
204 (CollectionOf (Type 'StringValue) (Name "list of structures")))
205
206(cog-execute!
207 (Concatenate (Type 'StringValue) (Name "list of structures")))
208
209(cog-execute!
210 (LinkSignature
211 (Signature
212 (Type 'StringValue)
213 (Type 'StringValue)
214 (Type 'StringValue)
215 (Type 'StringValue))
216 (Name "list of structures")))
217
218
219(cog-execute!
220 (Filter
221 (Rule
222 (VariableList
223 (Variable "$a")
224 (Variable "$b")
225 (Variable "$c")
226 (Variable "$d"))
227 (LinkSignature (Type 'LinkValue)
228 (Variable "$a")
229 (Variable "$b")
230 (Variable "$c")
231 (Variable "$d"))
232 (LinkSignature (Type 'LinkValue)
233 (LinkSignature (Type 'StringValue) (Variable "$a"))
234 (LinkSignature (Type 'StringValue) (Variable "$b"))
235 (LinkSignature (Type 'StringValue) (Variable "$c"))
236 (LinkSignature (Type 'StringValue) (Variable "$d"))))
237 (Name "list of structures")))
238
239
240(cog-execute!
241 (LinkSignature (Type 'StringValue) (Number 3)))
242;; ---------
243 (Rule
244 (VariableList
245 (TypedVariable (Variable "$typ") (Type 'Type))
246 (TypedVariable (Variable "$cnt") (Type 'FloatValue)) ; vardecl
247 ; Specify a body that rejects types without counts.
248 (And
249 (Present (Variable "$typ"))
250 (Equal
251 (Variable "$cnt")
252 (ValueOf (Variable "$typ") (Predicate "cnt"))))
253
254GuardLink
255
256(cog-execute!
257 (Filter
258 (Equal
259 (Type 'FloatValue)
260 (TypeOf (ValueOf (Variable "$typ") (Predicate "cnt"))))
261 (Name "sorted-types")))
129262
263; --------------------------