Install Moses MT Server

The CASMACAT workbench may interact with any machine translation system that reponds to the API according to the specifications.

In the following, we describe how to set up a machine translation server using the open source Moses system. The installation requires two parts: (1) the core Moses system, from which we will use the mosesserver process, and (2) a Python Server Wrapper that calls mosesserver, alongside other pre-processing and post-processing steps, and provides additional services.

Install the Moses Server Wrapper

You can download the server script (written in Python) from its Git repository:

 cd /opt/casmacat
 git clone git:// mt-server

The server (in python_server/ requires the cherrypy to run, so you may have to install that as well.

Install Moses

Installing Moses may be a longer process, but it may be as easy as:

 cd /opt/casmacat
 git clone git:// moses
 cd moses

If this fails, please refer to the Moses web site for additional installation instructions.

To use an existing model, you will need bin/mosesserver and various scripts in the scripts directory to handle pre and post-processing.

Set up a Toy Model

You can download a toy French-English system from the CASMACAT web site.

The system consists of a model (toy-fr-en) directory and a number of support scripts (in the scripts directory). We suggest to unpack the tar ball in a new directory:

 cd /opt/casmacat
 mkdir engines
 cd engines
 tar xzf toy-fr-en.tgz

If you place the system in a different directory, you will have to edit toy-fr-en/moses.tuned.ini.71 to point to the right locations of the model files.

The system also comes with the shell script RUN that starts up mosesserver and the Python Moses server wrapper. This script in full looks like this:


 export ROOTDIR=/opt/casmacat
 export SRCLANG=fr
 export TGTLANG=en
 export SCRIPTDIR=$ROOTDIR/engines/scripts
 export PYTHONPATH=$ROOTDIR/mt-server/python_server/python-module
 export ENGINEPATH=$ROOTDIR/engines

 mkdir -p $ENGINEPATH/log

 export MOSESSERVER_CMD="/opt/moses/bin/mosesserver \ 
   -config $MODELDIR/moses.tuned.ini.71 \ 
   --server-port 9010 \ 
   -mp -search-algorithm 1 -cube-pruning-pop-limit 100 -s 100 \ 
  >  $ENGINEPATH/log/toy-$SRCLANG-$TGTLANG.moses.stdout \ 
  2> $ENGINEPATH/log/toy-$SRCLANG-$TGTLANG.moses.stderr"


 export SERVER_PY_CMD="$ROOTDIR/mt-server/python_server/ \ 
  -tokenizer '$SCRIPTDIR/tokenizer.perl -b -a -l $SRCLANG' \ 
  -truecaser '$SCRIPTDIR/truecase.perl -b -model $MODELDIR/truecase-model.41.$SRCLANG' \ 
  -prepro '$SCRIPTDIR/normalize-punctuation.perl -b $SRCLANG' \ 
  -detruecaser '$SCRIPTDIR/detruecase.perl -b' \ 
  -detokenizer '$SCRIPTDIR/detokenizer.perl -b -l $TGTLANG' \ 
  -persist \ 
  -nthreads 1 \ 
  -ip \ 
  -port 9000 \ 
  -mosesurl '' \ 
  >  $ENGINEPATH/log/toy-$SRCLANG-$TGTLANG.stdout \ 
  2> $ENGINEPATH/log/toy-$SRCLANG-$TGTLANG.stderr"

This script starts mosesserver to listen to port 9010 and the Python server wrapper to list to port 9000. While mosesserver carries out the core translation task, the Python server wrapper deals with additional pre and post-processing.

You may have to run the following two commands to install essential libraries:

 apt-get -yq install python-pip
 pip install CherryPy

Connect the MT Server to the CASMACAT workbench

To point your CAT server to your machine translation server, you have to edit in the following lines:

 port = 9000
 if isinstance (text, unicode):
   text = text.encode ('UTF-8')
 url = '' % (

Now restart your CAT server:

 ./ 9997

If everthing still works, you have completed the installation of the CASMACAT Workbench.