diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-02-21 18:01:30 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-02-22 01:58:05 +0100 |
commit | 8aeceff885261b662ab373483e1669fcfbc42a21 (patch) | |
tree | 2471187ce921776cd159413f4d6527f281674c3a /data | |
parent | b9a51549e71790fcb801828b19d7de925ff94fad (diff) |
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.
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/markov.rb | 10 |
1 files 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 |