From 8aeceff885261b662ab373483e1669fcfbc42a21 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 21 Feb 2009 18:01:30 +0100 Subject: markov: learn vs learn_line Make learn a higher-level function that queues one or more lines, and make learn_line the low-level database access method. --- data/rbot/plugins/markov.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb index dd66ae1d..62559658 100644 --- a/data/rbot/plugins/markov.rb +++ b/data/rbot/plugins/markov.rb @@ -44,7 +44,7 @@ class MarkovPlugin < Plugin @learning_queue = Queue.new @learning_thread = Thread.new do while s = @learning_queue.pop - learn s + learn_line s sleep 0.5 end end @@ -222,6 +222,10 @@ class MarkovPlugin < Plugin end end + def learn(*lines) + lines.each { |l| @learning_queue.push l } + end + def message(m) return if ignore? m @@ -232,11 +236,11 @@ class MarkovPlugin < Plugin message = "#{m.sourcenick} #{message}" end - @learning_queue.push message + learn message random_markov(m, message) unless m.replied? end - def learn(message) + def learn_line(message) # debug "learning #{message}" wordlist = message.split(/\s+/) return unless wordlist.length >= 2 -- cgit v1.2.3