-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsort_ol_results.sh
executable file
·55 lines (47 loc) · 1.16 KB
/
sort_ol_results.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
#!/bin/bash
if [ $# -lt 3 ]; then
echo "Usage: `basename $0` task source_language target_language [-a algorithm] [-l loss] [-p path] [-s split]"
echo "Computes BLEU and sorts by BLEU the hypotheses."
echo "example:`basename $0` europarl es en SGD categorical_crossentropy OL/logs"
echo "We assume that the calc_bleu tool is in $path and that the references are in ~/DATASETS/task/srctrg/split.trg"
echo "Default values:"
echo -e "\t algorithm: all (*)"
echo -e "\t loss: all (*)"
echo -e "\t path: ."
fi
task=$1
src=$2
trg=$3
algo="*"
loss="*"
path="."
split="dev"
while [ $# -ne 0 ]; do
case $1 in
"--help") usage
exit 0
;;
"-a") shift
algo=$1
;;
"-l") shift
loss=$1
;;
"-p") shift
path=$1
;;
"-s") shift
split=$1
;;
esac
shift
done
tmp=`mktemp -d`
for f in ${path}/${task}.${src}${trg}*.${split}*.${algo}.*.${loss}.${trg} ; do
echo "$f" >> ${tmp}/names
calc_bleu -r ~/DATASETS/${task}/${src}${trg}/${split}.${trg} -t ${f} | awk '{print $1" "$2}' >> ${tmp}/bleus
echo -n "."
done
echo ""
paste ${tmp}/bleus ${tmp}/names | sort -nr -k 2
rm -rf ${tmp}