Skip Menu |

This queue is for tickets about the StupidMarkov CPAN distribution.

Report information
The Basics
Id: 45927
Status: resolved
Worked: 5 min
Priority: 0/
Queue: StupidMarkov

People
Owner: JTGANS [...] cpan.org
Requestors: apeiron [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.001
Fixed in: (no value)



Subject: Camel_Case_Is_Evil!
This patch fixes the presence of evil camelcase in Stupidmarkov. Should work, but not tested too extensively (see also: better tests!)
Subject: camel_case_is_evil.diff
diff --git a/bin/stupidmarkov-dissociator.pl b/bin/stupidmarkov-dissociator.pl index e837834..3f2f7a2 100755 --- a/bin/stupidmarkov-dissociator.pl +++ b/bin/stupidmarkov-dissociator.pl @@ -12,9 +12,9 @@ while (my $line = <>) { next if (!defined($line)); foreach my $word (split(/ /, $line)) { - $mm->addItem($word); + $mm->add_item($word); } } -print $mm->getNextItem(), " " for (0 .. $mm->getItemCount()); +print $mm->get_next_item(), " " for (0 .. $mm->get_item_count()); diff --git a/lib/StupidMarkov.pm b/lib/StupidMarkov.pm index 70117af..2bdcf24 100644 --- a/lib/StupidMarkov.pm +++ b/lib/StupidMarkov.pm @@ -19,25 +19,25 @@ sub new { "_state" => undef, }; - return bless($self, $class); + bless $self, $class ; } -sub getItemCount { +sub get_item_count { my $self = shift; return $self->{"_item_count"}; } -sub getProbabilities { +sub get_probabilities { my $self = shift; return $self->{"_probabilities"}; } -sub getState { +sub get_state { my $self = shift; return $self->{"_state"}; } -sub addItem { +sub add_item { my $self = shift; my $item = shift; my $prev_item = $self->{"_prev_item"}; @@ -57,7 +57,7 @@ sub addItem { $self->{"_item_count"}++; } -sub _getProbableNextItem { +sub _get_probable_next_item { my $self = shift; my $state = $self->{"_state"}; my $probabilities = $self->{"_probabilities"}; @@ -72,7 +72,7 @@ sub _getProbableNextItem { return $items->[int(rand(@{$items}))]; } -sub getNextItem { +sub get_next_item { my $self = shift; my $ext_state = shift; my $probabilities = $self->{"_probabilities"}; @@ -84,7 +84,7 @@ sub getNextItem { $self->{"_state"} = $self->{"_first_item"}; } - $self->{"_state"} = $self->_getProbableNextItem(); + $self->{"_state"} = $self->_get_probable_next_item(); return $self->{"_state"}; } @@ -108,11 +108,11 @@ StupidMarkov - A stupid Markov chain implementation. next if !defined $line; foreach my $word (split(/ /, $line)) { - $mm->addItem($word); + $mm->add_item($word); } } - print $mm->getNextItem(), " " for (0 .. $mm->getItemCount()); + print $mm->get_next_item(), " " for (0 .. $mm->get_item_count()); =head1 DESCRIPTION @@ -144,30 +144,30 @@ paragraph results in output like the following: Create a new StupidMarkov chain. -=item getItemCount +=item 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. -=item getProbabilities +=item get_probabilities Return a reference to the internal probability hash of items to hash of next items to integer probabilities. Probably not very useful. -=item getState +=item get_state Return the current item that is used as the internal state. -=item addItem +=item add_item Add an item to the Markov chain. -=item getNextItem +=item 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 addItem is used instead. +item passed to add_item is used instead. =back
Integrated the patch and uploaded to CPAN.