using PowerLoom to find things for an external program
"Robert P. Goldman" <[email protected]>
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
I apologize for bombing the list for questions, but I'm trying to come
up to speed, and I seem to have hit *precisely* the least-documented
parts of PowerLoom!
I'll try to step back and ask the most general possible questions, in
the hopes that this will avoid having my questions be aimed wrong.
I am trying to use PowerLoom for an exercise that's loosely related to
semantic web-style semantic addressing.
So, for example, I would like to be able to look up individuals in a
PowerLoom database, according to how well they match given query.
Then I would like my Common Lisp program to process the responses.
I think that the best way to do this might be something like:
1. Generate the query as a string. This will generally be something
of the following form:
(retrieve-partial best <var> <formula>)
So I think I want to generate something like:
"best <var> <formula>"
2. Ask the request of PowerLoom. This is the first point where I run
into trouble. There is an S-RETRIEVE-PARTIAL *command*, but no
corresponding *function* in the API, and I'm afraid I am not
sufficiently STELLA-aware to fill this hole.
Has such an API function crept into later versions of PowerLoom?
Would it be possible to post code for it into this list?
3. Catch an iterator back from this query.
I am not sure at this point whether I should be working in Common
Lisp or in Stella. At any rate, I would like to be able to walk
the iterator, pulling out some of the best responses, and possibly
dropping some of them as their scores go down, if there are too
many responses.
[For the record, while I sympathize with previous responders'
advice that working wholly in Stella is preferable, this advice is
difficult to take given the fragmentary state of the Stella manual
that ships with 3.0.2.beta.]
4. Project the PowerLoom instances I get back from the query into
something that the surrounding CL code can understand.
Perhaps I should just have something like
(deffunction public-name (?x) :-> (?s string))
and retrieve the public-name...
5. In general, previous list responses have helped me understand how
to turn the lisp data items I know and love into Stella objects.
(I think the basic approach is to work with strings at all
possible.)
But the inverse translation still seems mysterious to me.
My attempts to extract the items from a PL-ITERATOR (except by
just turning them into lists) have mostly failed. There are
functions that are intended to pull stuff out of columns, but then
there's the special case of queries like mine that don't have
columns. In that case, using and where recovering the zeroth
item fails.
The following snippet might serve to illustrate my confusion:
STELLA(147): (setf foo (pli:s-retrieve "all ?x (studied-by ?x tribe-b)" "EXPERTS" "NULL"))
|i|/PLI/@PL-ITERATOR
STELLA(148): (length foo)
2
STELLA(151): (pli:get-column-count foo)
0
STELLA(152): (pli:get-nth-logic-object foo 0)
Error: Column index `0' is out of range for `|i|/PLI/@PL-ITERATOR'
[condition type: LOGIC-EXCEPTION]
Restart actions (select using :continue):
0: Return to Top Level (an "abort" restart).
1: Abort entirely from this (lisp) process.
[1] STELLA(153):
STELLA(154): (pli:get-nth-value foo 0)
Error: Column index `0' is out of range for `|i|/PLI/@PL-ITERATOR'
[condition type: LOGIC-EXCEPTION]
Restart actions (select using :continue):
0: Return to Top Level (an "abort" restart).
1: Abort entirely from this (lisp) process.
[1] STELLA(155):
I'm afraid that I don't even understand how to turn the wrapped
STELLA objects into native CL objects. If I have a literal that
is a stella string, for example, how can I "crack it open" and get
at the string that is presumably squirreled away in it? The best
I have figured out for now is to use
(slot-value <powerloom-obj> 'wrapper-value)
is this the proper way to proceed?