diff --git a/load-brain.pl b/load-brain.pl index 25c0ed7..4d86961 100644 --- a/load-brain.pl +++ b/load-brain.pl @@ -7,35 +7,9 @@ use FindBin qw($Bin); use lib $Bin; -use MarkovBot::Config; +use MarkovBot::Learning; -# Load Configuration - -my $redis_prefix = config("redis_prefix"); my $brain_file = $ARGV[0]; - -my $redis = Redis->new(); - open BRAIN, $brain_file or die $!; - -while () { - - # Apply preprocessing to the line - $_ = $_ . "___end___"; - $_ = lc $_; - $_ =~ y/\,\.\!\?\(\)//d; - - # Split it into individual words - my @words = split(' ', $_); - - # Disregard short sentences - next if scalar(@words < 4); - - for (my $i = 0; $i <= $#words-2; $i++) { - # $words[$i] $words[$i+1] => $words[$i+2] - $redis->rpush("$redis_prefix:chains:$words[$i],$words[$i+1]", $words[$i+2]); - } - -} - +learn $_ while ; close BRAIN;