diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-22 09:19:54 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-22 09:19:54 +0100 |
commit | bf2a5a05b86773da8351ae01d94b0fecd5c4519a (patch) | |
tree | d34f9ee366c1d7c68f974810934e499fa9dec47e /data/rbot/plugins/markov.rb | |
parent | ab69d59c03a101de571fece156c96409e5ba5b61 (diff) |
markov plugin: small optimization for markov chains contructions
Diffstat (limited to 'data/rbot/plugins/markov.rb')
-rw-r--r-- | data/rbot/plugins/markov.rb | 6 |
1 files changed, 4 insertions, 2 deletions
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) |