Hi all,

I'm having trouble with my work email account, so I'm sending from this one.....

Okay, so I was able to rewrite my code so as to use the functionality from
the example below.  However, I've come across another problem which I can't
seem to find a decent solution to.  Without going into too much detail, my
basic program is a Java program that is getting fact attributes over a
socket and asserts facts into a Rete object that is continually resident.
I'll illustrate my problem by extending the code below.  Now suppose over
the socket I get the fact attributes for Fred whose pets are fluffy the cat,
rover the dog, and his toy is the red guitar.  Now suppose some time later,
I get fact attributes for John who has no toys, but has one pet, who just
happens to be a dog and who just happens to be called rover.  Basically what
I am saying is that some of the facts are going to be the same.  Since I am
getting the attributes over a socket, I am simply asserting them into the
Rete object as soon as I get them.  Thus, when I try to assert  the fact:

(person (name "John") (pets (assert (pet (name "rover") (type dog)))))

JESS will return FALSE for the pets multifield, because (pet (name "rover")
(type dog)) has already been asserted.  The only way I can see to get out of
this bind is to pre-process the facts inside of Java and compare them to
facts already asserted in JESS.  This seems pretty messy, so there has got
to be a better way.  As always, any help is highly appreciated.  Thanks!

- Nik.


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 04, 2003 6:44 PM
Subject: Re: JESS: creating fact attributes with mulitple sub-attributes


> 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]
> --------------------------------------------------------------------
>
>

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to