← Back to team overview

opencog-dev team mailing list archive

Re: OpenCog Shell

 

2008/5/26 Linas Vepstas <linasvepstas@xxxxxxxxx>:
> 2008/5/26 Ben Goertzel <ben@xxxxxxxxxxxx>:
>>
>> How much effort do you reckon it would be to extend this into a Scheme
>> front end for the Combo language that currently exists in the Novamente
>> core (which Moshe wrote a while back)?

and perhaps I'm looking at the wrong document.
In "NovamenteComboDescription, I see the
example of novamente combo in action:

create_link (atom_type "EvaluationLink")
       (cons (pred "eats")
             (cons (list
                   (cons (concept "cat")
                         (cons (concept "fish") nil))) nil))

This differs slightly from what I have; with my
current syntax, the equivalent of this would be:
(if I understand it correctly):

(cog-new-link 'EvaluationLink
      (list (cog-new-node 'PredicateNode "eats")
            (cog-new-link 'ListLink
                (list (cog-new-node 'ConceptNode "cat")
                      (cog-new-node 'ConceptNode "fish")))))

(The reason for all of the "list"  is cause I got lazy about
implementing cog-new-link as a variable-arity function.
MaybeI should fix that)

Now, synactic sugar is almost trivially easy: all I have to say is

(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 (evelyn x)  (cog-new-link 'EvaluationLink x))  ;eval is a
reserved word in scheme

Then, with this trite sugar, I can write:

(evelyn (list (pred "eats") (listyl (list (concept "cat") (concept "fish")))))

And I get:

#<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]>]>]>

Looking up types_codes.h I see:

#define PREDICATE_NODE 47
#define CONCEPT_NODE 3
#define EVALUATION_LINK 53

so that is indeed what  was wanted ...
The above is working code, you can cut-in-paste it into
the scheme shell now.

You can write different syntactic suger that will, I think
bring it exactly into line with the original combo example.

The only thing I can't easily do is to get rid of parens.
Also,  making := be an infix operator, as opposed to
the prefix "define" would be ... tricky and weird.

--linas



References