opencog / atomspace

The OpenCog (hyper-)graph database and graph rewriting system
https://wiki.opencog.org/w/AtomSpace
Other
818 stars 232 forks source link

GetLink usage #57

Closed amebel closed 9 years ago

amebel commented 9 years ago

Scenario 1

Defined

(define (counter)
    (define (increment-number str)  (+ (string->number str) 1))
    (let ((nn (cog-chase-link 'ReferenceLink 'NumberNode (AnchorNode "count"))) )

        (if (null? nn)
            (ReferenceLink
                (AnchorNode "count")
                (NumberNode 1)
                )
            (cog-execute! (cog-execute!
                (AssignLink
                    (TypeNode "AssignLink")
                    (TypeNode "ReferenceLink")
                    (AnchorNode "count")
                    (NumberNode (increment-number (cog-name (car nn))))
                )
            ))

        )
    )
)

(define get
    (GetLink
        (AssignLink
            (TypeNode "AssignLink")
            (TypeNode "ReferenceLink")
            (AnchorNode "count")
            (VariableNode "x")
        )
    )
)

Run on the cogserver

guile> (counter) (counter)(counter)(counter) ; run as many time as you like
guile> (cog-satisfying-set get)
(SetLink
)

Senario 2:

load AssignLinks from https://github.com/opencog/atomspace/blob/master/examples/guile/assign.scm#L61

Defined

(define get2
    (GetLink 
        (AssignLink
        (TypeNode "EvaluationLink")
        (PredicateNode "some property")
        (ListLink
            (ConceptNode "thing A")
            (VariableNode "x")))))

Run on the cogserver

guile> (cog-satisfying-set get2)
(SetLink
   (ConceptNode "alternative B")
   (ConceptNode "The V alternative")
)

@linas why doesn't Scenario 1 work? Is it a feature or a bug?

amebel commented 9 years ago
(cog-execute! (RemoveLink
   (TypeNode "AssignLink" (av 0 0 0))
   (TypeNode "ReferenceLink" (av 0 0 0))
   (AnchorNode "count")
   (NumberNode "2.000000" (av 0 0 0))
)
)

has no effect

linas commented 9 years ago

Bugs I guess.

I have a huge number of changes to push, here: https://github.com/linas/atomspace/tree/put but its a nightmare, because I can't get the python unit tests to pass, due to library load symbol resolution failures. Python seems to struggle because it seems to try to load the libraries itself, and it is doing it wrong, and/or using eager instead of lazy binding. When I try to fix these, I get CMake complaining about circular shared library dependencies, which is utterly stupid and idiotic, because the glibc ld.so loader can resolve the symbols just fine; its a stupid CMake error message having nothing to do with reality. Its a CMake bug.

To fix python to work correctly would require a vast re-organization of the cython bindings; they were designed incorrectly, and with Curtis gone, this task is too large for me. The only remaining alternative I have is to cripple GetLinkPutLink to not quite work right. I'm tearing my hair out and am very frustrated about how an easy 2 hour task has turned into a eight-day ordeal with no end in sight.

linas commented 9 years ago

I think I pushed a bunch of commits that perhaps fix all of this maybe a week ago. Can you retest?

amebel commented 9 years ago

Thanks @linas it is resolved.