NAME
    Hailo - A pluggable Markov engine analogous to MegaHAL

SYNOPSIS
    This is the synopsis for using Hailo as a module. See hailo for
    command-line invocation.

        # Hailo requires Perl 5.10
        use 5.010;
        use strict;
        use warnings;
        use Hailo;

        # Construct a new in-memory Hailo using the SQLite backend. See
        # backend documentation for other options.
        my $hailo = Hailo->new;

        # Various ways to learn
        my @train_this = qw< I like big butts and I can not lie >;
        $hailo->learn(\@train_this);
        $hailo->learn($_) for @train_this;

        # Heavy-duty training interface. Backends may drop some safety
        # features like journals or synchronous IO to train faster using
        # this mode.
        $hailo->learn("megahal.trn");
        $hailo->learn($filehandle);

        # Make the brain babble
        say $hailo->reply("hello good sir.");

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 differences (with
    the default backends) being better scalability, drastically less memory
    usage, an improved tokenizer, and tidier output.

    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
    <http://identi.ca/failo>.

ATTRIBUTES
  "brain_resource"
    The name of the resource (file name, database name) to use as storage.
    There is no default.

  "save_on_exit"
    A boolean value indicating whether Hailo should save its state before
    its object gets destroyed. Defaults to true.

  "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 DBD::Pg DBD::mysql DBD::SQLite/file DBD::SQLite/memory
        DBD::Pg            2.22/s      --       -33%             -49%               -56%
        DBD::mysql         3.33/s     50%         --             -23%               -33%
        DBD::SQLite/file   4.35/s     96%        30%               --               -13%
        DBD::SQLite/memory 5.00/s    125%        50%              15%                 --

    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 for storage/tokenizer/ui backends. See the
    documentation for the backends for what sort of arguments they accept.

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. To override the
    filename you can provide one as an argument.

  "stats"
    Takes no arguments. Returns the number of tokens, expressions, previous
    token links and next token links.

SUPPORT
    You can join the IRC channel *#hailo* on FreeNode if you have questions.

SEE ALSO
    Hailo::UI::Web - A Catalyst and jQuery powered web interface to Hailo

    POE::Component::Hailo - A non-blocking POE wrapper around Hailo

    POE::Component::IRC::Plugin::Hailo - A Hailo IRC bot plugin

LINKS
    Hailo: A Perl rewrite of MegaHAL - A blog posting about the motivation
    behind Hailo

BUGS
    Bugs, feature requests and other issues are tracked in Hailo's issue
    tracker on Github <http://github.com/hinrik/hailo/issues>.

AUTHORS
    Hinrik Örn Sigurðsson, hinrik.sig@gmail.com

    Ævar Arnfjörð Bjarmason <avar@cpan.org>

LICENSE AND COPYRIGHT
    Copyright 2010 Hinrik Örn Sigurðsson and Ævar Arnfjörð Bjarmason
    <avar@cpan.org>

    This program is free software, you can redistribute it and/or modify it
    under the same terms as Perl itself.

