Scienco.org » Robots
Aug 5

Dear users,

It is with sadness that I have to inform you that Watexy will be discontinued. This is a direct consequence of Google pulling the plug on Google Wave (see e.g. http://digihub.theage.com.au/node/1792).

Watexy (and associated web-service) gets deleted on 31st of August 2010.

I'm very sorry, but hosting the bot is quite expensive, so I don't see much point in making the deficit any bigger when Google Wave is going to close anyway. And I have to remind you that Google Wave has always been a beta, so the risk of this happening has been present all the time.

Deleting Watexy and associated web-service means that all your waves with Latex-images/-equations will be useless; the images will not appear any longer. This means that you either have to print the waves before 31st of August 2010 or use the history functionality to get back to the Latex-codes.

I am very sorry for this but I see no other opion.

Feb 25

I've been working on a robot just like Watexy, but instead of converting Latex to images, it should convert to MathML-fonts. And I'm actually quite far with the robot, so I assume that something will be ready within a couple of days (or maybe a week). Stay tuned!

Oh - and I removed the ads on the site. They was indeed annoying! I hope that you will help the development and server expenses by donating a bit if you can afford it. And thanks to those who already donated - it's much appreciated!

Nov 14

Now version 14 of watexy@appspot.com is released.

$ $x$ $ makes an inline equation (with the $-signs immediately following each other and not with a space as here).

 4 + 5

makes an equation in "display math mode", i.e. centred on its own line. Edit by clicking at the equation (the image).

There are still a few misbehaviours/new feature suggestions:

  • Inline equations still doesn't support < and >
  • It's still not possible to edit the inline equations
  • Have an align environment so that several equations can be shown underneath each other
  • The height of the equation in display math mode doesn't always adjust automatically, so it may be necessary to either click it to edit and the press cancel or view another wave and go back to the original one
  • The history of how an equations is changed (editing by clicking on it) is not recorded, so for know it's not possible to track changes to a single equations. Yet.

I'm of course still working to fix these things, but it might not be solved until January because I'm going to travel the rest of the year.

Thanks a lot for your support and all the feedback. Please continue to comment on how the robot is made, bugs, and suggestions! I'm also on Twitter at http://twitter.com/mikldk.

A last request: If you can afford, please donate money to support my work and expenses. You'll find the donate-button in the upper right corner of this page.

Nov 13
Watexy-test (with edit and working < and >)
icon1 Mikkel Meyer Andersen | icon4 November 13, 2009 at 01:45 (UTC) | icon3 13 Comments »
icon3 , , , ,

I'm a new version of Watexy with the possibility to edit equations and fixes the bug with < and > not working.

The testing-robot is:
watexy-test@appspot.com

It only works in wave.google.com and not in wavesandbox.com for some reason.

I hope you'll take the time to give it a try and some feedback to improve it.

watexy-test

Nov 11

First of all, thanks for the feed-back in [1].

I've now fixed three things:
1) It's now possible to put more than one equation in a blip, and they all get nicely/properly displayed, thanks to Michael, post 18 in [1] for a possible solution
2) Instead of using http://www.forkosh.dreamhost.com/mathtex.cgi , I've now installed the program on one of my own servers (thanks a lot for both the software and the service)
3) Multi-line is supported, such that the equation can be written over multiple lines and still be matched correctly

Please do not hesitate to comment this version as well!

By the way, I'm sorry for the delay with this new version. My life as an exchange student in Australia has been a bit hectic with all the travelling besides the studies.

[1]: http://www.scienco.org/2009/watexy-latex-robot-for-google-wave/

The new code is as follows:

# Python reference:
# http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/index.html
 
# Shortcut to the important OpBasedDocument
# http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/waveapi.ops.OpBasedDocument-class.html
 
__author__ = 'mikl@mikl.dk (Mikkel Meyer Andersen)'
 
import re
 
from waveapi import events
from waveapi import model
from waveapi import robot
from waveapi import document
 
def OnRobotAdded(properties, context):
  """Invoked when the robot has been added."""
  root_wavelet = context.GetRootWavelet()
  root_wavelet.CreateBlip().GetDocument().SetText("Hi. My name is Watexy and I'm here to help you presenting Latex in waves. Just put the latex between  and , e.g. 2+2=5.")
 
def reversed_iterator(iter):
    return reversed(list(iter))
 
