OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-ure commits / b51b056

iMove more obsolete funcs out of the AtomSpace.
b51b056fe1d4505153ebebcfe28a230e38edcd7b
by Linas Vepštas <linasvepstas@gmail.com> · 2025-09-20T04:38:22.000Z

Changed files (1) +84 -39

opencog/scm/opencog/ure/ure-utils.scm +84 -39
……@@ -85,6 +85,90 @@
8585(use-modules (ice-9 receive))
8686(use-modules (ice-9 optargs))
8787
88; -----------------------------------------------------------------------
89(define-public (cog-map-chase-link link-type endpoint-type proc anchor)
90"
91 cog-map-chase-link -- Invoke proc on atom connected through type.
92
93 Similar to cog-chase-link, but invokes 'proc' on the wanted atom.
94 Starting at the atom 'anchor', chase its incoming links of
95 'link-type', and call procedure 'proc' on all of the atoms of
96 type 'endpoint-type' in those links. For example, if 'anchor' is the
97 node 'GivenNode \"a\"', and the atomspace contains
98
99 SomeLink
100 GivenNode \"a\"
101 WantedNode \"p\"
102
103 SomeLink
104 GivenNode \"a\"
105 WantedNode \"q\"
106
107 then 'proc' will be called twice, with each of the WantedNodes's
108 as the argument. These wanted nodes were found by following the
109 link type 'SomeLink, starting at the anchor GivenNode \"a\".
110
111 It is presumed that 'anchor' points to some atom (typically a node),
112 and that it has many links in its incoming set. So, loop over all of
113 the links of 'link-type' in this set. They presumably link to all
114 sorts of things. Find all of the things that are of 'endpoint-type'.
115 Apply proc to each of these.
116"
117 (define (get-endpoint w)
118 (map proc (cog-outgoing-by-type w endpoint-type))
119 )
120
121 ; We assume that anchor is a single atom, or empty list...
122 (if (null? anchor)
123 '()
124 (map get-endpoint (cog-incoming-by-type anchor link-type))
125 )
126)
127
128; -----------------------------------------------------------------------
129(define-public (cog-chase-link link-type endpoint-type anchor)
130"
131 cog-chase-link -- Return other atom of a link connecting two atoms.
132
133 cog-chase-link link-type endpoint-type anchor
134
135 Starting at the atom 'anchor', chase its incoming links of
136 'link-type', and return a list of all of the atoms of type
137 'endpoint-type' in those links. For example, if 'anchor' is the
138 node 'GivenNode \"a\"', and the atomspace contains
139
140 SomeLink
141 GivenNode \"a\"
142 WantedNode \"p\"
143 SomeLink
144 GivenNode \"a\"
145 WantedNode \"q\"
146
147 then this method will return the two WantedNodes's, given the
148 GivenNode as anchor, and the link-type 'SomeLink.
149
150 viz: (cog-chase-link 'SomeLink 'WantedNode (GivenNode \"a\")) will
151 return ((WantedNode \"p\") (WantedNode \"q\"))
152
153 It is presumed that 'anchor' points to some atom (typically a node),
154 and that it has many links in its incoming set. So, loop over all of
155 the links of 'link-type' in this set. They presumably link to all
156 sorts of things. Find all of the things that are of 'endpoint-type'.
157 Return a list of all of these.
158
159 See also: cgw-follow-link, which does the same thing, but for wires.
160"
161 (let ((lst '()))
162 (define (mklist inst)
163 (set! lst (cons inst lst))
164 #f
165 )
166 (cog-map-chase-link link-type endpoint-type mklist anchor)
167 lst
168 )
169)
170
171; -----------------------------------------------------------------------
88172(define* (cog-fc rbs source
89173 #:key
90174 (vardecl (List))
……@@ -670,45 +754,6 @@
670754 (cog-set-atomspace! current-as)
671755 rules))
672756
673(define-public (cog-map-chase-link link-type endpoint-type proc anchor)
674"
675 cog-map-chase-link -- Invoke proc on atom connected through type.
676
677 Similar to cog-chase-link, but invokes 'proc' on the wanted atom.
678 Starting at the atom 'anchor', chase its incoming links of
679 'link-type', and call procedure 'proc' on all of the atoms of
680 type 'endpoint-type' in those links. For example, if 'anchor' is the
681 node 'GivenNode \"a\"', and the atomspace contains
682
683 SomeLink
684 GivenNode \"a\"
685 WantedNode \"p\"
686
687 SomeLink
688 GivenNode \"a\"
689 WantedNode \"q\"
690
691 then 'proc' will be called twice, with each of the WantedNodes's
692 as the argument. These wanted nodes were found by following the
693 link type 'SomeLink, starting at the anchor GivenNode \"a\".
694
695 It is presumed that 'anchor' points to some atom (typically a node),
696 and that it has many links in its incoming set. So, loop over all of
697 the links of 'link-type' in this set. They presumably link to all
698 sorts of things. Find all of the things that are of 'endpoint-type'.
699 Apply proc to each of these.
700"
701 (define (get-endpoint w)
702 (map proc (cog-outgoing-by-type w endpoint-type))
703 )
704
705 ; We assume that anchor is a single atom, or empty list...
706 (if (null? anchor)
707 '()
708 (map get-endpoint (cog-incoming-by-type anchor link-type))
709 )
710)
711
712757(define-public (ure-weighted-rules rbs)
713758"
714759 List all weighted rules of rbs, as follow