]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
math plugin: fix some english-to-math translations
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 13 Mar 2008 21:19:45 +0000 (22:19 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 13 Mar 2008 21:19:45 +0000 (22:19 +0100)
data/rbot/plugins/math.rb

index afa4737cd9eff71bf10292245ea04e67c8a8b132..945b2c78abf915742511249a012f27741ad63f52 100644 (file)
@@ -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*$/ &&