# semco-train - script to train Semco with nohup
# Eirik Hektoen, 1997

# This script runs the GDE/Lisp image named as the first argument
# (default "gde" applies when no arguments), loads "semco" and any
# files named as further arguments, and calls semco-train.

DIR=`pwd`
PRG=${1-gde}
JOB=/tmp/semco-job-$$
INP=/tmp/semco-inp-$$
OUT=/tmp/semco-out-$$

LOAD="\"/usr/groups/nltools/semco/semco\""
until [ ${2-""} = "" ]
do LOAD="$LOAD \"$2\""; shift
done

cat > $INP <<- xxx
  (chdir "$DIR")
  (dolist (x '($LOAD)) (load x))
  (semco-train-corpus)
  (exit)
xxx

cat > $JOB <<- xxx
  TZ=GMT
  cd $DIR
  echo Training Semco with $PRG on \`hostname\`
  date
  echo
  echo "!(load \"$INP\")" | nice $PRG
  echo
  echo Training finished.
  date
  rm $INP $JOB
xxx

echo Will run $PRG,
echo load $LOAD,
echo and call semco-train-corpus...
echo

OLD=$OUT-old
if [ -f $OLD ]; then rm $OLD; fi
if [ -f $OUT ]; then mv $OUT $OLD; fi

nohup sh $JOB > $OUT &
echo Started nohup process $!
echo with output to $OUT
