mosesdecoder/contrib/python
2012-10-03 20:04:48 +02:00
..
binpt better doc 2012-10-03 20:04:48 +02:00
examples i) check for invalid paths; ii) added sample data; iii) added --with-cmph in setup.py 2012-09-14 12:51:31 +02:00
example.py query results can now be sorted and pruned 2012-09-18 11:39:39 +02:00
README.md better doc 2012-10-03 20:04:48 +02:00
setup.py better doc 2012-10-03 20:04:48 +02:00

Python interface to Moses

The idea is to have some of Moses' internals exposed to Python (inspired on pycdec).

What's been interfaced?

  • Binary phrase table:

      Moses::PhraseDictionaryTree.h
    

Building

  1. Build the python extension:

    You need to compile Moses with link=shared and (for while) without SRILM (for some reason SRILM prevents the compiler from generating libLM.so)

    ./bjam --libdir=path cxxflags=-fPIC link=shared
    

    Then you can build the extension (in case you used --libdir=path above, use --moses-lib=path below)

    python setup.py build_ext -i [--with-cmph] [--moses-lib=path]
    
  2. Check the example code

    echo "casa" | python example.py examples/phrase-table 5 1
    echo "essa casa" | python example.py examples/phrase-table 5 1
    

Changing the code

If you want to add your changes you are going to have to recompile the cython code.

  1. Compile the cython code (use Cython 0.16): this will generate binpt/binpt.cpp

    cython --cplus binpt/binpt.pyx