Debian Codegraph @

beam-eval-until-stable

raw
1 #!/bin/bash
2
3 if [[ $# -ne 4 ]]; then
4 cat <<EOF
5 ERROR: Missing -t and -r arguments.
6
7 Usage: Run this script with the same parameters as you would give
8 apertium-eval-translator.pl when running it without -beam, e.g.:
9
10 $0 -t test.txt -r ref.txt
11
12 This script will keep running apertium-eval-translator.pl with
13 doubling sizes of the -beam parameter until the result seems stable.
14 EOF
15 exit 1
16 fi
17
18
19 last=-1
20
21 b=5
22
23 while true; do
24 printf "Trying -beam %s …\t" "$b" >&2
25 out=$("$(dirname "$0")"/apertium-eval-translator.pl -b $b "$@")
26 cur=$(grep -m1 WER <<<"${out}")
27 if [[ "$last" = "$cur" ]]; then
28 echo "Stabilised; got the same result as with -beam $lastb: $cur" >&2
29 echo "${out}"
30 break
31 else
32 echo "got $cur" >&2
33 lastb="$b"
34 (( b += b ))
35 last="$cur"
36 fi
37 done