Re: EvaluationException in Java
Thomas Russ <[email protected]> Fri, 11 Jun 2010 18:06:45 -0700
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
On Jun 11, 2010, at 5:19 PM, lee martie wrote:
> Hello.
>
> I am trying to execute:
>
> " PLI.sEvaluate("(defrelation mismatched-competitor ((?c1 company) (?
> c2
> company)) :<=> (and (competitor ?c1 c2) (> (absolute-value (-
> (number-of-employees ?c1) (number-of-employees ?c2))) 1000)))",
> "testModule", null); "
>
> in Java, where "testModule" is the name of the module I am working in.
>
> I get the following exception when I try to execute the above:
>
> "edu.isi.stella.EvaluationException: While evaluating '(defrelation
> mismatched-competitor ((?c1 company) (?c2 company)) :<=> (and
> (competitor ?c1 c2) (> (absolute-value (- (number-of-employees ?c1)
> (number-of-employees ?c2))) |L|1000)))':
> Undefined operator: `defrelation'
> at edu.isi.stella.Cons.evaluateConsTree(Cons.java:8180)
> at edu.isi.stella.Stella_Object.evaluate(Stella_Object.java:4341)
> at edu.isi.powerloom.PLI.evaluate(PLI.java:4373)
> at edu.isi.powerloom.PLI.sEvaluate(PLI.java:4416)".
>
> Any ideas on why this is happening?
This is most likely happening because the module definition for
"testModule" makes it case sensitive.
PowerLoom commands are all upper case, which doesn't matter in a non-
case-sensitive module because everything is converted to upper case.
But if the module is case sensitive, then you will get an error like
the one you see. The fact that the error message refers to
"defrelation" and not "DEFRELATION" is a clue that this is happening.
To test for this, try it with upper case DEFRELATION:
PLI.sEvaluate("(DEFRELATION mismatched-competitor ((?c1 company)
(?c2 company)) :<=> (and (competitor ?c1 c2) (> (absolute-value (-
(number-of-employees ?c1) (number-of-employees ?c2))) 1000)))",
"testModule", null);
This is not the case here, but if you get an error message that
DEFRELATION is undefined, then the likely problem is that the module
definition hasn't included a module (such as PL-KERNEL-KB) that
includes the logic operators. That requires the logic operators to be
qualified by their home module, so one would need to write /logic/
defrelation instead of just defrelation.
But from the case of "defrelation" in the error message, it is almost
certainly a case sensitivity issue.
Some other general comments.
It is often simpler to define your relations and concepts in a file
and then load them rather than using the PLI interface to send them
one-by-one. That puts all the definitions in one place and provides a
good location for finding and reading them. It also makes interactive
operation easier, because you can just load your definitions and then
use the interactive prompt to try things out.
As a debugging aid, it is also often useful to use the command line to
enter expressions, definitions, etc. to test them. So if you start
the powerloom you should get a prompt that allows you to type
information in and see the results. [Not that it would have helped
particularly in this case.]