#! /bin/sh
#-------------------------------------------------------------------------------
# This file is part of OpenMaTrEx: a marker-driven corpus-based machine
# translation system.
#
# Copyright (c) 2004-2011 Dublin City University
# (c) 2011 Mikel L. Forcada, Sergio Penkale, Pratyush Banerjee, Antonio Toral
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# License text:
#-------------------------------------------------------------------------------
# This program installs OpenMaTrEx in the directory given as an argument.
# It installs:
# Giza++ 1.0.3 (and patches it to work when compiled with g++-4.4)
# IRSTLM 5.22.01
# Moses rev. 3284
# OpenMaTrEx v. 0.98 and dependencies
# It also configures the OpenMaTrEx command and the shell to launch
# a sample run (sample-run.sh)
EXPECTED_ARGS=1
E_BADARGS=65
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` INSTALLATION-DIRECTORY"
exit $E_BADARGS
fi
# set -x
set -e #if any command fails -> exit
set -u #if any variable not set -> exit
# Create installation directory
mkdir -p $1
# Obtain an absolute path
export INSTALLDIR=`cd $1; pwd`
echo "===> Installation directory:" $INSTALLDIR
cd $INSTALLDIR
# Install version 1.0.3 of Giza++
echo "===> Installing Giza++"
wget http://giza-pp.googlecode.com/files/giza-pp-v1.0.3.tar.gz
tar -xvzf giza-pp-v1.0.3.tar.gz
# Before compiling, we need to patch a file in Giza++ (Instead, it will not
# compile under g++-4.4, check
# http://code.google.com/p/giza-pp/issues/detail?id=11#c4)
wget http://www.openmatrex.org/giza-pp.patch
patch giza-pp/GIZA++-v2/file_spec.h Installing IRSTLM"
wget http://downloads.sourceforge.net/project/irstlm/irstlm/irstlm-5.22.01/irstlm-5.22.01.tar.gz
tar xzvf irstlm-5.22.01.tar.gz
cd irstlm-5.22.01
./configure --prefix=$INSTALLDIR
make
make install
cd ..
# Download and install version 3284 of Moses
echo "===> Installing Moses"
mkdir moses
svn co https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk moses -r 3284
cd moses
./regenerate-makefiles.sh
./configure --with-irstlm=$INSTALLDIR
make
# Install Moses scripts
cd scripts
# Change directories to release scripts
cp Makefile Makefile.bak
awk '/^TARGETDIR=/ {$0="TARGETDIR='"$INSTALLDIR"'/bin"} \
/^BINDIR=/ {$0="BINDIR='"$INSTALLDIR"'/bin"} {print}' Makefile.bak >Makefile
rm Makefile.bak
# But before releasing, patch moses_mert.pl so that it provides default
# values for at least 6 translation model weights
# [This is needed for later versions of Moses which use the new MERT]
# wget http://openmatrex.org/mert-moses.pl.patch
# patch training/mert-moses.pl Install OpenMaTrEx"
# Download OpenMaTrEx by checking it out from the trunk of
# the Subversion repository.
cd $INSTALLDIR
# svn co http://openmatrex.org/svn/OpenMaTrEx/trunk/
# Alternatively, one could download a particular version
wget http://openmatrex.org/OpenMaTrEx-0.98.tgz
tar xzvf OpenMaTrEx-0.98.tgz
# cd trunk
# Or, for a particular release
cd OpenMaTrEx-0.98
cd lib
wget http://download.java.net/maven/1/args4j/jars/args4j-2.0.9.jar
cd ..
ant dist
export SCRIPTDIR=$(ls -d $INSTALLDIR/bin/scripts*)
cp OpenMaTrEx OpenMaTrEx.bak
# This for the version from the Subversion repository
# awk '/^export BASE_DIR=/ {$0="export BASE_DIR='"$INSTALLDIR"'"} \
# /^export OPENMATREX_DIR=/ {$0="export OPENMATREX_DIR='"$INSTALLDIR"'/trunk"} \
# /^export MOSES_SCRIPTS_DIR=/ {$0="export MOSES_SCRIPTS_DIR='"$SCRIPTDIR"'"} \
# {print}' OpenMaTrEx.bak >OpenMaTrEx
# This installs a particular version
awk '/^export BASE_DIR=/ {$0="export BASE_DIR='"$INSTALLDIR"'"} \
/^export OPENMATREX_DIR=/ {$0="export OPENMATREX_DIR='"$INSTALLDIR"'/OpenMaTrEx-0.98"} \
/^export MOSES_SCRIPTS_DIR=/ {$0="export MOSES_SCRIPTS_DIR='"$SCRIPTDIR"'"} \
{print}' OpenMaTrEx.bak >OpenMaTrEx
rm OpenMaTrEx.bak
# This modifies the sample_run.sh document
cp sample-run.sh sample-run.sh.bak
# For the version from the Subversion repository
# awk '/^OM=/ {$0="OM='"$INSTALLDIR"'/trunk/OpenMaTrEx"} \
# {print}' sample-run.sh.bak >sample-run.sh
# For a particular version
awk '/^OM=/ {$0="OM='"$INSTALLDIR"'/OpenMaTrEx-0.98/OpenMaTrEx"} \
{print}' sample-run.sh.bak >sample-run.sh
rm sample-run.sh.bak