First Wave Robot

I took advantage of the fact that some wave developers were passing by our office and wrote a wave robot during a jam session. This robot monitors what is being typed and makes it easy to convert to different units. If you type "100kg (? lbs)" it will replace the ? with the correct value of 220 after you type the closing parenthesis, for example.

I went a bit further and tried to be sensible with the significant figures. I didn't want it say '220.462262 lbs. So I examine the number of significant figures from the original number and try to duplicate it in the result. If you say "100 kg" it'll put "220 lbs". If instead you enter "100.0 kg" it'll put "220.5 lbs".

Test revealed, however, that this wasn't good enough. If I put in "1 inch" in would convert this to "3cm", a 18% error. I put in an extra rule to increase the precision if the error was greater than 10%, which got these corner cases.

What's interesting is that it took more time to write the conversion routines than it did to hook it up with wave. If you use Google App engine in Python or Java it's dead easy.

Google Wave is really a new way to communicate and collaborate, even without robots and gadgets. With robots it goes to a whole new level. You really should take a look at the wave api documentation.

The code for my converter is available here and the robot is called convertsy@appspot.com.

Comments

Popular posts from this blog

Shortest Sudoku solver in Python

Downloading projecteuler.net