AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Using facts for Object storage
 
 

Hello,
I want to store emotions in this fashion:

emotion (x y z)
joy (4 5 6

I have tried using fact sets to store and retrieve the emotion set like this:

uSET (set _*1 _*1 _*1 _*)
     
commandset emo_0 to _1 _2 _3 )
     
a:(~yes)
       $
$pad = ^createfact_1 _2 _3 )
 ^
createfactemo _0 $$pad )
 
donequerying...

 @
= ^query(direct_sv emo _0 )
 
result: @0verb == @0object 

The dialouge goes like this:

GRIFFIN:  Welcome to ChatScript.
e: > emosys
GRIFFIN
:  EMOSystem
e
: > set sad 4 5 6
GRIFFIN
:  Commandset emo sad to (456)
e: > yes
GRIFFIN
:  Donequerying... resultsad == 228,837
e
: > 

The problem is when I want the three values ( 4 5 6 ) it gives me 228,837 (the reference?)
Can someone help shed light on what im doing wrong ?

 

 
  [ # 1 ]

Well, you are correct. You create a fact and then use that fact as the object of another fact.  So when you do @0object, yes, you get the reference id of that fact. You’d have to dereference once MORE, to get something from that fact.  There currently is nothing in ChatScript that prints out a fact directly (chatscript being oriented to displaying human words), meaning if that’s what you want, you have to do so manually. e.g.,
@0 = ^query(direct_sv emo _0 )
$$tmp = @0object
result: @0verb == \(  ^field($$tmp subject) ^field($$tmp verb) ^field($$tmp object) \)
(code above untested)

 

 
  [ # 2 ]

HOWEVER, that being said, the original FACT creation of the fact reference was “incorrect”, because you didn’t tell CS that the object was a fact reference instead of a number. The correct way to create the second fact would be
^createfact( emo _0 $$pad FACTOBJECT )

 

 
  [ # 3 ]

Or you might have tried:
  ^createfact( emo _0 ( _1 _2 _3 ) )
Which I also haven’t tested but which would be convenient if it worked.

 

 
  [ # 4 ]

Thank you for your help it is working great now.

I may have missed this somewhere but how do I dereference the fact id? Do I simply run another query with the fact ID within it or is there a special method to it?

 

 
  [ # 5 ]

The example dereferenced the fact id.  It called ^field, passing the fact id, and asking for a piece of it.

 

 
  [ # 6 ]

Hello,
The example was indeed really helpful in order to make also a similar part of my code run.
I was curious though, what is the logical foundation of the whole fact mechanism.
It seems like Datalog ( http://en.wikipedia.org/wiki/Datalog ), which is a pretty nice solution for chatbots.

If this is indeed the logic behind this specific mechanism, it would be easier to migrate existing rules and facts into chatscript.
Thank you very much.

 

 
  [ # 7 ]

I believe that the logical foundation behind the fact system is a data storage systtm in the form of data log that stores triplets of data/information in triplets, in the language format of [Subject Verb Object].

 

 
  [ # 8 ]

Triple representation of data is common (eg the W2 RDF world).  My particular view of actions upon triples (the query language) is informed by CMU’s SCONE project: http://www.cs.cmu.edu/~sef/scone/

 

 
  [ # 9 ]

Thank you very much Bruce.
This is exactly what I was looking for!!

 

 
  login or register to react