forked from czcorpus/xmlanntools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathveld_xml2standoff.sh
executable file
·46 lines (36 loc) · 1.4 KB
/
veld_xml2standoff.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
#!/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
command="./xml2standoff /veld/input/${in_xml_file}"
if [ -n "$text_elements" ]; then
command+=" -t ${text_elements}"
fi
if [ -n "$exclude_elements" ]; then
command+=" -e ${exclude_elements}"
fi
if [ "$keep_linebreaks" = "true" ]; then
command+=" -kl"
fi
echo "executing:"
echo "$command"
eval "$command"
# 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_txt_file_generated="${in_xml_file%.xml}.txt"
if [ -n "$out_txt_file" ]; then
mv /veld/input/"$out_txt_file_generated" /veld/output/"$out_txt_file" 2> /dev/null
else
mv /veld/input/"$out_txt_file_generated" /veld/output/ 2> /dev/null
fi
out_json_file_generated="${in_xml_file%.xml}.json"
if [ -n "$out_json_file" ]; then
mv /veld/input/"$out_json_file_generated" /veld/output/"$out_json_file" 2> /dev/null
else
mv /veld/input/"$out_json_file_generated" /veld/output/ 2> /dev/null
fi
exit 0