From c8c1703e41836a6c0a1e20a13abe572ef8061599 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Sat, 8 Feb 2020 18:49:32 +0100
Subject: [PATCH] Added basic training script

---
 UD_any/train.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100755 UD_any/train.sh

diff --git a/UD_any/train.sh b/UD_any/train.sh
new file mode 100755
index 0000000..721a966
--- /dev/null
+++ b/UD_any/train.sh
@@ -0,0 +1,81 @@
+#! /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
+
-- 
GitLab