forked from czcorpus/xmlanntools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathveld_ann2standoff.sh
executable file
·49 lines (38 loc) · 1.68 KB
/
veld_ann2standoff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# This script is a wrapper for the underlying xmlanntools script. It handles input and output files,
# respective to the VELD design, and also constructs a command from the VELD compose file, which is
# then executed.
set -e
# because the script excpects additional files with specific naming, but the code veld enables more
# flexibility, a temporary input file is created for consumption of the underlying script, without
# modifying that.
in_txt_file_expected="${in_conllu_file%.conllu}.txt"
if [ -n "$in_txt_file" ] && [ $in_txt_file != $in_txt_file_expected ]; then
cp /veld/input/data/"$in_txt_file" /veld/input/data/"$in_txt_file_expected"
rm_txt_file=1
fi
command="./ann2standoff /veld/input/data/${in_conllu_file}"
if [ -n "$in_ann2standoff_ini_file" ]; then
command+=" -c /veld/input/config/${in_ann2standoff_ini_file}"
fi
if [ -n "$profile_name" ]; then
command+=" -p ${profile_name}"
fi
echo "executing:"
echo "$command"
eval "$command"
if [ "$rm_txt_file" = "1" ]; then
rm /veld/input/data/"$in_txt_file_expected"
fi
# The underlying script produces output next to the input file, which clashes with VELD's design. So
# the output file is moved from the input folder to the respective output folder. In case that the
# chain veld actually maps the input and output folder to the same host path, the `mv` operation
# might crash; hence ignoring such crashes with `set +e` and `2> /dev/null`
set +e
out_json_file_generated="${in_conllu_file%.conllu}.ann.json"
if [ -n "$out_json_file" ]; then
mv /veld/input/data/"$out_json_file_generated" /veld/output/"$out_json_file" 2> /dev/null
else
mv /veld/input/data/"$out_json_file_generated" /veld/output/ 2> /dev/null
fi
exit 0