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

How can I allow and underscore in input?
 
 

I’d like to be able to match for input such as “query_vars”, but it won’t match it due to the underscore. How can I escape the underscore so I can match against it?

 

 
  [ # 1 ]

Search for “query vars” instead. The underscore will be removed by the normalization process.

In AIML, I would advise not using variables with special characters in though.

 

 
  [ # 2 ]

The way I want this bot to work, users will include underscores quite often in their input (for various WordPress function names). There is no way to allow underscores in user input?

 

 
  [ # 3 ]

They can still use the underscore. As I say, the underscore will be removed and so to check “query_vars” you should check “query vars”. They must not use underscores by themselves though as it will count as the underscore wildcard.

query_vars = good
query _ vars = bad

 

 
  [ # 4 ]

Hmm. Maybe it’s a bug with pandorabots (which I’m using). If I set up “query vars” as a check, it works against “query vars” (obviously) but not against “query_vars”. Screenshot: http://screencast.com/t/TLVNsotD6

Should I try working with something other than pandorabots?

 

 
  [ # 5 ]

Do you have any debug categories? I have one that echos the input back so I can see what the interpreter is seeing:

<category>
<
pattern>ECHO *</pattern>
<
template><star/></template>
</
category

You can then see what query_vars translates to.
Add this category and then type Echo query_vars

Have you tried using the “say instead” box to add an answer and then checking the AIML to see what the pattern was?

Mickey Mellen - Apr 3, 2016:

Should I try working with something other than pandorabots?

Yes, if I was first starting to learn how to play the piano with one finger and couldn’t play a complex Mozart concerto after a few attempts, I too would give up… hmmm

 

 
  [ # 6 ]
Steve Worswick - Apr 3, 2016:

Have you tried using the “say instead” box to add an answer and then checking the AIML to see what the pattern was?

When I do that, it saves it with the underscore replaced with a space(“query vars”), as you mentioned. However, it won’t match the underscore against the space if I do it again as “query_vars”. I’m simply unable to find something I can put in the system that will match up against an input of “query_vars”.

Yes, if I was first starting to learn how to play the piano with one finger and couldn’t play a complex Mozart concerto after a few attempts, I too would give up… hmmm

Sorry, I’m clearly new to this and stumbled upon pandorabots. Wasn’t sure if you’d suggest an alternate piece of software. I’m certainly willing to continue digging into it as it seems rather intuitive (aside from this edge case I’m fighting with).

 

 
  [ # 7 ]

I was able to use the normal and denormal substitution files to map an underscore to a vertical pipe character |
In the normal file map an underscore to a vertical pipe.
In the denormal file map a vertical pipe to an underscore.

In my patterns and stored data I use the vertical pipe character everywhere I would have normally used an underscore.  So in your case you should be able to match on query|vars.
If wrap your output in a denormalize tag then you will get back your underscores.  So in your case:
<DENORMALIZE>query|vars</DENORMALIZE>

should result in:
query_vars

as output.

This has the advantage of keeping your terms together when looping through words in a sentence or otherwise parsing a sentence instead of having “query” and “vars” appear as two separate terms.

 

 

 
  [ # 8 ]

Brilliant! That solved it. Thanks so much for your help, both of you.

 

 
  [ # 9 ]

Great! I would still be interested in seeing the results of the ECHO command though, just for my own curiosity smile

 

 
  login or register to react