NAME Hailo - A pluggable Markov engine analogous to MegaHAL SYNOPSIS use strict; use warnings; use Hailo; my $hailo = Hailo->new( # Or Pg, or Perl ... storage_class => 'SQLite', brain_resource => 'brain.db' ); while (<>) { $hailo->learn($_); say $hailo->reply($_); } DESCRIPTION Hailo is a fast and lightweight markov engine intended to replace AI::MegaHAL. It has a lightweight Moose-based core with pluggable storage and tokenizer backends. It is similar to MegaHAL in functionality, the main difference being (with the default storage/tokenizer backends) better scalability, drastically less memory usage, and an improved tokenizer. With this distribution, you can create, modify, and query Hailo brains. To use Hailo in event-driven POE applications, you can use the POE::Component::Hailo wrapper. One example is POE::Component::IRC::Plugin::Hailo, which implements an IRC chat bot. Etymology *Hailo* is a portmanteau of *HAL* (as in MegaHAL) and failo . ATTRIBUTES "brain_resource" The name of the resource (file name, database name) to use as storage. There is no default. "order" The Markov order (chain length) you want to use for an empty brain. The default is 5. "storage_class" The storage backend to use. Default: 'SQLite'. This gives you an idea of approximately how the backends compare in speed: Rate CHI::File PostgreSQL CHI::BerkeleyDB MySQL CHI::Memory SQLite Perl::Flat Perl CHI::File 1.08/s -- -53% -63% -70% -71% -78% -89% -93% PostgreSQL 2.28/s 112% -- -21% -35% -38% -53% -76% -86% CHI::BerkeleyDB 2.90/s 169% 27% -- -18% -21% -40% -70% -82% MySQL 3.53/s 228% 55% 22% -- -4% -27% -63% -78% CHI::Memory 3.68/s 242% 61% 27% 4% -- -24% -62% -78% SQLite 4.81/s 347% 111% 66% 36% 31% -- -50% -71% Perl::Flat 9.62/s 793% 321% 232% 172% 162% 100% -- -41% Perl 16.4/s 1423% 618% 466% 364% 346% 241% 70% -- To run your own test try running utils/hailo-benchmark in the Hailo distribution. "tokenizer_class" The tokenizer to use. Default: 'Words'; "ui_class" The UI to use. Default: 'ReadLine'; "storage_args" "tokenizer_args" "ui_args" A "HashRef" of arguments storage/tokenizer/ui backends. See the documentation for the backends for what sort of arguments they accept. "token_separator" Storage backends may choose to store the tokens of an expression as a single string. If so, they will be joined them together with a separator. By default, this is "\t". METHODS "new" This is the constructor. It accepts the attributes specified in "ATTRIBUTES". "run" Run the application according to the command line arguments. "learn" Takes a string or an array reference of strings, and learns from them. "train" Takes a filename, filehandle or array reference and learns from all its lines. If a filename is passed, the file is assumed to be UTF-8 encoded. Unlike "learn", this method sacrifices some safety (disables the database journal, fsyncs, etc) for speed while learning. "reply" Takes an optional line of text and generates a reply that might be relevant. "learn_reply" Takes a string argument, learns from it, and generates a reply that might be relevant. "save" Tells the underlying storage backend to save its state. CAVEATS All occurences of "token_separator" will be stripped from your input before it is processed, so make sure it's set to something that is unlikely to appear in it. SUPPORT You can join the IRC channel *#hailo* on FreeNode if you have questions. SEE ALSO Hailo: A Perl rewrite of MegaHAL - A blog posting about the motivation behind Hailo AUTHORS Hinrik Örn Sigurðsson, hinrik.sig@gmail.com Ævar Arnfjörð Bjarmason LICENSE AND COPYRIGHT Copyright 2010 Hinrik Örn Sigurðsson and Ævar Arnfjörð Bjarmason This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.