AI Zone Admin Forum Add your forum

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

Repeating output after ^refine

I am trying to get repeated output (get output from the same pattern, repeatedly).

This works fine:

u: (who _I
keep() ^repeat()
$var = %ip
?] [Who are you?] [who you are?] [your identity?] You are $$var 

But I have yet to find how that works after ^refine, nothing I have tried will repeat output- I can get only one round of output.

u: ( ~anatomy ) ^refine()  # gets any reference to anatomy
a: (hardLike a bone
a: (softLike a fatty lump
a: (~bodypart
$BPART '_0
  A problem with your $$BPART ?
 a: (_*)
  Would you like to consult with a human now? 

I am sure it is something simple, but I am not clever enough to have yet figured it out for myself.


  [ # 1 ]

So what allows you to KEEP that rule?  THis code works fine for me…
topic: ~introductions safe keep repeat()
t: gambit1 ^keep()
u: ( arm ) ^refine()  # gets any reference to anatomy
a: (hard) Like a bone?
a: (soft) Like a fatty lump?


  [ # 2 ]

Sorry, I am still on the bottom of the steep slope of the CS learning curve.  I actually had the control script leading me astray on this issue (along with various self-induced syntactical anomalies).

On a similar vein, the following code worked fine for me to retrieve “emotion” so I could match an appropriate image to the emotion:

topic: ~getimageemo nostay()

u: ( _* ) keep() repeat() refine()
a: (~feeling_sad$EMOIMAGENAME sad.png 
: (~feeling_happy$EMOIMAGENAME happy.png 
: (~emocurse$EMOIMAGENAME curse.png
: (~feeling_angry$EMOIMAGENAME angry.png 
: (~no)  $EMOIMAGENAME no.png
: (~yes)  $EMOIMAGENAME yes.png
: (~emogoodbye)  $EMOIMAGENAME bye.png 
: ( _* ) $EMOIMAGENAME = default.png 

I am still a little confused as to where and when the ^ and () need to be used with, for example, keep and repeat.

Also, I have yet to figure out how to include the variable ($EMOIMAGENAME) into the output stream response (currently just hacked it in by calling nofail(TOPIC respond(~getimage)) in the control script (to varying degrees of success) and then parsing the img url out of the response on the web page (using a derivative of Daves “better” php web interface) using JS. I would prefer to have this variable passed as an oob starter (encapsulated in []?). How could I append (or prepend) the $EMOIMAGENAME to the response sent from the CS server?



  [ # 3 ]

So, when using keep and repeat on a rule (as opposed to the topic),  these are built-in functions.
The CORRECT way to refer to all functions is to put ^ in front of the name, but CS is forgiving and if you omit the ^ and it can find your name exists as a function, it will do that for you.  This helpfulness will be a problem with something like this:

u: ( [  find (search for) ] ) 
if find is a function, then this will not be correct and you would have to reorder to
u: ([  (search for)  find] )

So that the system cannot interpret find as a function.

The typical way to manage oob stuff is to have a function you call in script:
outputmacro: ^oob($_what)
$$oob = $_what
Then in postprocessing have a rule like this:
t: ($$oob) ^postprintbefore( \[ $$oob \]) $$oob = null



  login or register to react