#!/bin/sh
SEMPATH=.
GRAMMAR=./shrdlurn/stacks.grammar
mkdir ./shrdlurn/logs
mkdir ./shrdlurn/examples
cd $SEMPATH

LEARNOPTS="-Parser FloatingParser -FloatingParser.maxDepth 8 -FloatingParser.useSizeInsteadOfDepth true -Params.l1Reg lazy -Params.l1RegCoeff 0.001 -Parser.beamSize 100 -StacksWorldFeatureComputer.ngramN 2 -Params.initStepSize 0.1 -Params.adaptiveStepSize true -FeatureExtractor.featureDomains tree"

SESSIONSTUFF="-Master.onlineLearnExamples false -Master.independentSessions true"

PRAG="-Master.bePragmatic true -PragmaticListener.addModelProb true -PragmaticListener.smoothAlpha 1.0 -PragmaticListener.uniformWeight 0.001 -PragmaticListener.lambda 3.0 -Learner.onlineEvaluation true -Derivation.comparePragmatically true"

OPTIONS="-Dmodules=core,cubeworld -cp libsempre/*:lib/* -ea edu.stanford.nlp.sempre.Main  -execDir _OUTPATH_/runFloat -overwriteExecDir -addToView 0 -Main.interactive -JavaExecutor.convertNumberValues false -FeatureExtractor.featureComputers cubeworld.StacksWorldFeatureComputer  -Params.initWeightsRandomly false -Grammar.inPaths $GRAMMAR -Parser.pruneErrorValues true -JoinFn.typeInference true -LanguageAnalyzer.lowerCaseTokens true"

# features are tree, heads, ngram
DEBUG="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,suspend=n,address=8898"

if [ "$HOSTNAME" = "jonsson.stanford.edu" ]; then
    echo "running on jonsson"
    TRAIN_OUTS_SERVER="-Master.newExamplesPath /afs/cs.stanford.edu/u/sidaw/git/examples/ -Master.logPath /afs/cs.stanford.edu/u/sidaw/git/logs/ -server true"
    echo rlwrap java $OPTIONS $LEARNOPTS $SESSIONSTUFF $TRAIN_OUTS_SERVER -Server.numThreads 16 "$@"
    rlwrap java $OPTIONS $LEARNOPTS $SESSIONSTUFF $TRAIN_OUTS_SERVER -Server.numThreads 16 "$@"
else
    echo "not running on jonsson"
    TRAIN_OUTS_LOCAL="-Master.newExamplesPath ./shrdlurn/examples/ -Master.logPath ./shrdlurn/logs/ -server true"
    rlwrap java $OPTIONS $LEARNOPTS $TRAIN_OUTS_LOCAL $SESSIONSTUFF $PRAG -Server.numThreads 1 "$@"
fi
