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

Selecting Random Facts
 
 
u: ("tell me" _*) ^keep() ^query(direct_sv _0 isa_0 is ^pick(@0object). 
s: (_*1 is "_*") ^keep() ^repeat() right. ^createfact(_0 isa _1

I am using the above code to create and reference a factlist. I can use it to create facts about the same subject with different object values but when trying to reference the object values using ^pick sometimes the same value get selected and won’t be repeated unless I have ^repeat specified too or I reset the user. But resetting wipes out the facts! If I just repeat, it keeps on repeating infinitely but how do I randomly go through the list in the factset until all options are exhausted and then repeated no more?

 

 
  [ # 1 ]

^query acquires a fact set. Pick removes one randomly. But if you call query again, it’s a new set, that hasn’t been picked yet. You’d need to detect that the user was referencing the same word and preserve the factset across volleys, so it would steadily diminish.  (which means telling the system to save a particular @n set across volleys in part).

 

 
  [ # 2 ]

I’ll have to delve deeper into that but thanks. What about losing facts when resetting? I assume newly created facts are stored in the topic_user_bot.txt file always and deleted when the user is reset? Is there any way to store facts specific to a user that won’t be deleted with reset or quit? The Facts manual refers to a save function but that seems to only work on a factset.

I note there is a system command called allfacts that saves to a temp file. Is this the solution?

 

 
  [ # 3 ]

resetting a user is supposed to completely reset the bot. The only way to save across a reset would be to write the facts to a file ^export   and ^import them back again when the bot starts up.

 

 
  [ # 4 ]

I looked up export and import in the docs but info is confusing. It says the from for export should be a factset but doesn’t query reset this each time? I tried adding ^export(data.txt @0) to the s: rule in my above code but while the file is created it stays at 3 bytes no matter how many facts i add. Is it in a binary format cos I cant see anything in Notepad++? I also tried running ^query(? ? ?) before exporting but no change.

Also I am not sure how to specify the import function. What do I use for the set parameter that can be accessed by ^query?

 

 
  [ # 5 ]

to use export, you would generally need a query first, to fill the factset.  But ^query has a 1st argument that says what kind of query to do, so ^query(? ? ?) has no meaning and that rule failed (and a message would have been put in LOGS/bug.txt) .  So your query would be ^query(direct_v ? isa ?) which would find all isa facts (presuming none come from the system facts space). Then you could ^export(myfacts.txt @0) . When you 1st start the bot (eg initially or after a :reset), then the code would do ^import(myfacts.txt @0) to load all the facts. This will create the facts and you don’t care that they are now listed in @0.

 

 
  [ # 6 ]

Thanks Bruce. Still learning about Chatscript so facts may be wading in waters too deep for me right now. Just want a few clarifications.

—Is there any way for query to fill factsets other than @0? Otherwise if we want to save any info before we make a querycall we’ll have to assign that to @1 for example and export that right? Probably have to create a macro to export data each time createfact is used…..

—Here is the scenario I’m trying to acheive. Lets say we have input “Banana is a yellow fruit”. That is saved as “banana yellow fruit”. Then input “Lemon is a yellow fruit”. Saved as “lemon yellow fruit”. Then maybe using intersection and looping, input “What is a yellow fruit?” can respond with banana. lemon. if the query for yellow fruit fails maybe the script can ask “What is a yellow fruit” and based on the response learn a new fact. Since the svo triples are defined by user input and not words i pick I will probably have to save them as soon as the fact is created by using _0 _1 to define them, right? Just let me know if this scenario is possible. I will try to work out the scripting as hard as possible before bugging you about this.

—I thought ^reuse(label) could work on rules that had been used up but when I try to use it to go to middle of a gambit unless ^repeat is enabled on that rule it always fails. Even when i’m using NOFAIL(RULE ^reuse(label)). What am I doing wrong? Here is the code:

u: (test) ^keep() ^repeat() NOFAIL(RULE ^reuseTEST2 ))
u: (gambit) ^keep() ^repeat() NOFAIL(RULE ^reuse(TEST1))
  
tTEST1 ()   This is something to say.
a: (~yesyou said okay
   b
:  TEST2 (~yesthats right what you said
      c
: (~yes) finally you admit
      c
: (~noyou dont admit
   b
: (~nodint say that
 

 
  [ # 7 ]

Yup. You are wading into deep waters.

@3 = ^query() 
is how you do other than @0.  OR
^query(type sub verb obj -1 ? @3)    (@3 is the toset argument)

more later for the rest of your stuff.

 

 
  [ # 8 ]

Not sure I understand:” Since the svo triples are defined by user input and not words i pick I will probably have to save them as soon as the fact is created by using _0 _1 to define them, right?”

What does “save them” mean- are your referring back to export/import discussion?  You had to export ONLY because you were involved in a :reset operation. Otherwise the facts were automatically saved with the user and if they came back some later time and conversed, the facts would still be there.  Your scenario is perfectly possible.

 

 
  [ # 9 ]

check the docs on query… it can take up to 9 arguments.  so the TOSET is merely one of them.

 

 
  [ # 10 ]

It’s just that it seems i have to reset each time i rebuild the script as the patterns I have defined fail unless i also add ^repeat.  Which is why I thought it would be best to export each time a new fact was created. in case, i forgot before a reset and lost all that data

I guess I could just add repeat at the topic flags but then it seems to get stuck on one gambit sometimes. I’ve worked with other languages before but CS is different because you dont always have full linear control of the path.

 

 
  [ # 11 ]

add repeat as a topic flag to the topic itself. Then it doesnt need to be on the rules individually.  It can only get stuck on a gambit if you do ^keep() on that gambit or the topic is declared system.  If your topic has gambits to ask questions in order to elicit a fact, they can naturally erase themselves and then the last one can do ^reset(TOPIC) to unerase all the gambits to start over again.

If you want full linear control of a path, you can script to do that.  But you have to edit the control script appropriately

 

 
  [ # 12 ]

I was playing around with the query options to see if I can generate a factset with all facts without knowing either s v or o but can’t seem to find one. I assume that q in query def marks something for processing and t marks it for output.

Tried creating various new queries using combos of svot: but while I didn’t always get a query control code error in bugs.txt I did get a “bad number1” error for my rule with the query. Does bad number refer to parameters? I’m sure query will always require a type parameter but will it always also require word parameter(even if word is ?) I tried calling the query with only the queryname or queryname and ? ? ? Both generated “bad number1” errors

 

 
  [ # 13 ]

I’m sorry to have bugged ya so much Bruce. I think the best step for me right now as a noob to CS is to work on pattern handling to direct the flow of conversation and see how realisitc I can make it. I can worry about creating learning algorithims and such once I get a proper handle on that first. I understand the basic concepts of CS so I’ll get to work on that. I’ll try not to bother you on this forum for a while….I know I’ve already started a lot of threads in a very short time.

 

 
  [ # 14 ]

I’m not objecting to your posting so much, but I do agree you should master the basics of patterns and such before working on learning.  But I did figure you’d eventually want to try to get all user facts (possibly for export) w/o knowing any of SVO, so I added that ability this weekend and it will be in the next CS release in a couple of weeks.

Bad number1 refers to something the system tried to decode as a number but found faulty.  If you send me the source and how to get the message, I can try to figure it out.

 

 
  [ # 15 ]

Thanks for adding the functionality Bruce.

Could you tell me why the u:(test) rule in the following code fails unless ^repeat has been added to TEST2 even though I’m using NOFAIL?

u: (test) ^keep() ^repeat() NOFAIL(RULE ^reuseTEST2 ))
u: (gambit) ^keep() ^repeat() NOFAIL(RULE ^reuse(TEST1))
  
tTEST1 ()   This is something to say.
a: (~yesyou said okay
   b
:  TEST2 (~yesthats right what you said
      c
: (~yes) finally you admit
      c
: (~noyou dont admit
   b
: (~nodint say that
 

 1 2 > 
1 of 2
 
  login or register to react