Skip to content

Commit

Permalink
Add exclamation mark to the end of cog-extract
Browse files Browse the repository at this point in the history
There's a backwards-compat function that should have made it work,
but according to bug opencog#3656 it appears to fail. So fix by brute force.
  • Loading branch information
linas committed Aug 22, 2020
1 parent df7dab0 commit 4b94bdc
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion opencog/eva/attic/chatbot-train/simple-training.scm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
(set! result #f)
)
; Remove the temp needed listified string
(cog-extract listified-string)
(cog-extract! listified-string)
result
)

Expand Down
2 changes: 1 addition & 1 deletion opencog/eva/behavior/movement-api.scm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(cog-get-link 'DefineLink 'DefinedPredicateNode
(DefinedPredicate STR)))

(if (not (null? dfn)) (cog-extract (car dfn)) #f))
(if (not (null? dfn)) (cog-extract! (car dfn)) #f))

; Printer stub -- Prints to the opencog log file.
(define-public (prt-pred-defn PRED . REST)
Expand Down
8 changes: 4 additions & 4 deletions opencog/eva/behavior/primitives.scm
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@
(define-public (run-behavior-tree-gc)
(define (free-stuff)
(sleep 1)
(cog-map-type (lambda (a) (cog-extract a) #f) 'SetLink)
(cog-map-type (lambda (a) (cog-extract a) #f) 'ListLink)
(cog-map-type (lambda (a) (cog-extract a) #f) 'NumberNode)
(cog-map-type (lambda (a) (cog-extract a) #f) 'ConceptNode)
(cog-map-type (lambda (a) (cog-extract! a) #f) 'SetLink)
(cog-map-type (lambda (a) (cog-extract! a) #f) 'ListLink)
(cog-map-type (lambda (a) (cog-extract! a) #f) 'NumberNode)
(cog-map-type (lambda (a) (cog-extract! a) #f) 'ConceptNode)
(free-stuff)
)
(call-with-new-thread free-stuff)
Expand Down
2 changes: 1 addition & 1 deletion opencog/eva/chatbot-eva/imperative.scm
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
; XXX FIXME we need a better way of marking actions as having
; been performed, already.
(for-each (lambda (x)
(cog-extract-recursive (ListLink current-action x)))
(cog-extract-recursive! (ListLink current-action x)))
action-list)

; XXX replace the dont-know reply by ChatScript or something.
Expand Down
2 changes: 1 addition & 1 deletion opencog/eva/chatbot-eva/model-query.scm
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
)

; Free up anything attached to the anchor.
(map cog-extract-recursive (get-grounded-replies))
(map cog-extract-recursive! (get-grounded-replies))

reply-words
)
Expand Down
4 changes: 2 additions & 2 deletions opencog/eva/model/faces.scm
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
Quick hack to remove face ID from the room
"
(cog-extract (EvaluationLink (PredicateNode "visible face")
(cog-extract! (EvaluationLink (PredicateNode "visible face")
(ListLink (ConceptNode id)))))

; -----------------------------------------------------------------
Expand Down Expand Up @@ -155,7 +155,7 @@

;; ----
(define (undefine def)
(cog-extract (car (cog-incoming-set def))))
(cog-extract! (car (cog-incoming-set def))))

#|
;; Example usage:
Expand Down
2 changes: 1 addition & 1 deletion opencog/ghost/test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
(define rtn (cog-outgoing-set rset))

; Remove the SetLink
(cog-extract rset)
(cog-extract! rset)

rtn
)
Expand Down
6 changes: 3 additions & 3 deletions opencog/nlp/chatbot-old/pln/symmetric-relation.scm
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@
cnt
)

(cog-map-type (lambda (x) (cog-extract-recursive x) #f) 'FWVariableNode)
(cog-map-type (lambda (x) (cog-extract-recursive x) #f) 'OrderedLink)
(cog-map-type (lambda (x) (cog-extract-recursive! x) #f) 'FWVariableNode)
(cog-map-type (lambda (x) (cog-extract-recursive! x) #f) 'OrderedLink)
(cog-map-type prt-atom 'FWVariableNode)

(cog-extract-recursive (ConceptNode "___PLN___"))
(cog-extract-recursive! (ConceptNode "___PLN___"))



Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/chatbot-old/seme/seme-process.scm
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@
; Delete upwards ... this deletes the link to the document,
; and also the link to the new-parsed-sentences anchor.
; XXX but it leaves a DocumentNode with nothing pointing to it.
(cog-extract-recursive sent)
(cog-extract-recursive! sent)
)

(for-each do-one-sentence (get-new-parsed-sentences))
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/chatbot-psi/actions.scm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
(if (equal? (cog-arity fuzzy-results) 0)
(State fuzzy-reply no-result)
(let ((rtn (pick-and-generate (cog-outgoing-set fuzzy-results))))
(cog-extract fuzzy-results)
(cog-extract! fuzzy-results)
(if (nil? rtn)
; Could happen if none of them can be used to generate
; an actual sentence
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/fuzzy/fuzzy.scm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
(set! max-score score))
#f)))
(cog-outgoing-set fset))
(cog-extract fset)
(cog-extract! fset)
results))

(let* ( ; List of setence types to not consider
Expand Down
4 changes: 2 additions & 2 deletions opencog/nlp/lg-dict/lg-dict.scm
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
(let ((dentry (LgDictEntry WORD (LgDictNode "en"))))
; XXX Argh. This function gets called in par-map in sureal,
; and because it races, the dentry could already be deleted
; by now, in another thread. If so, the the cog-extract throws.
; by now, in another thread. If so, the the cog-extract! throws.
; Yuck.
(catch 'wrong-type-arg
(lambda ()
(cog-execute! dentry)
(cog-extract dentry))
(cog-extract! dentry))
(lambda (key . args) #f))
(cog-incoming-by-type WORD 'LgDisjunct)
)
Expand Down
4 changes: 2 additions & 2 deletions opencog/nlp/microplanning/anaphora.scm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
)
; do not want a copy of the link for every changes to the node, just want one
(if (not (equal? (get-orig-link ni) old-link))
(cog-extract old-link)
(cog-extract! old-link)
)

(mod-link results-set (get-chunk-index ni) (get-link-index ni) new-link)
Expand All @@ -92,7 +92,7 @@
(mod-chunk results-set index (get-chunk inputs-set index))
)

(cog-extract temp-set-link)
(cog-extract! temp-set-link)
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/microplanning/main.scm
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
(define say-able (not (nil? (cached-sureal temp-set-link))))

; remove the temporary SetLink
(cog-extract temp-set-link)
(cog-extract! temp-set-link)

(cond
; not long/complex but sayable
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/relex2logic/post-processing.scm
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
(define results-list (append-map helper marker-list))
; delete the markers links and the marker itself
(for-each extract-hypergraph marker-list)
(cog-extract marker)
(cog-extract! marker)
; return the results
results-list
)
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/relex2logic/relex2logic.scm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
; XXX maybe this should be part of the ure module??
(if (or (equal? 'ListLink (cog-type A-LINK)) IS-FROM-FC)
(let ((returned-list (cog-outgoing-set A-LINK)))
(cog-extract A-LINK)
(cog-extract! A-LINK)
returned-list)
(list A-LINK))
)
Expand Down
24 changes: 12 additions & 12 deletions opencog/nlp/scm/nlp-utils.scm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
"
; Purge stuff associated with a single LgLinkInstanceNode
(define (extract-link-instance li)
(if (cog-atom? li) (cog-extract-recursive li))
(if (cog-atom? li) (cog-extract-recursive! li))
)

; Purge stuff associated with a single word-instance.
Expand Down Expand Up @@ -394,10 +394,10 @@
; Extract the NumberNode, but only if it's not used.
((eq? 'WordSequenceLink (cog-type x))
(let ((oset (cog-outgoing-set x)))
(cog-extract x)
(cog-extract (cadr oset))))))
(cog-extract! x)
(cog-extract! (cadr oset))))))
(cog-incoming-set wi))
(cog-extract-recursive wi)
(cog-extract-recursive! wi)
)

; Purge, recusively, all of the word-instances in the parse.
Expand All @@ -415,7 +415,7 @@
(extract-word-instance (car (cog-outgoing-set x)))))
(cog-incoming-set parse)
)
(cog-extract-recursive parse)
(cog-extract-recursive! parse)
)

; For each parse of the sentence, extract the parse
Expand All @@ -434,16 +434,16 @@
; Extract the NumberNode, but only if it's not used.
((eq? 'SentenceSequenceLink (cog-type x))
(let ((oset (cog-outgoing-set x)))
(cog-extract x)
(cog-extract (cadr oset))))
(cog-extract! x)
(cog-extract! (cadr oset))))
)
)
(cog-incoming-set sent)
)

; This delete will fail if there are still incoming links ...
; this is intentional. Its up to the caller to cleanup.
(cog-extract sent)
(cog-extract! sent)
)

; ---------------------------------------------------------------------
Expand All @@ -467,11 +467,11 @@
"
(let ((n 0))
; (define (delit atom) (set! n (+ n 1)) #f)
; (define (delit atom) (cog-extract-recursive atom) #f)
(define (delit atom) (cog-extract-recursive atom) (set! n (+ n 1)) #f)
; (define (delit atom) (cog-extract-recursive! atom) #f)
(define (delit atom) (cog-extract-recursive! atom) (set! n (+ n 1)) #f)

; (define (delone atom) (cog-extract atom) #f)
; (define (delone atom) (cog-extract atom) (set! n (+ n 1)) #f)
; (define (delone atom) (cog-extract! atom) #f)
; (define (delone atom) (cog-extract! atom) (set! n (+ n 1)) #f)
(define (delone atom) (extract-hypergraph atom) (set! n (+ n 1)) #f)

; Can't delete InheritanceLink, its used to mark wsd completed...
Expand Down
6 changes: 3 additions & 3 deletions opencog/nlp/scm/processing-utils.scm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(if (nil? iset) '()
(let* ((lnk (car iset))
(item (cog-get-partner lnk ANCHOR)))
(cog-extract-recursive lnk)
(cog-extract-recursive! lnk)
item))))))
)

Expand All @@ -50,11 +50,11 @@
Release all items attached to ANCHOR.
"

; Use cog-extract-recursive, not cog-extract, because some poorly
; Use cog-extract-recursive!, not cog-extract!, because some poorly
; written code somewhere is running a badly-scoped search pattern,
; which results in links getting wrapped in a SetLink. So the
; recursive-extract forcibly breaks such mal-formed usages.
(for-each (lambda (x) (cog-extract-recursive x))
(for-each (lambda (x) (cog-extract-recursive! x))
(cog-incoming-set anchor)
)
)
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/sureal/surface-realization.scm
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@

; Delete the filter-from SetLink and its encompasing MapLink.
; FIXME: This results in 'result' being 'Invalid handle' sometimes.
;(cog-extract-recursive filter-from)
;(cog-extract-recursive! filter-from)

result
)

0 comments on commit 4b94bdc

Please sign in to comment.