OpenCog Brainwave

scheme shell

Posted by: linasv on: 2008-05-27

I needed the ability to hand-edit opencog data while other processes were running. And so I hacked with guile for a while, and now there’s a scheme shell for opencog.
So far it’s very simple: just say ’scm’ at the opencog prompt; this puts you into the shell. Then you can scheme away.

So, fore example:

  (cog-new-node 'ConceptNode "some node name")

creates a new node:

  #<node[3:some node name] sti:(0,0) tv:(0.000000,0.000000)>

Well… I suppose the above looks like goobldy-gook. But it just says that its a new node with zero “short-term importance” (sti) and zero “truth value” (tv). It would be slicker if all this could be viewed visually, as a graph… the above would be just a single point, with a label.

Creating links is easy:

  (define x (cog-new-node 'ConceptNode "abc"))
(define y (cog-new-node 'ConceptNode "def"))
(cog-new-link 'Link x y)

which creates two new nodes (called ‘x’ and ‘y’) and a link connecting the two. Here’s the result:

  #<link[2 sti:(0,0) tv:(0.000000,0.000000) <[3 abc],[3 def]>]>

What’s slick about scheme is that it’s easy to add a bit of syntactic sugar to make link and node creation even easier. So, for example, we can define some new functions:

  (define (concept x) (cog-new-node 'ConceptNode x))
(define (pred x) (cog-new-node 'PredicateNode x))
(define (listyl x) (cog-new-link 'ListLink x)) ; list is a reserved word in scheme
(define (evely x) (cog-new-link 'EvaluationLink x)) ; eval is a reserved word in scheme

and with this syntactic sugar:

  (evely (pred "eats") (listyl (concept "cat") (concept "fish")))

which creates the opencog graph:

  #<link[53 sti:(0,0) tv:(0.000000,0.000000) <[47 eats],link[13 sti:(0,0) tv:(0.000000,0.000000) <[3 cat],[3 fish]>]>]>

So I’m thrilled. I can finally create, edit and delete nodes on the fly, without having to write C++ code, compile it, etc. etc. Woo hoo!

Leave a Reply

You must be logged in to post a comment.

About

OpenCog is software for the collaborative development of safe and beneficial Artificial General Intelligence.

The Brainwave blog tracks OpenCog development.

  • jasonforceau: Hi, i am looking for tools for syntactic analysis for the system of my Final Year Project and found your post so interesting. But I don't know Link-Gr
  • linasv: These graphs were discussed on the corpora mailing list in March 2009. See http://mailman.uib.no/public/corpora/2009-March/008193.html and followups i
  • linasv: Martin Reynaert wrote to say: ''From what I have learned from the work of mainly Ramon Ferrer i Cancho ( http://www.lsi.upc.edu/~rferrericancho/p

RSS OpenCog on del.icio.us

  • An error has occurred; the feed is probably down. Try again later.