From bf2a5a05b86773da8351ae01d94b0fecd5c4519a Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 22 Mar 2008 09:19:54 +0100 Subject: markov plugin: small optimization for markov chains contructions --- data/rbot/plugins/markov.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'data') diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb index 5bae9bbd..60ecafec 100644 --- a/data/rbot/plugins/markov.rb +++ b/data/rbot/plugins/markov.rb @@ -206,10 +206,12 @@ class MarkovPlugin < Plugin return unless wordlist.length >= 2 word1, word2 = :nonword, :nonword wordlist.each do |word3| - @registry["#{word1} #{word2}"] = @registry["#{word1} #{word2}"].push(word3) + k = "#{word1} #{word2}" + @registry[k] = @registry[k].push(word3) word1, word2 = word2, word3 end - @registry["#{word1} #{word2}"] = @registry["#{word1} #{word2}"].push(:nonword) + k = "#{word1} #{word2}" + @registry[k] = @registry[k].push(:nonword) return if m.replied? random_markov(m, message) -- cgit v1.2.3