PyCLIPS provides the API-like methods to retrieve Fact
slots, either declared or implied: however there is no
way to quickly access a Fact relation (the first field in a
CLIPS fact), the only way to do it is to apply a formula
f = <somefact>
rel = f.CleanPPForm()[1:-1].split()
which always succeeds for correctly defined facts but
makes code much less readable. Probably this formula
should be implemented at the higher level in order to
improve readability in an operation that is likely to be
performed several times.
The proposal is to implement a read-only property
called 'Relation' for Fact objects, which actually returns
the string defined above as a Symbol (which is the type
of the "relation" as in BPG, page 11). The property
should be read-only because this symbol either depends
on a specific Template or it occurs in an already
asserted Fact: in both cases it would be not modifiable.
Log in to post a comment.