From 7dc1c024c1f29552f131b280ec9fae838301caf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hinrik=20=C3=96rn=20Sigur=C3=B0sson?= Date: Fri, 12 Feb 2010 04:19:58 +0000 Subject: [PATCH] Various Pod corrections --- Changes | 3 + README | 70 ++++++++++++------------ lib/Hailo.pm | 82 ++++++++++++++-------------- lib/Hailo/Role/Storage.pm | 8 +-- lib/Hailo/Storage/CHI/BerkeleyDB.pm | 4 +- lib/Hailo/Storage/CHI/File.pm | 4 +- lib/Hailo/Storage/CHI/Memory.pm | 4 +- lib/Hailo/Storage/DBD/SQLite.pm | 18 +++--- lib/Hailo/Storage/Mixin/CHI.pm | 4 +- lib/Hailo/Storage/Mixin/Hash.pm | 3 +- lib/Hailo/Storage/Mixin/Hash/Flat.pm | 4 +- lib/Hailo/Storage/Mixin/Storable.pm | 4 +- lib/Hailo/Storage/Perl.pm | 1 - lib/Hailo/Storage/Perl/Flat.pm | 1 - lib/Hailo/UI/ReadLine.pm | 6 -- 15 files changed, 104 insertions(+), 112 deletions(-) diff --git a/Changes b/Changes index ad36e81..8d2ac27 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +0.11 + - Corrected outdated documentation in some places + 0.10 Fri Feb 12 02:31:34 GMT 2010 - Normalized the SQL schema some more. This breaks compatability with old brains of course, but training/learning is quite a bit faster now. diff --git a/README b/README index 61e8902..5d4c66d 100644 --- a/README +++ b/README @@ -2,28 +2,34 @@ NAME Hailo - A pluggable Markov engine analogous to MegaHAL SYNOPSIS - use Hailo; + use strict; + use warnings; + use Hailo; - my $hailo = Hailo->new( - # Or Pg, or Perl ... - storage_class => 'SQLite', - brain_resource => 'brain.db' - ); + my $hailo = Hailo->new( + # Or Pg, or Perl ... + storage_class => 'SQLite', + brain_resource => 'brain.db' + ); - while (<>) { - $hailo->learn($_); - print $hailo->reply($_), "\n"; - } + while (<>) { + $hailo->learn($_); + print $hailo->reply($_), "\n"; + } DESCRIPTION Hailo is a fast and lightweight markov engine intended to replace AI::MegaHAL. It has a lightweight Moose-based core with pluggable - storage, tokenizer and engine backends. + storage and tokenizer backends. - It's faster than MegaHAL and can handle huge brains easily with the - default SQLite backend. It can be used, amongst other things, to - implement IRC chat bots with POE::Component::IRC. In fact, there exists - a POE::Component::IRC plugin for just that purpose. + 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 asynchronous applications, you can use the + POE::Component::Hailo wrapper. One example is + POE::Component::IRC::Plugin::Hailo, which implements and IRC chat bot. Etymology *Hailo* is a portmanteau of *HAL* (as in MegaHAL) and failo @@ -44,15 +50,15 @@ ATTRIBUTES This gives you an idea of approximately how the backends compare in speed: - s/iter CHI::File CHI::BerkeleyDB PostgreSQL MySQL CHI::Memory SQLite Perl Perl::Flat - CHI::File 15.1 -- -51% -72% -75% -82% -91% -95% -95% - CHI::BerkeleyDB 7.43 103% -- -42% -49% -64% -81% -90% -91% - PostgreSQL 4.30 252% 73% -- -11% -37% -67% -83% -84% - MySQL 3.83 295% 94% 12% -- -29% -63% -81% -82% - CHI::Memory 2.70 460% 176% 59% 42% -- -48% -73% -75% - SQLite 1.41 972% 427% 205% 171% 91% -- -48% -52% - Perl 0.735 1957% 911% 485% 420% 267% 92% -- -7% - Perl::Flat 0.683 2114% 988% 529% 460% 295% 106% 8% -- + s/iter CHI::File CHI::BerkeleyDB PostgreSQL MySQL CHI::Memory SQLite Perl Perl::Flat + CHI::File 15.1 -- -51% -72% -75% -82% -91% -95% -95% + CHI::BerkeleyDB 7.43 103% -- -42% -49% -64% -81% -90% -91% + PostgreSQL 4.30 252% 73% -- -11% -37% -67% -83% -84% + MySQL 3.83 295% 94% 12% -- -29% -63% -81% -82% + CHI::Memory 2.70 460% 176% 59% 42% -- -48% -73% -75% + SQLite 1.41 972% 427% 205% 171% 91% -- -48% -52% + Perl 0.735 1957% 911% 485% 420% 267% 92% -- -7% + Perl::Flat 0.683 2114% 988% 529% 460% 295% 106% 8% -- To run your own test try running utils/hailo-benchmark in the Hailo distribution. @@ -60,15 +66,11 @@ ATTRIBUTES "tokenizer_class" The tokenizer to use. Default: 'Words'; - "engine_class" - The engine to use. Default: 'Default'; - - "engine_class" + "ui_class" The UI to use. Default: 'ReadLine'; "storage_args" "tokenizer_args" - "engine_args" "ui_args" A "HashRef" of arguments storage/tokenizer/engine/ui backends. See the documentation for the backends for what sort of arguments they accept. @@ -80,7 +82,7 @@ ATTRIBUTES METHODS "new" - This is the constructor. It accept the attributes specified in + This is the constructor. It accepts the attributes specified in "ATTRIBUTES". "run" @@ -90,16 +92,16 @@ METHODS Takes a line of UTF-8 encoded text as input and learns from it. "train" - Takes a filename and calls "learn" on all its lines. Lines are expected + Takes a filename and calls "learn" on all its lines. The file is assumed to be UTF-8 encoded. "reply" - Takes a line of text and generates a reply (UTF-8 encoded) that might be + Takes an optional line of text and generates a reply that might be relevant. "learn_reply" - Takes a line of text, learns from it, and generates a reply (UTF-8 - encoded) that might be relevant. + Takes a line of text, learns from it, and generates a reply that might + be relevant. "save" Tells the underlying storage backend to save its state. diff --git a/lib/Hailo.pm b/lib/Hailo.pm index e22cd11..78ce3eb 100644 --- a/lib/Hailo.pm +++ b/lib/Hailo.pm @@ -467,32 +467,37 @@ Hailo - A pluggable Markov engine analogous to MegaHAL =head1 SYNOPSIS - use Hailo; + use strict; + use warnings; + use Hailo; - my $hailo = Hailo->new( - # Or Pg, or Perl ... - storage_class => 'SQLite', - brain_resource => 'brain.db' - ); + my $hailo = Hailo->new( + # Or Pg, or Perl ... + storage_class => 'SQLite', + brain_resource => 'brain.db' + ); - while (<>) { - $hailo->learn($_); - print $hailo->reply($_), "\n"; - } + while (<>) { + $hailo->learn($_); + print $hailo->reply($_), "\n"; + } =head1 DESCRIPTION Hailo is a fast and lightweight markov engine intended to replace -L. It has a lightweight L-based core with -pluggable L, -L and L -backends. +L. It has a lightweight L-based core +with pluggable L and +L backends. -It's faster than MegaHAL and can handle huge brains easily with the -default L. It can be used, -amongst other things, to implement IRC chat bots with -L. In fact, there exists a L -L for just that purpose. +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 asynchronous applications, you can use the +L wrapper. One example is +L, +which implements and IRC chat bot. =head2 Etymology @@ -518,15 +523,15 @@ The storage backend to use. Default: 'SQLite'. This gives you an idea of approximately how the backends compare in speed: - s/iter CHI::File CHI::BerkeleyDB PostgreSQL MySQL CHI::Memory SQLite Perl Perl::Flat - CHI::File 15.1 -- -51% -72% -75% -82% -91% -95% -95% - CHI::BerkeleyDB 7.43 103% -- -42% -49% -64% -81% -90% -91% - PostgreSQL 4.30 252% 73% -- -11% -37% -67% -83% -84% - MySQL 3.83 295% 94% 12% -- -29% -63% -81% -82% - CHI::Memory 2.70 460% 176% 59% 42% -- -48% -73% -75% - SQLite 1.41 972% 427% 205% 171% 91% -- -48% -52% - Perl 0.735 1957% 911% 485% 420% 267% 92% -- -7% - Perl::Flat 0.683 2114% 988% 529% 460% 295% 106% 8% -- + s/iter CHI::File CHI::BerkeleyDB PostgreSQL MySQL CHI::Memory SQLite Perl Perl::Flat + CHI::File 15.1 -- -51% -72% -75% -82% -91% -95% -95% + CHI::BerkeleyDB 7.43 103% -- -42% -49% -64% -81% -90% -91% + PostgreSQL 4.30 252% 73% -- -11% -37% -67% -83% -84% + MySQL 3.83 295% 94% 12% -- -29% -63% -81% -82% + CHI::Memory 2.70 460% 176% 59% 42% -- -48% -73% -75% + SQLite 1.41 972% 427% 205% 171% 91% -- -48% -52% + Perl 0.735 1957% 911% 485% 420% 267% 92% -- -7% + Perl::Flat 0.683 2114% 988% 529% 460% 295% 106% 8% -- To run your own test try running F in the Hailo distribution. @@ -535,11 +540,7 @@ distribution. The tokenizer to use. Default: 'Words'; -=head2 C - -The engine to use. Default: 'Default'; - -=head2 C +=head2 C The UI to use. Default: 'ReadLine'; @@ -547,8 +548,6 @@ The UI to use. Default: 'ReadLine'; =head2 C -=head2 C - =head2 C A C of arguments storage/tokenizer/engine/ui backends. See @@ -565,7 +564,7 @@ this is C<"\t">. =head2 C -This is the constructor. It accept the attributes specified in +This is the constructor. It accepts the attributes specified in L. =head2 C @@ -578,18 +577,17 @@ Takes a line of UTF-8 encoded text as input and learns from it. =head2 C -Takes a filename and calls L|/learn> on all its lines. Lines are -expected to be UTF-8 encoded. +Takes a filename and calls L|/learn> on all its lines. The file is +assumed to be UTF-8 encoded. =head2 C -Takes a line of text and generates a reply (UTF-8 encoded) that might be -relevant. +Takes an optional line of text and generates a reply that might be relevant. =head2 C -Takes a line of text, learns from it, and generates a reply (UTF-8 encoded) -that might be relevant. +Takes a line of text, learns from it, and generates a reply that might be +relevant. =head2 C diff --git a/lib/Hailo/Role/Storage.pm b/lib/Hailo/Role/Storage.pm index d4a42d4..91bb3f1 100644 --- a/lib/Hailo/Role/Storage.pm +++ b/lib/Hailo/Role/Storage.pm @@ -76,14 +76,8 @@ Learns from a sequence of tokens. Takes an array ref of strings. =head2 C -Takes a single token as an argument and returns a randomly picked expression -which contains it. - -=head2 C - Takes an array reference of tokens and returns a reply (arrayref of tokens) -that might be relevant. If none of the supplied tokens are known, nothing is -returned. +that might be relevant. =head2 C diff --git a/lib/Hailo/Storage/CHI/BerkeleyDB.pm b/lib/Hailo/Storage/CHI/BerkeleyDB.pm index 7bd40a3..0007533 100644 --- a/lib/Hailo/Storage/CHI/BerkeleyDB.pm +++ b/lib/Hailo/Storage/CHI/BerkeleyDB.pm @@ -22,7 +22,8 @@ __PACKAGE__->meta->make_immutable; =head1 NAME -Hailo::Storage::CHI::BerkeleyDB - A L storage backend for L using L +Hailo::Storage::CHI::BerkeleyDB - A L +storage backend for L using L =head1 AUTHOR @@ -36,4 +37,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - diff --git a/lib/Hailo/Storage/CHI/File.pm b/lib/Hailo/Storage/CHI/File.pm index 703f091..c9ecf7e 100644 --- a/lib/Hailo/Storage/CHI/File.pm +++ b/lib/Hailo/Storage/CHI/File.pm @@ -24,7 +24,8 @@ __PACKAGE__->meta->make_immutable; =head1 NAME -Hailo::Storage::CHI::File - A L storage backend for L using L +Hailo::Storage::CHI::File - A L storage backend +for L using L =head1 AUTHOR @@ -38,4 +39,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - diff --git a/lib/Hailo/Storage/CHI/Memory.pm b/lib/Hailo/Storage/CHI/Memory.pm index 08f17c9..59e52f6 100644 --- a/lib/Hailo/Storage/CHI/Memory.pm +++ b/lib/Hailo/Storage/CHI/Memory.pm @@ -22,7 +22,8 @@ __PACKAGE__->meta->make_immutable; =head1 NAME -Hailo::Storage::CHI::Memory - A L storage backend for L using L +Hailo::Storage::CHI::Memory - A L storage +backend for L using L =head1 AUTHOR @@ -36,4 +37,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - diff --git a/lib/Hailo/Storage/DBD/SQLite.pm b/lib/Hailo/Storage/DBD/SQLite.pm index dbfcd46..59f94e9 100644 --- a/lib/Hailo/Storage/DBD/SQLite.pm +++ b/lib/Hailo/Storage/DBD/SQLite.pm @@ -52,22 +52,24 @@ L =head1 DESCRIPTION -This backend maintains information in an SQLite database. It can handle -pretty large datasets. +This backend maintains information in an SQLite database. It is the default +storage backend. -For some example numbers, I have a 5th-order database built from a 204k line -(7.2MB) IRC channel log file (7.2MB). On my laptop (Core 2 Duo 2.53 GHz) it -took 10 minutes and 42 seconds (317 lines/sec) to create the 290MB database. -Furthermore, it can generate 166 replies per second from it. Since this is -just an SQL database, there is very little RAM usage. +For some example numbers, I have a 5th-order database built from a ~210k line +(7.4MB) IRC channel log file. On my laptop (Core 2 Duo 2.53 GHz) it took 8 +minutes and 50 seconds (~400 lines/sec) to create the 229MB database. +Furthermore, it can generate about 90 replies per second from it. =head1 AUTHOR Evar ArnfjErE Bjarmason +Hinrik Ern SigurEsson, hinrik.sig@gmail.com + =head1 LICENSE AND COPYRIGHT -Copyright 2010 Evar ArnfjErE Bjarmason. +Copyright 2010 Evar ArnfjErE Bjarmason and +Hinrik Ern SigurEsson This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Hailo/Storage/Mixin/CHI.pm b/lib/Hailo/Storage/Mixin/CHI.pm index ac47410..20c3cf3 100644 --- a/lib/Hailo/Storage/Mixin/CHI.pm +++ b/lib/Hailo/Storage/Mixin/CHI.pm @@ -113,7 +113,8 @@ __PACKAGE__->meta->make_immutable; =head1 NAME -Hailo::Storage::Mixin::CHI - A mixin class for L L backends using L +Hailo::Storage::Mixin::CHI - A mixin class for L +L backends using L =head1 AUTHOR @@ -127,4 +128,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - diff --git a/lib/Hailo/Storage/Mixin/Hash.pm b/lib/Hailo/Storage/Mixin/Hash.pm index 1c2845e..733071f 100644 --- a/lib/Hailo/Storage/Mixin/Hash.pm +++ b/lib/Hailo/Storage/Mixin/Hash.pm @@ -195,7 +195,8 @@ __PACKAGE__->meta->make_immutable; =head1 NAME -Hailo::Storage::Mixin::Hash - A mixin class for L classes using a C +Hailo::Storage::Mixin::Hash - A mixin class for +L classes using a C =head1 DESCRIPTION diff --git a/lib/Hailo/Storage/Mixin/Hash/Flat.pm b/lib/Hailo/Storage/Mixin/Hash/Flat.pm index fb9d151..a22d600 100644 --- a/lib/Hailo/Storage/Mixin/Hash/Flat.pm +++ b/lib/Hailo/Storage/Mixin/Hash/Flat.pm @@ -158,7 +158,8 @@ __PACKAGE__->meta->make_immutable; =head1 NAME -Hailo::Storage::Mixin::Hash::Flat - A mixin class for L classes using a flat C +Hailo::Storage::Mixin::Hash::Flat - A mixin class for +L classes using a flat C =head1 DESCRIPTION @@ -178,4 +179,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - diff --git a/lib/Hailo/Storage/Mixin/Storable.pm b/lib/Hailo/Storage/Mixin/Storable.pm index 049ff8e..822c6de 100644 --- a/lib/Hailo/Storage/Mixin/Storable.pm +++ b/lib/Hailo/Storage/Mixin/Storable.pm @@ -37,7 +37,8 @@ __PACKAGE__->meta->make_immutable; =head1 NAME -Hailo::Storage::Mixin::Storable - A mixin class for L providing L storage +Hailo::Storage::Mixin::Storable - A mixin class for +L providing L storage =head1 DESCRIPTION @@ -55,4 +56,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - diff --git a/lib/Hailo/Storage/Perl.pm b/lib/Hailo/Storage/Perl.pm index ca3f8c4..f7abe65 100644 --- a/lib/Hailo/Storage/Perl.pm +++ b/lib/Hailo/Storage/Perl.pm @@ -41,4 +41,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - diff --git a/lib/Hailo/Storage/Perl/Flat.pm b/lib/Hailo/Storage/Perl/Flat.pm index 4e57d28..580140e 100644 --- a/lib/Hailo/Storage/Perl/Flat.pm +++ b/lib/Hailo/Storage/Perl/Flat.pm @@ -39,4 +39,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - diff --git a/lib/Hailo/UI/ReadLine.pm b/lib/Hailo/UI/ReadLine.pm index 087adf3..9bda45f 100644 --- a/lib/Hailo/UI/ReadLine.pm +++ b/lib/Hailo/UI/ReadLine.pm @@ -58,12 +58,6 @@ command-line with only a C<--brain> argument: Presents a ReadLine interface using L, the L frontend will be used. -=head1 METHODS - -=head2 C - -Run the UI. - =head1 AUTHOR Evar ArnfjErE Bjarmason