Skip to content

LavirtheWhiolet/markov-chain-bot-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Markov chain chat bot

A chat bot utilizing Markov chains. It speaks Russian and English.

How to build

  • Install Ruby 1.9.1 or latest.
  • Give command rake in this directory.
  • You have got a Ruby gem!

Examples

Basic usage:

require 'markov_chain_chat_bot'

bot = MarkovChainChatBot.from(Hash.new)
bot.learn("one two three two one")
bot.answer("count up and down please")
  #=> "one two three two three two one two one two three two one two one"
bot.learn("three four six")
bot.answer("count from three please")
  #=> "three two one two one two three four six"

One may save the bot's knowledge into key-value storage:

require 'markov_chain_chat_bot'
require 'auto_marshalling_map'
require 'gdbm'

# 1.
kvs = GDBM.open("chat_bot.dat")
bot = MarkovChainChatBot.from(AutoMarhsallingMap.new(kvs))
bot.learn("one two three two one")
kvs.close()

# 2.
kvs = GDBM.open("chat_bot.dat")
bot = MarkovChainChatBot.from(AutoMarhsallingMap.new(kvs))
bot.answer("count up and down please")
  #=> "one two three two three two three two one two one"

Credits

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages