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

Logically OR in patterns/pattern macros?
 
 

I have a number of ‘high level’ patterns I use frequently in rejoinders, and I wish to share/reuse their script.  Here’s a simplified example of looking for user responses after the bot has made a statement:

#! That’s incorrect
s: MISTAKEN ( !not ~incorrectness ) Oh sorry, I am mistaken.

#! You’re not correct
# s: ( not *~2 ~correctness ) ^reuse(MISTAKEN)

#! No
# s: ( ~no ) ^reuse(MISTAKEN)


This is essentially a logical OR of the 3 different pattern types.  A match of any of them produces the same result.

I know I can implement this as an output macro, or as a system topic invoked via ^respond().  These both come with their own advantages (eg. ability to produce output or rejoinders).

However, a lot of the time I just want to wrap them into a pattern macro so I can do this:

s: ( ^IS_INCORRECT() ) Oh sorry, I am mistaken.

My question is : is there a way of wrapping up all three tests in a single pattern macro?

 

 
  [ # 1 ]

Sure.

patternmacro: ^incorrect()
  [
    ~no
  ( not *~2 ~correctness )
  ( !not ~incorrectness )
  ]

 

 
  [ # 2 ]

Brilliant, thanks.  I should have worked that out myself!

 

 
  login or register to react