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

RiveScript to AIML Converter (rs2aiml)
 
 

Because I was up to the challenge, I’ve written a converter script that translates RiveScript code into AIML (you read that right—rs2aiml!)

The biggest challenge in converting RS to AIML is that RS uses a simplified regular expression system for its triggers, whereas AIML’s patterns are just plain text and wildcards. I found a deviously simple algorithm to calculate all the possible permutations of RS triggers though on PerlMonks ( http://www.perlmonks.org/?node_id=24270 ) and then got to work writing the converter!

The permutation algorithm can turn this:

what is my (home|office|cell) [phone] number

Into this list of things!

what is my home phone number
what is my home number
what is my office phone number
what is my office number
what is my cell phone number
what is my cell number

The converter generates what appears to be valid AIML code (I haven’t tested loading the AIML into an Alicebot, but the syntax looks good to me). Compared to the aiml2rs, this one only has a few limitations:

[ul]
[li]Conditions can only check == equality in AIML, so any RS replies that do anything otherwise are skipped entirely.[/li]
[li]Conditions can only check user variables to values. Any condition in RS more complex than “<get whatever> == value” is skipped entirely.[/li]
[li]AIML can’t have nested <set> tags (<set name=“fav<star index=“1” >”>), so replies that rely on this are skipped entirely.[/li]
[li]If your RS trigger has embedded parenthesis groups, like “(what (is|be)) *”, they’ll be skipped. This is technically OK for a regular expression, but nowhere in the RiveScript docs does it ever recommend embedding parenthesis groups. Any triggers that do get skipped because these can’t be cleanly permutated out for AIML.[/li]
[/ul]

For each trigger that has any permutations, the first permutation becomes the category that has all the reply data in it; all the other permutations end up with an <srai> that redirects back to the first one.

This is beta quality (it only took me a couple hours to write, and hasn’t been extensively tested apart from the standard default RS brain), but let me know if there are any major bugs in it. smile

The code is in the aiml2rs repo on github: https://github.com/kirsle/aiml2rs

 

 
  [ # 1 ]

Noah, if something is skipped, is there a warning or notification generated, so that the user is aware of it? It seems to me that this would be an important step, so that the user can address whatever issues might arise from overly complex or untranslatable responses. smile

 

 
  [ # 2 ]

Yeah, it shows a list of warnings at the end for all the replies it skipped.

 

 
  login or register to react
     RiveScript Tutorial ››