You just have to think about it the right way:
1) Jess's working memory is something like a relational database in
"normal form." Each fact is like a single row in one table.
2) Think of an "object-relational mapping" in which objects correspond
to table rows.
3) Finally, note that Java objects don't have members with submembers
with subsubmembers... they have members. The members themselves have
members. Those members have members, etc.
OK, so...
(deftemplate pet (slot name) (slot type))
(deftemplate toy (slot color) (slot type))
(deftemplate person (slot name) (multislot toys) (multislot pets))
(bind ?r (assert (pet (name "rover") (type dog))))
(bind ?f (assert (pet (name "fluffy") (type cat))))
(bind ?g (assert (toy (color red) (type guitar))))
(assert (person (name "Fred") (toys ?g) (pets ?r ?f)))
(defrule people-with-dogs
?d <- (pet (type dog) (name ?dog-name))
(person (name ?person-name) (pets $? ?d $?))
=>
(printout t ?person-name " has a dog named " ?dog-name crlf))
You can carry this to an arbitrarily deep level.
I think Nik Joshi wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi all,
>
> I am new to the JESS world so please bear with me. Here is my problem: I
> need to be able to create facts (a knowledge base) that have attributes that
> have multiple values. This, of course, can be easily done using a
> multislot. However, I also need for each value within a multislot to have
> attributes associated with it. The number of attributes or sub-attributes
> is variable. The best thing would be a list of lists, but as far as I can
> tell, JESS doesn't do that. What I need to be able to do is to see if two
> facts have overlapping attributes, and then to see if the sub-attributes
> match for each of the attributes. The way I'm doing this right now is to
> have a multislot for the attributes, and then another multislot (of strings)
> for the sub-attributes so that sub-attributes for attributes[1] is a string
> at sub-attributes[1]. This is confusing and not very good coding. I seem
> to have to work around JESS rather than having JESS work for me. Is JESS
> just not made for this, or am I simply not familiar enough with it? If
> anybody has any ideas, I would highly appriciate some input. Thanks!
>
> - Nik.
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------