#!/bin/bash
#
# Joshua decoder invocation script.
# 
# This script takes care of passing arguments to Java and to the
# Joshua decoder.  Usage:
#
# ./decoder [-m memory] [Joshua arguments]
#
# The default amount of memory is 4gb.

NUM_ARGS=0
E_OPTERROR=1

## memory usage; default is 4 GB
mem=4g

if [[ $1 == "-m" ]]; then
    mem=$2

    shift
    shift
fi

set -u

exec java -Xmx${mem} \
 	-cp $JOSHUA/class:$JOSHUA/thrax/bin/thrax.jar:$JOSHUA/lib/berkeleylm.jar:$JOSHUA/lib/junit-4.10.jar \
	-Dfile.encoding=utf8 \
	-Djava.util.logging.config.file=${JOSHUA}/logging.properties \
	-Djava.library.path=$JOSHUA/lib \
	joshua.decoder.JoshuaDecoder "$@"
