srush/PyDecode — pull request #7 by srush (2013-10-30 22:27:16+00:00)
Title: Get Cython working with semirings

Hey,

So this took way longer then expected to do, but was actually pretty interesting. I did the following.

* I used jinja2 to make a file hyper.pyx.tpl. I then call cython_jinja.py to generate hyper.pyx which then has a class for each semiring. In python you can call these as Viterbi.Weights, Prob.Weights which is actually pretty elegant.

* I moved you template member definitions into the header. For some reason cython fails to link if they are in the .cpp, otherwise it is able to find them. (I had to explicitly instantiate the classes in Algorithms.cpp).

* Apparently you need the "inline" keyword on specializations, according to stackoverflow.

* I added back the SemiringWeight template parameter into the semiring class. The compiler was complaining if I didn't have that.

* Some of the times and pluses are flipped, but that part should be easy to fix compared to the rest of this (phew).

So I'll check this in and you can have fun merging it with your changes :). Sorry about that.