Notes on using PowerLoom with SBCL Common Lisp
A while ago, I wrote Java wrappers for easily using PowerLoom from Java (see my Java AI book (free PDF download)).
I am evaluating the use of PowerLoom on a customer project and spent a while this morning experimenting with PowerLoom (version powerloom-3.2.50) using SBCL Common Lisp. Since it took me a while to find how to do the things in Lisp that I am used to doing in Java, I thought that I would make some notes on what I did:
Download and unpack the PowerLoom distribution. We will be using the example knowledge base file kbs/business.plm so you might want that open in a text editor to read through it. Start by running SBCL (lots of output removed for brevity):
$ cd powerloom-3.2.50 $ sbcl This is SBCL 1.0.29, an implementation of ANSI Common Lisp. * (load "load-powerloom.lisp") * (STELLA::LOAD "kbs/business.plm") NIL * (PLI:S-ASSERT-PROPOSITION "(and (company c1) (company-name c1 \"Moms Grocery\"))" "BUSINESS" nil) |i|/PLI/@PL-ITERATOR * (PLI:S-ASSERT-PROPOSITION "(and (company c2) (company-name c1 \"Dads Grocery\"))" "BUSINESS" nil) |i|/PLI/@PL-ITERATOR * (let ((iter (pli:s-retrieve "all (company-name ?x ?y)" "BUSINESS" nil))) (loop while (stella::next? iter) do (print (pli::%pl-iterator.value iter)))) (|i|/PL-KERNEL-KB/PL-USER/BUSINESS/C1 |L|"Dads Grocery") (|i|/PL-KERNEL-KB/PL-USER/BUSINESS/C1 |L|"Moms Grocery") (|i|/PL-KERNEL-KB/PL-USER/BUSINESS/MEGASOFT |L|"MegaSoft, Inc.") (|i|/PL-KERNEL-KB/PL-USER/BUSINESS/ACME-CLEANERS |L|"ACME Cleaners, LTD") (|i|/PL-KERNEL-KB/PL-USER/BUSINESS/MEGASOFT |L|"MegaSoft") NIL *
The argument "BUSINESS" is the knowledge base module name defined in kbs/business.plm. The last nil argument specifies a PowerLoom environment.
The example file kbs/business.plm defined the concept company and defined instances. I asserted two additional companies and listed them.
It is easy enough to use PowerLoom using the interactive shell but it is more difficult embedding PowerLoom in Java and Common Lisp applications. The above example will at least get you started interfacing between your Lisp runtime environment and the embedded PowerLoom environment. API functions that start with "s-" are the most convenient because they take string input arguments.