Skip to content
Snippets Groups Projects
Commit c8c1703e authored by Franck Dary's avatar Franck Dary
Browse files

Added basic training script

parent 3c36c5e2
No related branches found
No related tags found
No related merge requests found
#! /bin/bash
source config
function has_space {
[[ "$1" != "${1%[[:space:]]*}" ]] && return 0 || return 1
}
function print_usage_and_exit {
>&2 echo "USAGE : language_keyword templateName expName [arguments]"
exit 1
}
MCD=data/conllu.mcd
KEYWORD=$1
TEMPLATENAME=$2
EXPNAME=$3
if [ -z "$KEYWORD" ];
then
>&2 echo "ERROR : missing argument 1 (keyword)"
print_usage_and_exit
fi
if [ -z "$TEMPLATENAME" ];
then
>&2 echo "ERROR : missing argument 2 (templateName)"
print_usage_and_exit
fi
if [ -z "$EXPNAME" ];
then
>&2 echo "ERROR : missing argument 3 (expName)"
print_usage_and_exit
fi
shift
shift
shift
if [ "$KEYWORD" = "." ]
then
KEYWORD=""
fi
TRAIN=$(find $UD_ROOT*$KEYWORD -type f -name '*train*.conllu')
TRAINRAW=$(find $UD_ROOT*$KEYWORD -type f -name '*train*.txt')
DEV=$(find $UD_ROOT*$KEYWORD -type f -name '*dev*.conllu')
DEVRAW=$(find $UD_ROOT*$KEYWORD -type f -name '*dev*.txt')
TEST=$(find $UD_ROOT*$KEYWORD -type f -name '*test*.conllu')
TESTRAW=$(find $UD_ROOT*$KEYWORD -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 with keyword" $KEYWORD
>&2 echo "$TRAIN"
print_usage_and_exit
fi
mkdir -p bin
if [ ! -d "$TEMPLATENAME" ]; then
>&2 echo "ERROR : directory $TEMPLATENAME doesn't exist"
print_usage_and_exit
fi
cp -r $TEMPLATENAME bin/$EXPNAME
EVALCONLL="../scripts/conll18_ud_eval.py"
macaon_train --model bin/$EXPNAME --mcd $MCD --trainTSV $TRAIN --devTSV $DEV $@ || exit 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment