#!/bin/sh

#   determine Java environment
export JAVA_PLATFORM="sun-jdk"
eval `@l_prefix@/bin/java-toolkit -e`

#   sanity check arguments
if [ $# -lt 1 -o $# -gt 2 ]; then
    echo "Usage: postagger <model-file>|<model-name> [-textFile <input>]"
    exit 1
fi
model="$1"
shift

#   determine model
if [ ! -f "$model" ]; then
    if [ -f "@l_prefix@/share/postagger/$model.tagger" ]; then
        model="@l_prefix@/share/postagger/$model.tagger"
    else
        echo "No such model: $model"
        exit 1
    fi
fi

#   pass-through execution
exec @l_prefix@/bin/java \
    -mx5g -cp "@l_prefix@/lib/postagger/stanford-postagger.jar:" \
    edu.stanford.nlp.tagger.maxent.MaxentTagger \
    -model "$model" \
    "$@"

