Saturday, December 7, 2013

MAC OS: compile Megam for Moses

Megam is a machine learning tool which can be found at:
http://www.umiacs.umd.edu/~hal/megam/

It is required by the pair-wise ranking optimization (PRO, which is a replacement of MERT) of Moses.
It releases its binary executable version on Linux which can run on most Linux systems, but it does not have a binary executable version for MAC OS. We have to compile it by ourselves.

MAC OS version: 10.8.5
Port version: MacPorts 2.2.1
Megam version: 0.92 (Fifth Release 17 August 2007)
Moses version: 1.0

1. install ocaml using port on MAC OS:
sudo port install ocaml

2. go to the MERT directory of Moses:
cd mosesdecoder-RELEASE-1.0/mert

3. download Megam:
wget http://hal3.name/megam/megam_src.tgz
tar -xzvf megam_src.tgz (creating a directory megam_0.92)
cd megam_0.92

4. change megam's Makefile:
(1) replace "WITHSTR =str.cma -cclib -lstr" with:
WITHSTR =str.cma -cclib -lcamlstr
(2) replace "WITHCLIBS =-I /usr/lib/ocaml/caml" with:
WITHCLIBS =-I /opt/local/lib/ocaml/caml/

5. compile:
make opt

6. link:
cd .. (to mosesdecoder-RELEASE-1.0/mert)
ln -sf megam_0.92/megam.opt megam_i686.opt

Now you can run mert-moses.pl with PRO tuning.


No comments: