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

Chatscript Sample Code: Plurals and renaming match variables
 
 

Chatscript can return the part of speech for words that it knows using the ^POS function.  You can also create your own output macros that are like functions.  Here is one for plural nouns which simplifies the use of the ^POS function for plural nouns.  This allows for one pattern or rule to handle many inputs.

Chatscript stores matched words for any word or concept preceded with an underscore into the variables _0,_1,_2,_3….

You can rename these variables to something more meaningful.  I have renamed mine to _star,_star2,_star3…. to be more similar to the AIML syntax it uses for its match tags <star>,<star index=2>, ....

Sample Code:

outputmacro: ^PLURAL(^ARG1)  ^POS(NOUN ^ARG1 PLURAL)

rename_star  _0

Topic
: ~SEENANIMALS see ~animals )

u: ( have you seen {a an} _~animals ) ^keep() ^repeat() I have seen ^PLURAL(_star). 

Output:
alaric: > have you seen a dog?
HARRY:  I have seen dogs.
alaric: > have you seen a deer?
HARRY:  I have seen deer.
alaric: > have you seen a hippopotamus?
HARRY:  I have seen hippopotami.

 

 

 

 
  login or register to react