Re: JESS: [EXTERNAL] Matching facts based on a slot, but not the fact's type
"Aurelien Mazurie" <[email protected]> Tue, 30 Jul 2013 10:22:54 -0600
| Newsgroups | gmane.comp.java.jess |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_98B98E17-C3D4-4800-949B-70B7E4F43FF1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Thank you; the template inheritance mechanism was the answer. Aur=E9lien On Jul 30, 2013, at 8:11 AM, "Friedman-Hill, Ernest" = <[email protected]> wrote: > The short answer is =93no=94. Templates are like Java classes, and so = this is akin to asking if you can write Java code that reads the value = of a =93score=94 member variable in any class. > =20 > But you can use template inheritance to achieve your goal. Templates = can extend other templates; just put your =93score=94 slot in a base = template, and extend everything else that needs a =93score=94 slot from = that common base, and write your patterns to match the base template. = Read about the use of =93extends=94 in templates here: > =20 > http://www.jessrules.com/jess/docs/71/memory.html > =20 > =20 > From: [email protected] [mailto:[email protected]] = On Behalf Of Aurelien Mazurie > Sent: Friday, July 26, 2013 4:43 PM > To: jess-users > Subject: JESS: [EXTERNAL] Matching facts based on a slot, but not the = fact's type > =20 > Dear Jess users,=20 > I am still learning the ropes, and cannot find an answer to the = following question either online or in the 'Jess in action' book. Is = there a way to match facts in a LHS based on the presence of a slot?=20 >=20 > For example, I have two templates:=20 >=20 > (deftemplate A (slot score))=20 > (deftemplate B (slot score))=20 >=20 > I would like my rule to be triggered if any fact (either from template = A, B, or others) have a 'score' slot with a specific value. For now I = can do it by manually adding references to A and B in the LHS, but this = will not scale well. I'm looking for a solution that can just work on = any fact, regardless of the template they are defined from.=20 >=20 > Best,=20 > Aurelien=20 --Apple-Mail=_98B98E17-C3D4-4800-949B-70B7E4F43FF1 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html = charset=3Dwindows-1252"><base href=3D"x-msg://1/"></head><body = style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; = -webkit-line-break: after-white-space; "><div>Thank you; the template = inheritance mechanism was the = answer.</div><div>Aur=E9lien</div><br><div><div>On Jul 30, 2013, at 8:11 = AM, "Friedman-Hill, Ernest" <<a = href=3D"mailto:[email protected]">[email protected]</a>> = wrote:</div><br class=3D"Apple-interchange-newline"><blockquote = type=3D"cite"><div lang=3D"EN-US" link=3D"blue" vlink=3D"purple" = style=3D"font-family: Helvetica; font-size: medium; font-style: normal; = font-variant: normal; font-weight: normal; letter-spacing: normal; = line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: = 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: = 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; = "><div class=3D"WordSection1" style=3D"page: WordSection1; "><div = style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times = New Roman', serif; "><span style=3D"font-size: 11pt; font-family: = Calibri, sans-serif; color: rgb(31, 73, 125); ">The short answer is = =93no=94. Templates are like Java classes, and so this is akin to asking = if you can write Java code that reads the value of a =93score=94 member = variable in any class.<o:p></o:p></span></div><div style=3D"margin: 0in = 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; = "><span style=3D"font-size: 11pt; font-family: Calibri, sans-serif; = color: rgb(31, 73, 125); "> </span></div><div style=3D"margin: 0in = 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; = "><span style=3D"font-size: 11pt; font-family: Calibri, sans-serif; = color: rgb(31, 73, 125); ">But you can use template inheritance to = achieve your goal. Templates can extend other templates; just put your = =93score=94 slot in a base template, and extend everything else that = needs a =93score=94 slot from that common base, and write your patterns = to match the base template. Read about the use of =93extends=94 in = templates here:<o:p></o:p></span></div><div style=3D"margin: 0in 0in = 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; = "><span style=3D"font-size: 11pt; font-family: Calibri, sans-serif; = color: rgb(31, 73, 125); "> </span></div><div style=3D"margin: 0in = 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; = "><a href=3D"http://www.jessrules.com/jess/docs/71/memory.html" = style=3D"color: purple; text-decoration: underline; = ">http://www.jessrules.com/jess/docs/71/memory.html</a><o:p></o:p></div><d= iv style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: = 'Times New Roman', serif; "><span style=3D"font-size: 11pt; font-family: = Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div = style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times = New Roman', serif; "><span style=3D"font-size: 11pt; font-family: = Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div = style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times = New Roman', serif; "><b><span style=3D"font-size: 10pt; font-family: = Tahoma, sans-serif; ">From:</span></b><span style=3D"font-size: 10pt; = font-family: Tahoma, sans-serif; "><span = class=3D"Apple-converted-space"> </span><a = href=3D"mailto:[email protected]" style=3D"color: purple; = text-decoration: underline; ">[email protected]</a><span = class=3D"Apple-converted-space"> </span>[mailto:owner-<a = href=3D"mailto:[email protected]" style=3D"color: purple; = text-decoration: underline; ">[email protected]</a>]<span = class=3D"Apple-converted-space"> </span><b>On Behalf Of<span = class=3D"Apple-converted-space"> </span></b>Aurelien = Mazurie<br><b>Sent:</b><span = class=3D"Apple-converted-space"> </span>Friday, July 26, 2013 4:43 = PM<br><b>To:</b><span = class=3D"Apple-converted-space"> </span>jess-users<br><b>Subject:</b>= <span class=3D"Apple-converted-space"> </span>JESS: [EXTERNAL] = Matching facts based on a slot, but not the fact's = type<o:p></o:p></span></div><div style=3D"margin: 0in 0in 0.0001pt; = font-size: 12pt; font-family: 'Times New Roman', serif; = "><o:p> </o:p></div><div><div style=3D"margin: 0in 0in 0.0001pt; = font-size: 12pt; font-family: 'Times New Roman', serif; "><span = style=3D"font-size: 10pt; font-family: Verdana, sans-serif; ">Dear Jess = users, <br>I am still learning the ropes, and cannot find an answer = to the following question either online or in the 'Jess in action' book. = Is there a way to match facts in a LHS based on the presence of a = slot? <br><br>For example, I have two = templates: <br><br>(deftemplate A (slot = score)) <br>(deftemplate B (slot score)) <br><br>I would like = my rule to be triggered if any fact (either from template A, B, or = others) have a 'score' slot with a specific value. For now I can do it = by manually adding references to A and B in the LHS, but this will not = scale well. I'm looking for a solution that can just work on any fact, = regardless of the template they are defined = from. <br><br>Best, <br>Aurelien </span><o:p></o:p></div></= div></div></div></blockquote></div><br></body></html>= --Apple-Mail=_98B98E17-C3D4-4800-949B-70B7E4F43FF1--