Sunday 26 June 2016

Installing moses and its componets for text translation between two languages


Moses is a statistical machine translation system that allows you to automatically train translation models for any language pair. All you need is a collection of translated texts (parallel corpus). Once you have a trained model, an efficient search algorithm quickly finds the highest probability translation among the exponential number of choices.

Before installing moses install the following packages :


g++, git, subversion, automake, libtool, zlib1g-dev, libboost-all-dev, libbz2-dev, liblzma-dev, python-dev, libtcmalloc-minimal4 

sudo apt-get install g++ git subversion automake libtool zlib1g-dev libboost-all-dev libbz2-dev liblzma-dev python-dev libtcmalloc-minimal4
Installing Boost :

Make a directory where all work related to Machine Translation will be present:
 mkdir MachineTranslation
Download Boost from Sourceforge and extract it to this folder using file manager.
If you download boost_1_61_0 you must be able to see the folder boost_1_61_0 in the folder MachineTranslation. Then enter that folder using terminal.
cd boost_1_61_0
Then run the following commands:
 ./bootstrap.sh
 ./b2 -j5 --prefix=$PWD -- libdir=$PWD/lib64 --layout=tagged link=static threading =multi,single install || echo FAILURE
In the above command -j5 indicates my PC is 5 Core machine (i.e. i5 processor). Use -j2 for dual core or -j3 for i3.

Installing Moses :

Download Moses decoder, Giza++ from github and extract to the directory MachineTranslation
In terminal enter the directory mosesdecoder-master

cd ../mosesdecoder-master/
Install moses:
 ./bjam -j5
If you installed moses successfully, you will be able to see the options available with bjam. Run:
./bjam --help
./bjam --with-boost=/home1/MachineTranslation/boost_1_61_0/ -j5
Enter the path of the directory MachineTranslation according to your PC in the above command
Then enter the directory giza-pp-master:

cd ../giza-pp-master/
Install giza-pp-master:
make
Go to the directory mosesdecoder-master:
cd ../mosesdecoder-master/
Make tools directory:
mkdir tools
Copy components to the tools directory:
cp ../giza-pp-master/GIZA++-v2/GIZA++ ../giza-pp-master/GIZA++-v2/snt2cooc.out ../giza-pp-master/mkcls-v2/mkcls tools/
Installing IRSTLM :

Download the latest version of IRSTLM from Sourceforge and extract it to the MachineTranslation directory.
Now enter the directory trunk in irstlm in the terminal

cd ../irstlm-5.80.08/trunk/
Install IRSTLM:
./regenerate-makefiles.sh
./configure --prefix=/home1/MachineTranslation/irstlm-5.80.08/
make install
Enter the path of the directory MachineTranslation according to your PC in the above command


Sample example running on moses :
 
Go to the directory mosesdecoder-master
cd ../../mosesdecoder-master/
Download samples:
wget http://www.statmt.org/moses/download/sample-models.tgz
tar xzf sample-models.tgz
rm sample-models.tgz
cd sample-models/
Run the decoder :
 /home1/MachineTranslation/mosesdecoder-master/bin/moses -f phrase-model/moses.ini < phrase-model/in > out

If everything worked out right, this should translate the sentence "das ist ein kleine haus" (in the file in) as "this is a small house" (in the file out).

5 comments:

  1. IS IRSTLM IS DIFFICULT TO INSTALL ?? As it becomes older??

    ReplyDelete
  2. IRSTLM in unable to install on Ubuntu 19 .After "make" it simply terminate the compilation,without making the "bin" directory.
    Is KenLM is the replacement of IRSTLM of all?

    ReplyDelete
  3. Is it possible to install mosesdecoder,without installing IRSTLM ?

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete