> Example:
>
> (deftemplate Person
> (slot name (type STRING)))
>
> (deftemplate Organization
> (slot name (type STRING))
> (slot location(type STRING))
> (slot employs --->Person )
>
> I want the slot "employs" being of type "Person",and so when setting
> a fact for Organization I want to set the slot "employs" to a Person's
> "name".
>
> Does anybody knows if it's possible to make such structures in Jess?
> Thank you very much in advance for your help.
The usual approach is to think of deftemplates as defining a relational
schema, as in a relational database. I'm not a JESS user (yet) primarily
because I dislike Java as a programming language. I use an ObjectiveC
bridge to CLIPS that works a lot like JESS does wrt introspecting
objects and asserting them as facts. (If/When we ever move to Java -
we'd switch our rule logic to Jess).
Anyhow, it helps to think like a relational database designer.
Using objects, your template might look something like:
(deftemplate Person
(field self)
(field name)
(field organization)) ; relates to an Organization
(deftemplate Organization
(field self)
(field name)
(field location))
For instance, to get a Person's Organization you might do something like....
(defrule person-organization
(Person (organization ?org) ....)
(Organization (self ?org) .....)
=>
...)
It sounds like JESS has a way to store a Java object reference in a field,
which does roughly the same thing as the self field I put into every object.
Hope this helps.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
eTranslate, Inc. The Power of Language
Todd Blanchard main +1.415.970.7119
Chief Technology Architect fax +1.415.371.0008
http://www.etranslate.com/
500 Treat Street, Suite 100, San Francisco, California 94110, U.S.A.
