john-doe¶ ↑
John doe is simple chatbot AI basing on idea of AIML language. Yaml is used instead of xml.
Getting started¶ ↑
-
Install the gem
sudo gem install john-doe
-
Create your rules file (like default.yml)
-
Sample usage:
require 'rubygems' require 'john-doe' cb = JohnDoe::ChatBot.new() while true print "User: " input = gets.chomp break if input == "" response = cb.get_response input puts "Bot: #{response.text} (emotion:#{response.emotion})" end
Configuration¶ ↑
If you want to create your own rules file just do:
JohnDoe::ChatBot.new("your_rules.yml")
If you want to use another quotes file just do:
JohnDoe::ChatBot.new("your_rules.yml", "my_quotes.txt")
Rules file¶ ↑
See github.com/dfens/john-doe/raw/master/default.yml to understand what should be in you rules.yml file. Generally all bot responses are based on patterns that are regex-like, for example:
whoareyou:
patterns: p1: who are you p2: what are you responses: r1: I am chatbot r2: I am coolest bot in the net r3: "I'm nobody" r4: "I am bot:name"
If bot does not recognize the sentence it will use markov chain to build it. Bot learns from what you write to him (he will load this data in new session).
There is also possible to add some universal knowledge for bot:
knowledge: bot: age: "21" sex: "men" language: "english" name: "John" surname: "Doe" specimen: "Human"
Now in your answers you may use scheme like: “bot:age”, example
age: patterns: p1: * old are you p2: your age p3: how do you feel p4: how do you do responses: r1: "I am bot:age old" r2: "I am bot:age"
Context¶ ↑
You can use context of dialog like in example:
whats:
patterns: p1: what's $ p2: what is $ p3: Tell me something about $ responses: r1: "I'm not sure what's $"
Now if someone will write “tell me something about ruby language” bot will answer “I’m not sure what’s ruby language”
Quotes¶ ↑
Quotes file is collection of sentences provided by user during chat. Using markov chains bot is generating answer if he can’t recognize pattern.
Copyright¶ ↑
Copyright © 2010 Pawel Mikolajewski. See LICENSE for details.