Re: Beginner - Help Needed!

"Rangarajan Krishnamoorthy" <[email protected]> Tue, 1 Jul 2008 14:30:01 +0530
Newsgroups gmane.comp.ai.powerloom
Message-ID <000a01c8db58$de37e830$0201a8c0@COM>
Russ,
Thanks a lot for the quick reply. I noticed Chapter 6 lists the PLI. Did you 
mean Chapter 6 or 7 in your reply (1)?

Consider the following scenario. I have loaded PowerLoom into my Lisp. 
Instead of saying (in-package "STELLA"), I do the following:

CL-USER 1 > (STELLA::defconcept person)

|c|PERSON



CL-USER 2 > (STELLA::assert (person john))

|P|(PERSON JOHN)



CL-USER 3 > (STELLA::ask (person john))

TRUE



CL-USER 4 > (STELLA::ask (person peter))

UNKNOWN



CL-USER 5 > (STELLA::retrieve all (person ?x))

There is 1 solution:

  #1: ?X=JOHN



CL-USER 6 > (setf matches (STELLA::retrieve all (person ?x)))

There is 1 solution:

  #1: ?X=JOHN



CL-USER 7 > matches

There is 1 solution:

  #1: ?X=JOHN


Notice that when I retrieve the matches (as in CL-USER 6 prompt), I expect 
to get a "Lisp" form. That would allow me to use the matches in my Lisp 
code. But that is not what I get (see CL-USER 7).

So, to restate my original question, how do I programmatically interact with 
PowerLoom so that I get the results of queries/computations into my Lisp 
environment? I will most probably define the domain knowledge (concepts, 
relations, functions, rules, etc.) in a Powerloom file, load it into my Lisp 
environment (using the "in-package" format you indicated), but issue queries 
from Lisp code. Hope I have conveyed my usage scenario.

Regards,
Rangarajan

----- Original Message ----- 
From: "Thomas Russ" <[email protected]>
To: "Rangarajan Krishnamoorthy" <[email protected]>
Cc: <[email protected]>
Sent: Tuesday, July 01, 2008 9:46 AM
Subject: Re: [PowerLoom Forum] Beginner - Help Needed!



On Jun 30, 2008, at 7:42 PM, Rangarajan Krishnamoorthy wrote:

> Hi,
> I have just downloaded PowerLoom on Windows. I am using LispWorks 5.1. 
> Although the documentation of PowerLoom talks about the language and API, 
> I do not find examples of how to call the API from Lisp. I could not even 
> get started with simple examples using the API from Lisp.

First off, I apologize because we have not yet had the opportunity to
finish the lisp-specific section of the manual.

Fortunately, the Lisp interface is straight-forward, since the
documentation of the functions are all in the Lisp syntax.  The key
items that are missing from the documentation are:

1.  The PowerLoom Interface functions from section 7 are all in the PLI
package.  Those API functions are exported and are intended for use
from your own Lisp program.

2.  All other PowerLoom functions are in the STELLA package, but are
not exported.  This includes all of the normal PowerLoom functions.  So
it is often convenient to just operate in the STELLA package.  This
works well for interactive development using the Lisp environment.

So, to use PowerLoom in Lisp one would need to do the following:

(load "load-powerloom.lisp")
(in-package "STELLA")
;; At this point you can just type PowerLoom commands,
;; or you could go through the annotated example in the manual.

(defconcept Person)
(deffunction age ((?p person) (?age integer)))
(defrelation friend ((?p1 person) (?p2 person)))

(assert (person fred))
(assert (person rajiv))
(assert (and (age fred 20) (age rajiv 19) (friend fred rajiv)))

(ask (age fred 20))
(ask (age fred 30))
(retrieve all (friend ?x rajiv))

(defconcept teenager ((?p person))
    :<=> (and (person ?p)
              (< (age ?p) 20)
              (> (age ?p) 12)))

(retrieve all (teenager ?p))
(retrieve all (and (teenager ?p) (age ?p ?age)))




>
> There is some mention of "translation" to C++, etc. Does it mean that 
> PowerLoom code can be translated to Lisp (or C++) and then used in that 
> mode? How do I invoke the translator?

PowerLoom itself has already been translated to Lisp, Java and C++.
This is done by using our underlying Stella language, which has such a
translator.  More information and an incomplete manual can be found at
http://www.isi.edu/isd/LOOM/Stella/index.html

When using Stella to write programs, one would normally build a
"system" which has a description of the files and Stella modules
(namespaces) involved.  Then the translator is invoked with

   (make-system "system-name" :target-language)

where the :target-language is one of :common-lisp :java or :cpp
and "system-name" is the name of your system.

>
> Thanks for your help.

I hope this helps to get you started.  If this isn't quite enough,
please ask further questions and we'll help you get started.



>
> Regards,
> Rangarajan_______________________________________________
> powerloom-forum mailing list
> [email protected]
> http://mailman.isi.edu/mailman/listinfo/powerloom-forum