From: Giuseppe Bilotta Date: Thu, 13 Mar 2008 21:19:45 +0000 (+0100) Subject: math plugin: fix some english-to-math translations X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=38212f89578111324c096d9bab55f2225a1d4d76;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git math plugin: fix some english-to-math translations --- diff --git a/data/rbot/plugins/math.rb b/data/rbot/plugins/math.rb index afa4737c..945b2c78 100644 --- a/data/rbot/plugins/math.rb +++ b/data/rbot/plugins/math.rb @@ -80,19 +80,20 @@ class MathPlugin < Plugin expr.gsub!(/\bover /, "/ ") expr.gsub!(/\bsquared/, "**2 ") expr.gsub!(/\bcubed/, "**3 ") - expr.gsub!(/\bto\s+(\d+)(r?st|nd|rd|th)?( power)?/, "**\1 ") + expr.gsub!(/\bto\s+(\d+)(r?st|nd|rd|th)?( power)?/, '**\1 ') expr.gsub!(/\bpercent of/, "*0.01*") expr.gsub!(/\bpercent/, "*0.01") expr.gsub!(/\% of\b/, "*0.01*") expr.gsub!(/\%/, "*0.01") - expr.gsub!(/\bsquare root of (\d+)/, "\1 ** 0.5 ") - expr.gsub!(/\bcubed? root of (\d+)/, "\1 **(1.0/3.0) ") + expr.gsub!(/\bsquare root of (\d+)/, '\1 ** 0.5 ') + expr.gsub!(/\bcubed? root of (\d+)/, '\1 **(1.0/3.0) ') expr.gsub!(/ of /, " * ") expr.gsub!(/(bit(-| )?)?xor(\'?e?d( with))?/, "^") expr.gsub!(/(bit(-| )?)?or(\'?e?d( with))?/, "|") expr.gsub!(/bit(-| )?and(\'?e?d( with))?/, "& ") expr.gsub!(/(plus|and)/, "+") + debug expr if (expr =~ /^\s*[-\d*+\s()\/^\.\|\&\*\!]+\s*$/ && expr !~ /^\s*\(?\d+\.?\d*\)?\s*$/ && expr !~ /^\s*$/ &&