June R. Tate-Gans > StupidMarkov > StupidMarkov

Download:
StupidMarkov-0.002.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.002   Source  

NAME ^

StupidMarkov - A stupid Markov chain implementation.

SYNOPSIS ^

  use StupidMarkov;

  my $mm = StupidMarkov->new();

  while (my $line = <>) {
      chomp $line;
      next if !defined $line;

      foreach my $word (split(/ /, $line)) {
          $mm->add_item($word);
      }
  }

  print $mm->get_next_item(), " " for (0 .. $mm->get_item_count());

DESCRIPTION ^

BIG FAT NOTE: THIS IS A /REALLY/ STUPID IMPLEMENTATION! It works (for the most part) for me. I didn't write it to be a complete implementation, or even a sane one. If you're looking for something other than a toy, please check the SEE ALSO section for ideas, or search CPAN for something else. =o)

StupidMarkov is a really simply and really stupid implementaiton of a Markov chain that I wrote in a fit of insomnia at midnight, after realizing I'd never understood what a Markov chain was, spending five minutes reading the Wikipedia entry on it, and then taking ten minutes to implement it. The output using the above synopsis and this paragraph results in output like the following:

  "is a fit of insomnia at midnight, after realizing I'd never
  understood what a really stupid implementaiton of insomnia at
  midnight, after realizing I'd never understood what a Markov chain
  that I wrote in a Markov chain that I wrote in a Markov chain that I
  wrote in output like the Wikipedia entry on it, and this paragraph
  results in a Markov chain that I wrote"

METHODS ^

new

Create a new StupidMarkov chain.

get_item_count

Return the number of items that have been added to the chain. Note that this number is cumulative, and does not count uniqueness.

get_probabilities

Return a reference to the internal probability hash of items to hash of next items to integer probabilities. Probably not very useful.

get_state

Return the current item that is used as the internal state.

add_item

Add an item to the Markov chain.

get_next_item

Generate the next item in the Markov chain. Takes an optional argument that represents the start state. If no argument is provided, the first item passed to add_item is used instead.

REFERENCES ^

Wikipedia: http://en.wikipedia.org/Markov_chain

REVISION HISTORY ^

0.002

2009-05-10: Integrating apeiron's camel case is evil patch. Note that this represents an API change.

0.001

2009-05-02: First implementation and insomnia effect.

SEE ALSO ^

Please consider using the below, as they are much better implementations than StupidMarkov could ever hope to be.

Decision::Markov
Algorithm::MarkovChain
Algorithm::MarkovChain::GHash

AUTHOR ^

June R. Tate-Gans <june@theonelab.com>

LICENSE ^

Copyright 2009 June R. Tate-Gans, all rights reserved.

StupidMarkov is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNEESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have recieved a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

BUGS ^

Please report any bugs or feature requests to bug-stupidmarkov at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=StupidMarkov. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc StupidMarkov

You can also look for information at:

syntax highlighting: