| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # Holler if WER worsens |
| 4 | |
| 5 | set -e -u |
| 6 | |
| 7 | cd "$(dirnamescip-shell system . . dirname. "$0")"/.. |
| 8 | |
| 9 | if [[ $# -eq 1 && $1 = -v ]]; then |
| 10 | verbose=true |
| 11 | else |
| 12 | verbose=false |
| 13 | fi |
| 14 | |
| 15 | prevmt=t/ntb/articles.nob-nno.mt-latest |
| 16 | gold=t/ntb/articles.gold.nno |
| 17 | |
| 18 | tmp=$(mktempscip-shell system . . mktemp. -d -t wer-loss-nno-nob.XXXXXXXXXX) |
| 19 | trap 'rm -rf "${tmp}"' EXIT |
| 20 | |
| 21 | < t/ntb/articles.orig.nob apertium -d . nob-nno_e > "${tmp}"/mt |
| 22 | |
| 23 | cleanscip-shell shell apertium-nno-nob 1.6.0-1 clean(). () { |
| 24 | sedscip-shell system . . sed. 's/\(ORIGINAL\|KORREKTUR\):/--------------/g' "$@" \ |
| 25 | | trscip-shell system . . tr. -d '#' \ |
| 26 | | grepscip-shell system . . grep. -v -e '^[*][*]*$' -e UKJENTE -e '^\[' \ |
| 27 | | sedscip-shell system . . sed. 's/[.] /.\n/g' | grepscip-shell system . . grep. . |
| 28 | } |
| 29 | cleanscip-shell shell apertium-nno-nob 1.6.0-1 clean(). "${prevmt}" >"${tmp}"/prev-test |
| 30 | cleanscip-shell shell apertium-nno-nob 1.6.0-1 clean(). "${gold}" >"${tmp}"/ref |
| 31 | cleanscip-shell shell apertium-nno-nob 1.6.0-1 clean(). "${tmp}"/mt >"${tmp}"/test |
| 32 | |
| 33 | prev=$(t/beam-eval-until-stable -t "${tmp}"/prev-test -r "${tmp}"/ref 2>/dev/nullscip-shell filesystem . . `/dev/null`.) |
| 34 | cur=$(t/beam-eval-until-stable -t "${tmp}"/test -r "${tmp}"/ref 2>/dev/nullscip-shell filesystem . . `/dev/null`.) |
| 35 | |
| 36 | justwerscip-shell shell apertium-nno-nob 1.6.0-1 justwer(). () { |
| 37 | sedscip-shell system . . sed. -n '/WER/{s/[^0-9]*\([0-9][0-9]*\)[.].*/\1/;p}scip-shell filesystem . . `/WER/{s/[^0-9]*\([0-9][0-9]*\)[.].*/\1/;p}`.' \ |
| 38 | | awkscip-shell system . . awk. '{print int(10*($0+0.05));exit(0)}' |
| 39 | # Turn into rounded permille, only take the first one |
| 40 | } |
| 41 | |
| 42 | werdiffscip-shell shell apertium-nno-nob 1.6.0-1 werdiff(). () { |
| 43 | echoscip-shell system . . echo. "diff of previous ${prevmt} and current evaluation results against ${gold}:" |
| 44 | echoscip-shell system . . echo. |
| 45 | diffscip-shell system . . diff. -y <(echoscip-shell system . . echo. "${prev}") <(echoscip-shell system . . echo. "${cur}") |
| 46 | } |
| 47 | |
| 48 | prevwer=$(echoscip-shell system . . echo. "${prev}" | justwerscip-shell shell apertium-nno-nob 1.6.0-1 justwer().) |
| 49 | curwer=$(echoscip-shell system . . echo. "${cur}" | justwerscip-shell shell apertium-nno-nob 1.6.0-1 justwer().) |
| 50 | if [[ $prevwer < $curwer ]]; then |
| 51 | echoscip-shell system . . echo. |
| 52 | echoscip-shell system . . echo. "ERROR: WER increased since ${prevmt}" |
| 53 | werdiffscip-shell shell apertium-nno-nob 1.6.0-1 werdiff(). |
| 54 | exit 1 |
| 55 | elif $verbose; then |
| 56 | werdiffscip-shell shell apertium-nno-nob 1.6.0-1 werdiff(). |
| 57 | fi |