AI Zone Admin Forum Add your forum

CX Company, chatbot market leader in the Netherlands since 2005, will speak on the Amsterdam Chatbots Meetup on Wednesday, Oct 18!

AIML generator
 
 

In October last year my school competed in some kind of code jam where we had to write any software in 24 hours and first thing which came in my mind was chatbot and language I chose to implement in was AIML. However, as programmer, and I believe other fellow developers had same thought working with AIML, working with XML is pain in the a*s. It’s very prone to errors and documents quickly become big and hard to manage.

As I worked in Ruby, I was thinking about writing library which will allow me to keep writing Ruby code but also translate everything in AIML. And I came up with some simple solution, Rocket. This is one example of the code so you can get the idea how it looks:

# This code is written for Rocket generator which generates
# AIML code out of Ruby methods.
# Run it with 'ruby discussion.rb' in the root directory of project

require_relative "lib/core.rb"

bot Bot.new("srbot")

# Pozdravi
bot.on "Zdravo"rand([
 
"Zdravo ljudsko biće!",
 
"Zdravo!",
 
"Hej!"
])

bot.on "Ćao"to("Zdravo")
bot.on "Ćao *"to("Ćao")

bot.on "Pozdrav"to("Zdravo")
bot.on "Pozdrav *"to("Pozdrav")

bot.on "Hej"to("Zdravo")

bot.on "Kako si"rand([
 
"Osećam se super, ti?",
 
"Dobro sam!",
 
"Nisam baš najbolje..."
])

bot.on "Ja sam""Pretpostavio sam da si ti."
bot.on "Ja sam *""Drago mi je #{star}!"
bot.on "Zovem se *""Počastvovan sam #{star}!"

# Podaci o ličnosti
bot.on "Ime""Zovem se Serbian Chatbot."
bot.on "_ se zoveš"to("Ime")
bot.on "_ ti je ime"to("Ime")
bot.on "_ te zovu"to("Ime"

As you can see it’s pretty straightforward and pulls inspiration from MVC framework Ruby on Rails. There are clearly advantages and disadvantages of this approach, most notable ones:

- You don’t have to switch over the syntaxes i.e. you can write the same code for back-end and template
- You do more with less code
- You can easily add new methods and generators to avoid doing boring, repetitive tasks
- You don’t have to mess with XML and you can use any XML beautify library to automatically fix indentation of your code and set it to do the same thing with more files

And some disadvantages:

- Learning new library
- Indentation hell (condition(... request( ... (set ... )) blah blah)
- ... dependencies?

Have anyone tried something similar in the past and do you personally think it would be helpful to write generators for AIML for different languages? (Swift, for example:)

on(
    
"how are you",
    
response
        
condition("happy", for: "emotion"result"I'm happy! :D"),
        
condition("sad",   for: "emotion"result"I'm sad... :("),
        
condition("angry", for: "emotion"result"I'm angry! :mad:")

Or ...

on(
    
"how are you",
    
response:
        
conditions(for: "emotion",
            
[
                
"happy""I'm happy! :D",
                
"sad":   "I'm sad... :(",
                
"angry""I'm angry! :mad:"
            
]
        
)
 

 
  [ # 1 ]

Bravo Nicola,

I’m me too a Ruby developer.

No, never tried to make a Ruby-to-AIML translator

Noah Petherbridge worked with the aim to simplify AIML, achieving https://www.rivescript.com/

 

 
  [ # 2 ]

Yeah, I know for RiveScript - interesting solution, but not verbose enough for my taste; it’s too symbolic while I aim to make something more self-explanatory.

 

 
  [ # 3 ]

I see things in opposite way grin

for me, even if I’m a ruby developer (!)

scripting languages like rivescript (or chatscript) are more concise (less verbose and reusable) than the if-then-else aka “hard-coding” the dialog flow with standard programming languages. I wrote a bunch of articles on that (http://www.medium.com/@solyarisoftware)...


my two cents

 

 
  [ # 4 ]
Giorgio Robino - Apr 5, 2017:

I see things in opposite way grin

for me, even if I’m a ruby developer (!)

scripting languages like rivescript (or chatscript) are more concise (less verbose and reusable) than the if-then-else aka “hard-coding” the dialog flow with standard programming languages. I wrote a bunch of articles on that (http://www.medium.com/@solyarisoftware)...


my two cents

+1

 

 

 
  [ # 5 ]

Hey friends, how’s my Bosnian? wink

# This code is written for Rocket generator which generates
# AIML code out of Ruby methods.
# Run it with 'ruby discussion.rb' in the root directory of project

require_relative "lib/core.rb"

bot Bot.new("srbot")

Bot.on "Hello"rand ([
 
"Hello, human being!",
 
"Hello!",
 
"Hey!"
])

Bot.on "Hello"it ("Hello")
Bot.on "Hello"to ("Hi")

Bot.on "Hello"it ("Hello")
Bot.on "Hello"it ("Hello")

Bot.on "Hey"it ("Hello")

Bot.on "How are you"rand ([
 
"I feel great, you?",
 
"I'm fine!",
 
"I'm not the best ..."
])

Bot.on "I am""I assumed you were."
Bot.on "I am *""I'm glad # {star}!"
Bot.on "My name is""I am honored # {star}!"

# Personality data
Bot.on "Name""My name is Serbian Chatbot."
Bot.on "your name"it ("Name")
Bot.on "your name"it ("Name")
Bot.on "they call you"it ("Name"

Learning Bosnian Language

https://www.youtube.com/watch?v=4YO_G9pxQLU

 

 

 
  [ # 6 ]

I have a server with rails. This makes me want to investigate that.

 

 
  login or register to react