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

manually working with facts and queries e.g. > :do ^query()
 
 

I am trying to run some experiments using queries in order to workout some application logic. I am in ‘dual mode’, you know chatscript.exe. I am not in server mode or client mode.

Now, I have some facts that get created by tables. Here they are:

> :facts requiredby
216383
: ( manywho-goalid requiredby repeating-manywho-goalid x100000 )
216382: ( manywho-code-goalid requiredby repeating-manywho-goalid x100000 )
216226: ( location-goalid requiredby provider-finder-goalid x100000 )
216223: ( support-bnumber-goalid requiredby support-unlock-account-goalid x100000 )
216220: ( manywho-code-goalid requiredby manywho-goalid x100000 

using ^writefact and using ToSet parm for ^query kind of works. It only gives you the first fact in the set. How would I get the rest of them?

: > :do ^writefact( ^querydirect_v requiredby ? @5fact) )
CHARLIE:  ( manywho-goalid requiredby repeating-manywho-goalid x100000 

I do not seem to be able to manually run a query to get a fact collection and look at the results.


I thought I would use :fact @10 to show the fact set. Now facts do not stay between volleys so you can’t just do @10 = ^query() and then do :facts@10. But I thought ^save(@10) would do it. It does not.
This does not work.

: > :do ^save(@10 true)
CHARLIE:
: > :do @
10 =  ^querydirect_v requiredby ? )
CHARLIE:
: > :
facts @10
Fact set 
@100 facts 

Using ^writeFact() does not work

> :do ^writefact( ^first( ^query(direct_v requiredby ?) ) )
CHARLIE


Is there any way to try these things without having to put it into a rule and recompile the bot?
I was hoping it would be a bit like :testPattern and :testtopic, where you can try things out on the system without having to rebuild.

 

 

 
  [ # 1 ]

For our bot we’ve written a ^dumpfactset() macro that will take a factset and write it to the screen. Then I can

> :do @1 = ^query(exact_s something ? ?) ^dumpfactset(@1)

The macro just loops through the fact set and does a ^writefact on each one.

 

 
  [ # 2 ]

Andy,

Thanks for the advice.

Care to share that little nugget of gold?

 

 
  [ # 3 ]

Don’t have the code with me here at home, but it is going to be something like:

^dumpfactset (^set)
{
    
@= ^set
    
^loop() {
        $_f 
= ^first(@0fact)
        ^
writefact($_f\n
    }
 

 
  login or register to react