blib/lib/Hailo.pm

filter: Statementstmt 97.4% 155 / 159 Branchbran 85.1% 46 / 54 Conditioncond 100% 12 / 12 MC/DCmcdc 100% 7 / 7 Subroutinesub 96.9% 32 / 33 Podpod 75.0% 6 / 8 totaltotal 94.5% 258 / 273 CC 33 SCAR 14.4
CC
33
Cov
95%
train
11.2
__ANON__
6.0
learn
5.0
CRAP 4.2
« blib/lib/Hailo/Storage/PostgreSQL.pm ↑ Summary blib/lib/Hailo/Storage/SQLite.pm »
1 package Hailo;
2 42 our $AUTHORITY = 'cpan:AVAR';
3 42 $Hailo::VERSION = '0.73';
4 42 ▶use v5.28.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 42 ▶use autodie qw(open close);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 42 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 42 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 42 ▶use File::Glob ':glob';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 42 ▶use Class::Load qw(try_load_class);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 42 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 42 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 42 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 42 use constant PLUGINS => [ qw[
15 Hailo::Engine::Default
16 Hailo::Engine::Scored
17 Hailo::Storage::MySQL
18 Hailo::Storage::PostgreSQL
19 Hailo::Storage::SQLite
20 Hailo::Tokenizer::Chars
21 Hailo::Tokenizer::Words
22 Hailo::UI::ReadLine
23 42 ▶] ];
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 42 has brain => (
26 isa => 'Str',
27 is => 'rw',
28 );
29  
30 has order => (
31 isa => 'Int',
32 is => 'rw',
33 default => 2,
34 trigger => sub {
35 211 ▶ my ($self, $order) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
36 211 $self->_custom_order(1);
37 },
38 42 );
39  
40 42 has _custom_order => (
41 isa => 'Bool',
42 is => 'rw',
43 default => 0,
44 init_arg => undef,
45 documentation => "Here so we can differentiate between the default value of order being explictly set and being set by default",
46 );
47  
48 42 has _custom_tokenizer_class => (
49 isa => 'Bool',
50 is => 'rw',
51 default => 0,
52 init_arg => undef,
53 documentation => "Here so we can differentiate between the default value of tokenizer_class being explictly set and being set by default",
54 );
55  
56 42 has save_on_exit => (
57 isa => 'Bool',
58 is => 'rw',
59 default => 1,
60 );
61  
62 has brain_resource => (
63 documentation => "Alias for `brain' for backwards compatibility",
64 isa => 'Str',
65 is => 'rw',
66 trigger => sub {
67 0 ▶ my ($self, $brain) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 0 $self->brain($brain);
69 },
70 42 );
71  
72 sub BUILD {
73 279 ▶ my ($self) = @_;
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
74 279 my $brain = $self->brain;
75 279 ▶ return if !defined $brain;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $brain 38 241 279
76 241 $self->brain(bsd_glob($brain));
77 241 return;
78 }
79  
80 42 my %has = (
81 engine => {
82 name => 'Engine',
83 default => 'Default',
84 },
85 storage => {
86 name => 'Storage',
87 default => 'SQLite',
88 },
89 tokenizer => {
90 name => 'Tokenizer',
91 default => 'Words',
92 },
93 ui => {
94 name => 'UI',
95 default => 'ReadLine',
96 },
97 );
98  
99 42 for my $k (keys %has) {
100 168 my $name = $has{$k}->{name};
101 168 my $default = $has{$k}->{default};
102 168 my $method_class = "${k}_class";
103 168 my $method_args = "${k}_args";
104  
105 # working classes
106 has "${k}_class" => (
107 isa => 'Str',
108 is => "rw",
109 default => $default,
110 ($k eq 'tokenizer'
111 ? (trigger => sub {
112 5 ▶ my ($self, $class) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
113 5 $self->_custom_tokenizer_class(1);
114 })
115 168 ▶ : ())
Branch: 1 branch
BranchTrueFalseTotal
$k eq 'tokenizer' ? : 42 126 168
116 );
117  
118 # Object arguments
119 has "${k}_args" => (
120 documentation => "Arguments for the $name class",
121 isa => 'HashRef',
122 is => "ro",
123 1102 ▶ default => sub { +{} },
Subroutine __ANON__: called CC=1 SCAR=0.0
124 168 );
125  
126 # Working objects
127 168 has "_${k}" => (
128 does => "Hailo::Role::$name",
129 lazy_build => 1,
130 is => 'ro',
131 init_arg => undef,
132 );
133  
134 # Generate the object itself
135 42 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
136 168 *{"_build__${k}"} = sub {
137 355 ▶ my ($self) = @_;
Subroutine __ANON__: called CC=6 SCAR=17.9
138  
139 my $obj = $self->_new_class(
140 $name,
141 $self->$method_class,
142 {
143 arguments => $self->$method_args,
144 ($k =~ /^(?:engine|storage)$/s
145 ? (order => $self->order)
146 : ()),
147 ($k eq 'engine'
148 ? (storage => $self->_storage)
149 : ()),
150 (($k eq 'storage' and defined $self->brain)
151 ? (
152 355 ▶ hailo => do {
Branch: 3 branches
BranchTrueFalseTotal
$k =~ /^(?:engine|storage)$/su ? : 307 48 355
$k eq 'engine' ? : 46 309 355
$k eq 'storage' && defined $self->brain ? : 240 115 355
Condition100%3/3
$k eq "storage" and defined $self->brain
!ll&&!rl&&r
9421240
MC/DC100%2/2
$k eq "storage" and defined $self->brain
$k eq "storage" defined $self->brain
Truth table100%3/3
A and B
A= $k eq "storage"B= defined $self->brain
ABresult
0X0
100
111
153 240 require Scalar::Util;
154 240 Scalar::Util::weaken(my $s = $self);
155  
156 my %callback = (
157 200 ▶ has_custom_order => sub { $s->_custom_order },
Subroutine __ANON__: called CC=1 SCAR=0.0
158 3 ▶ has_custom_tokenizer_class => sub { $s->_custom_tokenizer_class },
Subroutine __ANON__: called CC=1 SCAR=0.0
159 set_order => sub {
160 1 ▶ my ($db_order) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
161 1 $s->order($db_order);
162 1 $s->_engine->order($db_order);
163 },
164 set_tokenizer_class => sub {
165 1 ▶ my ($db_tokenizer_class) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
166 1 $s->tokenizer_class($db_tokenizer_class);
167 },
168 240 );
169  
170 240 ▶ \%callback;
Branch: 1 branch
BranchTrueFalseTotal
$k eq 'storage' ? : 261 94 355
171 },
172 brain => $self->brain
173 )
174 : ()),
175 ($k eq 'storage'
176 ? (tokenizer_class => $self->tokenizer_class)
177 : ())
178 },
179 );
180  
181 352 return $obj;
182 168 };
183 }
184  
185 sub _new_class {
186 355 ▶ my ($self, $type, $class, $args) = @_;
Subroutine _new_class: called CC=4 SCAR=14.0
187  
188 355 my $pkg;
189 355 ▶ if ($class =~ m[^\+(?<custom_plugin>.+)$]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class =~ /^\+(?<custom_plugin>.+)$/u) { } 0 355 355
190 0 $pkg = $+{custom_plugin};
191 } else {
192 355 my @plugins = @{ $self->PLUGINS };
193 # Be fuzzy about includes, e.g. DBD::SQLite or SQLite or sqlite will go
194 1837 ▶ $pkg = first { / $type : .* : $class /ix }
Subroutine __ANON__: called CC=1 SCAR=0.0
195 355 sort { length $a <=> length $b }
196 @plugins;
197  
198 355 ▶ unless ($pkg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pkg) 3 352 355
199 3 local $" = ', ';
200 3 my @p = grep { /$type/ } @plugins;
201 3 die "Couldn't find a class name matching '$class' in plugins '@p'";
202 }
203 }
204  
205 352 my ($success, $error) = try_load_class($pkg);
206 352 ▶ die $error if !$success;
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 352 352
207  
208 352 return $pkg->new(%$args);
209 }
210  
211 sub save {
212 259 ▶ my ($self, @args) = @_;
Subroutine save: called CC=1 SCAR=0.0
Pod documented
213 259 $self->_storage->save(@args);
214 259 return;
215 }
216  
217 sub train {
218 23 ▶ my ($self, $input, $fast) = @_;
Subroutine train: called CC=11 SCAR=24.1
Pod documented
219  
220 23 $self->_storage->start_training();
221  
222 23 ▶ if (not ref $input and defined $input and $input eq '-') {
Branch: 4 branches
BranchTrueFalseTotal
if (not ref $input and defined $input and $input eq '-') { } 1 22 23
elsif (ref $input eq 'GLOB') { } 1 21 22
elsif (not ref $input) { } 13 8 21
elsif (ref $input eq 'ARRAY') { } 7 1 8
Condition100%6/6
not ref $input and defined $input and $input eq "-"
!ll&&!rl&&r
11111
not ref $input and defined $input
!ll&&!rl&&r
9212
MC/DC100%3/3
not ref $input and defined $input and $input eq "-"
not ref $input defined $input $input eq "-"
Truth table100%4/4
not(A) and B and C
A= not ref $inputB= defined $inputC= $input eq "-"
ABCresult
0XX0
10X0
1100
1111
223 # With STDIN
224 1 ▶ die "You must provide STDIN when training from '-'" if $self->_is_interactive(*STDIN);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_interactive(*STDIN) 1 0 1
225 0 $self->_train_fh(*STDIN, $fast);
226 } elsif (ref $input eq 'GLOB') {
227 # With a filehandle
228 1 $self->_train_fh($input, $fast);
229 } elsif (not ref $input) {
230 # With a file
231 13 open my $fh, '<:encoding(utf8)', $input;
232 11 $self->_train_fh($fh, $fast, $input);
233 } elsif (ref $input eq 'ARRAY') {
234 # With an Array
235 7 for my $line (@$input) {
236 936 $self->_learn_one($line, $fast);
237 936 ▶ $self->_engine->flush_cache if !$fast;
Branch: 1 branch
BranchTrueFalseTotal
unless $fast 936 0 936
238 }
239 7 ▶ $self->_engine->flush_cache if $fast;
Branch: 1 branch
BranchTrueFalseTotal
if $fast 0 7 7
240 } else {
241 # With something naughty
242 1 die "Unknown input: $input";
243 }
244  
245 19 $self->_storage->stop_training();
246  
247 19 return;
248 }
249  
250 sub _train_fh {
251 11 ▶ my ($self, $fh, $fast) = @_;
Subroutine _train_fh: called CC=4 SCAR=14.0
252  
253 11 ▶ while (my $line = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 988 11 999
254 988 chomp $line;
255 988 $self->_learn_one($line, $fast);
256 988 ▶ $self->_engine->flush_cache if !$fast;
Branch: 1 branch
BranchTrueFalseTotal
unless $fast 988 0 988
257 }
258 11 ▶ $self->_engine->flush_cache if $fast;
Branch: 1 branch
BranchTrueFalseTotal
if $fast 0 11 11
259  
260 11 return;
261 }
262  
263 sub learn {
264 1641 ▶ my ($self, $input) = @_;
Subroutine learn: called CC=5 SCAR=16.1
Pod documented
265 1641 my $inputs;
266  
267 1641 ▶ if (not defined $input) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $input) { } 3 1638 1641
elsif (not ref $input) { } 1614 24 1638
elsif (ref $input eq 'ARRAY') { } 22 2 24
268 3 die "Cannot learn from undef input";
269 } elsif (not ref $input) {
270 1614 $inputs = [$input];
271 } elsif (ref $input eq 'ARRAY') {
272 22 $inputs = $input; # With an Array
273 } else {
274 2 die "Unknown input: $input";
275 }
276  
277 1636 my $storage = $self->_storage;
278  
279 1635 $storage->start_learning();
280 1635 $self->_learn_one($_) for @$inputs;
281 1634 $storage->stop_learning();
282 1634 return;
283 }
284  
285 sub _learn_one {
286 3620 ▶ my ($self, $input, $fast) = @_;
Subroutine _learn_one: called CC=2 SCAR=7.0
287 3620 my $engine = $self->_engine;
288  
289 3620 my $tokens = $self->_tokenizer->make_tokens($input);
290 3619 ▶ $fast ? $engine->learn_cached($tokens) : $engine->learn($tokens);
Branch: 1 branch
BranchTrueFalseTotal
$fast ? : 0 3619 3619
291  
292 3619 return;
293 }
294  
295 sub learn_reply {
296 9 ▶ my ($self, $input) = @_;
Subroutine learn_reply: called CC=1 SCAR=0.0
Pod documented
297 9 $self->learn($input);
298 6 return $self->reply($input);
299 }
300  
301 sub reply {
302 1419 ▶ my ($self, $input) = @_;
Subroutine reply: called CC=4 SCAR=13.9
Pod documented
303  
304 1419 my $storage = $self->_storage;
305 # start_training() hasn't been called so we can't guarentee that
306 # the storage has been engaged at this point. This must be called
307 # before ->_engine() is called anywhere to ensure that the
308 # lazy-loading in the engine works.
309 1419 ▶ $storage->_engage() unless $storage->_engaged;
Branch: 1 branch
BranchTrueFalseTotal
unless $storage->_engaged 211 1208 1419
310  
311 1218 my $engine = $self->_engine;
312 1218 my $tokenizer = $self->_tokenizer;
313  
314 1218 my $reply;
315 1218 ▶ if (defined $input) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $input) { } 1210 8 1218
316 1210 my $tokens = $tokenizer->make_tokens($input);
317 1210 $reply = $engine->reply($tokens);
318 }
319 else {
320 8 $reply = $engine->reply();
321 }
322  
323 1218 ▶ return unless defined $reply;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reply 4 1214 1218
324 1214 return $tokenizer->make_output($reply);
325 }
326  
327 sub stats {
328 34 ▶ my ($self) = @_;
Subroutine stats: called CC=1 SCAR=0.0
Pod documented
329  
330 34 return $self->_storage->totals();
331 }
332  
333 sub DEMOLISH {
334 281 ▶ my ($self) = @_;
Subroutine DEMOLISH: called CC=3 SCAR=11.0
Pod undocumented
335 281 ▶ $self->save() if blessed $self->{_storage} and $self->save_on_exit;
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($self->{"_storage"}) and $self->save_on_exit 259 22 281
Condition100%3/3
builtin::blessed($self->{"_storage"}) and $self->save_on_exit
!ll&&!rl&&r
211259
MC/DC100%2/2
builtin::blessed($self->{"_storage"}) and $self->save_on_exit
builtin::blessed($self->{"_storage"}) $self->save_on_exit
Truth table100%3/3
A and B
A= builtin::blessed($self->{"_storage"})B= $self->save_on_exit
ABresult
0X0
100
111
336 281 return;
337 }
338  
339 sub _is_interactive {
340 26 ▶ require IO::Interactive;
Subroutine _is_interactive: called CC=1 SCAR=0.0
341 26 return IO::Interactive::is_interactive();
342 }
343  
344 42 __PACKAGE__->meta->make_immutable;
345  
346 =encoding utf8
347  
348 =head1 NAME
349  
350 Hailo - A pluggable Markov engine analogous to MegaHAL
351  
352 =head1 SYNOPSIS
353  
354 This is the synopsis for using Hailo as a module. See L<hailo> for
355 command-line invocation.
356  
357 # Hailo requires Perl 5.10
358 use v5.28.0;
359 use Moose;
360 use Hailo;
361  
362 # Construct a new in-memory Hailo using the SQLite backend. See
363 # backend documentation for other options.
364 my $hailo = Hailo->new;
365  
366 # Various ways to learn
367 my @train_this = ("I like big butts", "and I can not lie");
368 $hailo->learn(\@train_this);
369 $hailo->learn($_) for @train_this;
370  
371 # Heavy-duty training interface. Backends may drop some safety
372 # features like journals or synchronous IO to train faster using
373 # this mode.
374 $hailo->train("megahal.trn");
375 $hailo->train($filehandle);
376  
377 # Make the brain babble
378 say $hailo->reply("hello good sir.");
379 # Just say something at random
380 say $hailo->reply();
381  
382 =head1 DESCRIPTION
383  
384 Hailo is a fast and lightweight markov engine intended to replace
385 L<AI::MegaHAL|AI::MegaHAL>. It has a L<Mouse|Mouse> (or
386 L<Moose|Moose>) based core with pluggable
387 L<storage|Hailo::Role::Storage>, L<tokenizer|Hailo::Role::Tokenizer>
388 and L<engine|Hailo::Role::Engine> backends.
389  
390 It is similar to MegaHAL in functionality, the main differences (with the
391 default backends) being better scalability, drastically less memory usage,
392 an improved tokenizer, and tidier output.
393  
394 With this distribution, you can create, modify, and query Hailo brains. To
395 use Hailo in event-driven POE applications, you can use the
396 L<POE::Component::Hailo|POE::Component::Hailo> wrapper. One example is
397 L<POE::Component::IRC::Plugin::Hailo|POE::Component::IRC::Plugin::Hailo>,
398 which implements an IRC chat bot.
399  
400 =head2 Etymology
401  
402 I<Hailo> is a portmanteau of I<HAL> (as in MegaHAL) and
403 L<failo|http://identi.ca/failo>.
404  
405 =head1 Backends
406  
407 Hailo supports pluggable L<storage|Hailo::Role::Storage> and
408 L<tokenizer|Hailo::Role::Tokenizer> backends, it also supports a
409 pluggable L<UI|Hailo::Role::UI> backend which is used by the L<hailo>
410 command-line utility.
411  
412 =head2 Storage
413  
414 Hailo can currently store its data in either a
415 L<SQLite|Hailo::Storage::SQLite>,
416 L<PostgreSQL|Hailo::Storage::PostgreSQL> or
417 L<MySQL|Hailo::Storage::MySQL> database. Some NoSQL backends were
418 supported in earlier versions, but they were removed as they had no
419 redeeming quality.
420  
421 SQLite is the primary target for Hailo. It's much faster and uses less
422 resources than the other two. It's highly recommended that you use it.
423  
424 See L<Hailo::Storage/"Comparison of backends"> for benchmarks showing
425 how the various backends compare under different workloads, and how
426 you can create your own.
427  
428 =head2 Tokenizer
429  
430 By default Hailo will use L<the word
431 tokenizer|Hailo::Tokenizer::Words> to split up input by whitespace,
432 taking into account things like quotes, sentence terminators and more.
433  
434 There's also a L<the character
435 tokenizer|Hailo::Tokenizer::Chars>. It's not generally useful for a
436 conversation bot but can be used to e.g. generate new words given a
437 list of existing words.
438  
439 =head1 UPGRADING
440  
441 Hailo makes no promises about brains generated with earlier versions
442 being compatable with future version and due to the way Hailo works
443 there's no practical way to make that promise. Learning in Hailo is
444 lossy so an accurate conversion is impossible.
445  
446 If you're maintaining a Hailo brain that you want to keep using you
447 should save the input you trained it on and re-train when you upgrade.
448  
449 Hailo is always going to lose information present in the input you
450 give it. How input tokens get split up and saved to the storage
451 backend depends on the version of the tokenizer being used and how
452 that input gets saved to the database.
453  
454 For instance if an earlier version of Hailo tokenized C<"foo+bar">
455 simply as C<"foo+bar"> but a later version split that up into
456 C<"foo", "+", "bar">, then an input of C<"foo+bar are my favorite
457 metasyntactic variables"> wouldn't take into account the existing
458 C<"foo+bar"> string in the database.
459  
460 Tokenizer changes like this would cause the brains to accumulate
461 garbage and would leave other parts in a state they wouldn't otherwise
462 have gotten into.
463  
464 There have been more drastic changes to the database format itself in
465 the past.
466  
467 Having said all that the database format and the tokenizer are
468 relatively stable. At the time of writing 0.33 is the latest release
469 and it's compatable with brains down to at least 0.17. If you're
470 upgrading and there isn't a big notice about the storage format being
471 incompatable in the F<Changes> file your old brains will probably work
472 just fine.
473  
474 =head1 ATTRIBUTES
475  
476 =head2 C<brain>
477  
478 The name of the brain (file name, database name) to use as storage.
479 There is no default. Whether this gets used at all depends on the
480 storage backend, currently only SQLite uses it.
481  
482 =head2 C<save_on_exit>
483  
484 A boolean value indicating whether Hailo should save its state before
485 its object gets destroyed. This defaults to true and will simply call
486 L<save|/save> at C<DEMOLISH> time.
487  
488 See L<Hailo::Storage::SQLite/"in_memory"> for how the SQLite backend
489 uses this option.
490  
491 =head2 C<order>
492  
493 The Markov order (chain length) you want to use for an empty brain.
494 The default is 2.
495  
496 =head2 C<engine_class>
497  
498 =head2 C<storage_class>
499  
500 =head2 C<tokenizer_class>
501  
502 =head2 C<ui_class>
503  
504 A a short name name of the class we use for the engine, storage,
505 tokenizer or ui backends.
506  
507 By default this is B<Default> for the engine, B<SQLite> for storage,
508 B<Words> for the tokenizer and B<ReadLine> for the UI. The UI backend
509 is only used by the L<hailo> command-line interface.
510  
511 You can only specify the short name of one of the packages Hailo
512 itself ships with. If you need another class then just prefix the
513 package with a plus (Catalyst style), e.g. C<+My::Foreign::Tokenizer>.
514  
515 =head2 C<engine_args>
516  
517 =head2 C<storage_args>
518  
519 =head2 C<tokenizer_args>
520  
521 =head2 C<ui_args>
522  
523 A C<HashRef> of arguments for engine/storage/tokenizer/ui
524 backends. See the documentation for the backends for what sort of
525 arguments they accept.
526  
527 =head1 METHODS
528  
529 =head2 C<new>
530  
531 This is the constructor. It accepts the attributes specified in
532 L</ATTRIBUTES>.
533  
534 =head2 C<learn>
535  
536 Takes a string or an array reference of strings and learns from them.
537  
538 =head2 C<train>
539  
540 Takes a filename, filehandle or array reference and learns from all its
541 lines. If a filename is passed, the file is assumed to be UTF-8 encoded.
542 Unlike L<C<learn>|/learn>, this method sacrifices some safety (disables
543 the database journal, fsyncs, etc) for speed while learning.
544  
545 You can prove a second parameter which, if true, will use aggressive
546 caching while training, which will speed things up considerably for large
547 inputs, but will take up quite a bit of memory.
548  
549 =head2 C<reply>
550  
551 Takes an optional line of text and generates a reply that might be relevant.
552  
553 =head2 C<learn_reply>
554  
555 Takes a string argument, learns from it, and generates a reply that
556 might be relevant. This is equivalent to calling L<learn|/learn>
557 followed by L<reply|/reply>.
558  
559 =head2 C<save>
560  
561 Tells the underlying storage backend to L<save its
562 state|Hailo::Role::Storage/"save">, any arguments to this method will
563 be passed as-is to the backend.
564  
565 =head2 C<stats>
566  
567 Takes no arguments. Returns the number of tokens, expressions, previous
568 token links and next token links.
569  
570 =head1 SUPPORT
571  
572 You can join the IRC channel I<#hailo> on FreeNode if you have questions.
573  
574 =head1 BUGS
575  
576 Bugs, feature requests and other issues are tracked in L<Hailo's RT on
577 rt.cpan.org|https://rt.cpan.org/Dist/Display.html?Name=Hailo>
578  
579 =head1 SEE ALSO
580  
581 =over
582  
583 =item * L<POE::Component::Hailo> - A non-blocking POE wrapper around Hailo
584  
585 =item * L<POE::Component::IRC::Plugin::Hailo> - A Hailo IRC bot plugin
586  
587 =item * L<http://github.com/hinrik/failo> - Failo, an IRC bot that uses Hailo
588  
589 =item * L<http://github.com/bingos/gumbybrain> - GumbyBRAIN, a more famous IRC bot that uses Hailo
590  
591 =item * L<Hailo::UI::Web> - A L<Catalyst> and jQuery powered web
592 interface to Hailo available at L<hailo.nix.is|http://hailo.nix.is>
593 and as L<hailo-ui-web|http://github.com/avar/hailo-ui-web> on
594 L<GitHub|http://github.com>
595  
596 =item * L<tweetmix|http://www.tweetmix.me/>, a random tweet generator powered by Hailo
597  
598 =item * L<http://github.com/pteichman/cobe> - cobe, a Python port of MegaHAL "inspired by the success of Hailo"
599  
600 =back
601  
602 =head1 LINKS
603  
604 =over
605  
606 =item * L<hailo.org|http://hailo.org> - Hailo's website
607  
608 =item * L<http://bit.ly/hailo_rewrite_of_megahal> - Hailo: A Perl rewrite of
609 MegaHAL, A blog posting about the motivation behind Hailo
610  
611 =item * L<http://blogs.perl.org/users/aevar_arnfjor_bjarmason/hailo/> -
612 More blog posts about Hailo on E<AElig>var ArnfjE<ouml>rE<eth>
613 Bjarmason's L<blogs.perl.org|http://blogs.perl.org> blog
614  
615 =item * Hailo on L<freshmeat|http://freshmeat.net/projects/hailo> and
616 L<ohloh|https://www.ohloh.net/p/hailo>
617  
618 =back
619  
620 =head1 AUTHORS
621  
622 Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com
623  
624 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
625  
626 =head1 LICENSE AND COPYRIGHT
627  
628 Copyright 2010 Hinrik E<Ouml>rn SigurE<eth>sson and
629 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
630  
631 This program is free software, you can redistribute it and/or modify
632 it under the same terms as Perl itself.
633  
634 =cut
« blib/lib/Hailo/Storage/PostgreSQL.pm ↑ Summary blib/lib/Hailo/Storage/SQLite.pm »