def OnBlipSubmitted(properties, context):
  """Invoked when a blip has been added."""
  blip = context.GetBlipById(properties['blipId']) 
  blip_text_view = blip.GetDocument()
 
  matches = re.finditer('\$\$(.+?)\$\$', blip_text_view.GetText(), re.DOTALL)
 
  """
  Reverse list such that the last items will be changed first, such that
  the positions for the first items doesn't change
  """
  matches = reversed_iterator(matches)
 
  for m in matches:
    """
    The +/- 2 is because of the length of the $$'s. 
    If not removed, the loop will run infintely! 
    """
    blip_text_view.DeleteRange(document.Range(m.start(1)-2, m.end(1)+2))
    image = document.Image('http://meyer.fm/cgi-bin/mathtex.cgi?' + m.group(1), caption=m.group(1))
    blip_text_view.InsertElement(m.start(1)-2, image)
 
if __name__ == '__main__':
  myRobot = robot.Robot('watexy',
      image_url='http://watexy.appspot.com/assets/icon.png',
      version='12',
      profile_url='http://watexy.appspot.com/')
  myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded)
  myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted)
  myRobot.Run()
Jul 30
Watexy - Latex robot for Google Wave
icon1 Mikkel Meyer Andersen | icon4 July 30, 2009 at 00:06 (UTC) | icon3 39 Comments »
icon3 , , , ,

I finally got access to a Google Wave sandbox account, making it possible to start experimenting. The first thing I made was a Latex robot. By adding the robot, it's possible to write Latex in Waves. Afterwards, simply by putting Latex between two $'s:

<span style=\lim_{n \to \infty} \frac{1}{n} = 0$$

Watexy then changes the Wave and inserts the Latex as an image instead of the text.

You can try it yourself by adding watexy [this-funny-curly-a] appspot.com to your Wave-conversations. You can download the source here.

There's still a quite big bug: It's only the first Latex-image that gets substituted correctly. The following gets inserted some positions wrong, and the deletion of the text isn't correct neither. But the images itself are correct, only the substitution isn't working properly. But I'm working on that!

The more technical part: the robot is written in Python, hence using the Google Wave Python API. It's the first time I've tried that (thought it was a good possibility to learn it). The robot basically works by getting triggered when a new blip is submitted. Then it searches for Latex-code in that and substitutes it with pictures. Although the code is quite simple, it shows some very basic concepts on how to alter/change the contents of Waves on-the-fly (deleting text and inserting images, but it could be other things as well) with robots. The Latex-source-to-image is done by the http://www.forkosh.dreamhost.com/source_mathtex.html#webservice service.

The core Python comprising the robot is this:

# Python reference:
# http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/index.html
 
# Shortcut to the important OpBasedDocument
# http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/waveapi.ops.OpBasedDocument-class.html
 
""" 
Known bugs:
- From (and including) the second Latex-fragment, the positioning gets wrong
  > Probably the document needs some kind of updatering
  > Even though it's a bit strange since the re matches all the Latex correctly
"""  
 
__author__ = 'mikl@mikl.dk (Mikkel Meyer Andersen)'
 
import re
 
from waveapi import events
from waveapi import model
from waveapi import robot
from waveapi import document
 
def OnRobotAdded(properties, context):
  """Invoked when the robot has been added."""
  root_wavelet = context.GetRootWavelet()
  root_wavelet.CreateBlip().GetDocument().SetText("Hi. My name is Watexy and I'm here to help you presenting Latex in waves. Just put the latex between " /> and , e.g. 2+2=5. This robot uses the http://www.forkosh.dreamhost.com/source_mathtex.html#webservice service.)
 
def OnBlipSubmitted(properties, context):
  """Invoked when a blip has been added."""
  blip = context.GetBlipById(properties['blipId']) 
  blip_text_view = blip.GetDocument()
 
  latex_regex = re.compile('\$\$(.+?)\$\$')
  m = latex_regex.search(blip_text_view.GetText())
 
  """ 
  Only replace one Latex-fragment at a time, because replaceing one fragment
  changes the text positions in the rest. That's why re.finditer isn't used.  
  """
  while m != None:
    """
    The +/- 2 is because of the length of the " />'s. 
    If not removed, the loop will run infintely! 
    """
    blip_text_view.DeleteRange(document.Range(m.start(1)-2, m.end(1)+2))
    image = document.Image('http://www.forkosh.dreamhost.com/mathtex.cgi?' + m.group(1), caption=m.group(1))
    blip_text_view.InsertElement(m.start(1)-2, image)    
    m = latex_regex.search(blip_text_view.GetText())
 
if __name__ == '__main__':
  myRobot = robot.Robot('watexy', 
      image_url='http://watexy.appspot.com/assets/icon.png',
      version='9',
      profile_url='http://watexy.appspot.com/')  
  myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded)
  myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted)
  myRobot.Run()