summaryrefslogtreecommitdiff
path: root/data/rbot/plugins
diff options
context:
space:
mode:
authorVoker57 <voker57@gmail.com>2009-12-14 20:13:17 +0300
committerVoker57 <voker57@gmail.com>2010-01-26 00:41:07 +0300
commit7908c0e356c4a7e3c0b252020fcae952ccb4449d (patch)
treeb12d865998d6ed93dc1af14b4cd641d9a34d9b11 /data/rbot/plugins
parentf70fb815499c05b4864d3362dc2793e13083a082 (diff)
markov: ignore word patterns
Diffstat (limited to 'data/rbot/plugins')
-rwxr-xr-xdata/rbot/plugins/markov.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb
index e1886ddc..4b007cc1 100755
--- a/data/rbot/plugins/markov.rb
+++ b/data/rbot/plugins/markov.rb
@@ -39,6 +39,9 @@ class MarkovPlugin < Plugin
:default => 50,
:validate => Proc.new { |v| (0..100).include? v },
:desc => "Probability of answer when addressed by nick")
+ Config.register Config::ArrayValue.new('markov.ignore_patterns',
+ :default => [],
+ :desc => "Ignore these word patterns")
MARKER = :"\r\n"
@@ -633,7 +636,11 @@ class MarkovPlugin < Plugin
def learn_line(message)
# debug "learning #{message.inspect}"
- wordlist = clean_str(message).split(/\s+/).map { |w| w.intern }
+ wordlist = clean_str(message).split(/\s+/).reject do |w|
+ @config['markov.ignore_patterns'].map do |pat|
+ w =~ Regexp.new(pat.to_s)
+ end.filter{|v| v}.size == 0
+ end.map { |w| w.intern }
return unless wordlist.length >= 2
word1, word2 = MARKER, MARKER
wordlist << MARKER