Acme-Wabby

 view release on metacpan or  search on metacpan

Wabby.pm  view on Meta::CPAN

There are several error conditions which can occur in the B<spew()> method.
None of them are fatal, but they must be taken into account by the calling
program.  They are:

* At least (min_len * 10) words haven't been run through yet. (Must B<add()>
more text before trying again.)

* A string was passed in containing nothing. (Don't do that.)

* We don't know the last word in the string passed in, and can therefore not
generate a sentence with it. (Either teach us about it with B<add()>, or try
something else.)

* A sentence of at least min_len words could not be generated, even after
max_attempts tries at doing so. (Likely need to B<add()> more text before
trying again.)

=head2 Saving / loading state

Acme::Wabby can save and load state to disk using the Storable module.  To do
this, simply use the B<save()> and/or B<load()> methods.

  $wabby->save;
  $wabby->load;

These methods take no arguments, they simply save or load the state to or from
the file names which were defined when the object was created.  Loading a
saved state is much faster than re-parsing a large body of text.

=head2 Getting statistics

Using the B<stat()> method will provide you with some simple statistics about
the current state of an object.  When used in a scalar context, the B<stat()>
method will return a string containing a description of what the object knows.
When used in a list context, it will return a list of two numbers.  The first
entry in the list is the number of words that the object knows.  The second
entry in the list is the average number of connections between words.

  my ($wordcount, $average) = $wabby->stats;
  print "count=$wordcount, average=$average\n";
  print scalar($wabby->stats), "\n";

=head1 BUGS

 * Uses a lot of memory (not so much a bug as an implementation quirk).

=head1 TODO

 * Be better about normalizing input text.
 * Fix english assumtions about single-letter words besides I and a.
 * See about making the parsing into phrases and words more configurable.
 * Investigate using longer-order chains to improve generation quality.
 * Try to use less memory!

=head1 AUTHOR

Nathan Poznick <kraken@wang-fu.org>

=head1 CREDITS

 nick@misanthropia.nu - for writing the original wabbylegs.pl
 Project Gutenberg - for providing free text to feed to Acme::Wabby.

=head1 COPYRIGHT

Copyright (c) 2004, Nathan Poznick.  All rights reserved.  This program is free
software; you can redistribute it and/or modify it under the terms of the GPL
version 2.

=cut



( run in 1.185 second using v1.01-cache-2.11-cpan-5735350b133 )