Re: JESS: assertFact() and java.lang.String

"Ernest Friedman-Hill" <[email protected]>
Newsgroups gmane.comp.java.jess
Message-ID <[email protected]>
STRING and SYMBOL are two different data types; here's one of the many  
forum threads where this has been discussed:

http://www.mail-archive.com/[email protected]/msg07900.html

Calling 'new Value("a")' creates a value of type STRING, while the  
values in your retract-string call are SYMBOLs. Check out the other  
constructors of jess.Value; they are documented extensively.



On Nov 9, 2010, at 12:23 PM, kartik tadanki wrote:

> Hi,
>
> Question How can I use Value object to put in simple strings instead  
> of java.lang.String instances.?
>
> -I wish to be able to assert facts from Java such that the rules in  
> the knowledge base can apply to them.
> -Currently, I use assertString().
> -When I use assertFact() the rules do not apply to the fact as with  
> assertString()
> This is because the slot values are now java.lang.String instances.
>
> How can I avoid building the string for assertString() and use  
> assertFact() such that the rules
> process facts thus asserted?
>
>
> My code:
> =============================================
> // (deftemplate Authorization (slot subject ) (slot predicate) (slot  
> object))
>
> //create fact
> Fact fact = new Fact("Authorization", r);
>
> set values
> Value va = new Value("a");
> fact.setSlotValue("subject", va);
> Value vb = new Value("b");
> fact.setSlotValue("predicate", vb);
> Value vc = new Value("c");
> fact.setSlotValue("object", vc);
>
> //assert the fact
> rete.assertFact(fact);
>
> // this retractString has no effect.
> rete.retractString("(Authorization (subject a) (object c) (predicate  
> b))");
> =============================================
>
>
> Thank you,
> -Kartik Tadanki
>
>

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012                            [email protected]
Livermore, CA 94550                             http://www.jessrules.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].
--------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.