Select Git revision
Franck Dary authored
train.sh 1.61 KiB
#! /bin/bash
function has_space {
[[ "$1" != "${1%[[:space:]]*}" ]] && return 0 || return 1
}
function print_usage_and_exit {
>&2 echo "USAGE : (tsv | txt) expPath [arguments]"
exit 1
}
MODE=$1
EXPPATH=$2
if [ -z "$MODE" ];
then
>&2 echo "ERROR : missing argument 1 (mode)"
print_usage_and_exit
fi
if [ -z "$EXPPATH" ];
then
>&2 echo "ERROR : missing argument 2 (expPath)"
print_usage_and_exit
fi
shift
shift
if [ ! -d "$EXPPATH" ]; then
>&2 echo "ERROR : directory $EXPPATH doesn't exist"
print_usage_and_exit
fi
source $EXPPATH"/config"
TRAIN=$(find $CORPUS -type f -name '*train*.conllu')
TRAINRAW=$(find $CORPUS -type f -name '*train*.txt')
DEV=$(find $CORPUS -type f -name '*dev*.conllu')
DEVRAW=$(find $CORPUS -type f -name '*dev*.txt')
TEST=$(find $CORPUS -type f -name '*test*.conllu')
TESTRAW=$(find $CORPUS -type f -name '*test*.txt')
if has_space "$TRAIN" || has_space "$DEV" || has_space "$TEST";
then
>&2 echo "ERROR : more than 1 match with keyword" $KEYWORD
>&2 echo "TRAIN : " $TRAIN
>&2 echo "DEV : " $DEV
>&2 echo "TEST : " $TEST
print_usage_and_exit
fi
if test ! -f $TRAIN;
then
>&2 echo "ERROR : no train file found in" $CORPUS
>&2 echo "$TRAIN"
print_usage_and_exit
fi
CURDIR=$(pwd)
cd $EXPPATH"/"data && make -s clean && make -s && cd $CURDIR
MCD=$EXPPATH"/data/*\.mcd"
if [ "$MODE" = "tsv" ]; then
macaon train --model $EXPPATH --mcd $MCD --trainTSV $TRAIN --devTSV $DEV $@ || exit 1
exit 0
fi
if [ "$MODE" = "txt" ]; then
macaon train --model $EXPPATH --mcd $MCD --trainTSV $TRAIN --trainTXT $TRAINRAW --devTSV $DEV --devTXT $DEVRAW $@ || exit 1
exit 0
fi
print_usage_and_exit