forked from c-amr/camr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.sh
executable file
·93 lines (81 loc) · 1.93 KB
/
eval.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
datadir=data
global_goldfile=golds/test
testfile_basename="test.parsed.final"
function usage {
echo "Evaluation helper (uses SMATCH)"
echo
echo "usage: $0 [DATADIR] [--gold FILE] [--test FILE]"
echo
echo "--gold FILE gold AMR file (default: DATADIR/test_gold or golds/test)"
echo "--test FILE test AMR file (default: DATADIR/test.parsed.final)"
echo
echo "Default data/model directory: $datadir"
echo
}
for arg in $@; do
if [ "$arg" == "--help" ] || [ "$arg" == "-h" ]; then
usage
exit 0
fi
done
default_datadir=1
while [ $# -gt 0 ]; do
if [ "$1" == "--" ]; then
shift
break
elif [ "$1" == "--gold" ]; then
shift
if [ ! -f "$1" ]; then
echo "error: gold file does not exist: $1"
exit 1
fi
goldfile="$1"
shift
elif [ "$1" == "--test" ]; then
shift
if [ ! -f "$1" ]; then
echo "error: test file does not exist: $1"
exit 1
fi
testfile="$1"
shift
elif [ -d "$1" ] && [ $default_datadir -eq 1 ]; then
default_datadir=0
datadir="$1"
shift
else
echo "unknown argument: $1"
exit 1
fi
done
if [ "$testfile" == "" ]; then
testfile="$datadir/$testfile_basename"
fi
if [ "$goldfile" == "" ]; then
# user not specified gold file explicitly
# local goldfile
if [ -f "$datadir/test_gold" ]; then
goldfile="$datadir/test_gold"
echo "using local gold file: $goldfile"
elif [ -f "$global_goldfile" ]; then
# global goldfile
goldfile="$default_goldfile"
echo "using global gold file: $goldfile"
else
echo "error: no local or global gold file found"
exit 1
fi
elif [ ! -f "$goldfile" ]; then
# user specified gold file not found
echo "error: missing gold file: $goldfile"
exit 1
fi
if [ ! -f "$testfile" ]; then
echo "error: missing test file: $testfile"
exit 1
fi
echo "Executing:"
echo "`dirname $0`/smatch.py --pr -f \"$testfile\" \"$goldfile\" $@"
echo
time `dirname $0`/smatch.py --pr -f "$testfile" "$goldfile" $@