#!/bin/bash

# Parse log file and get best epoch based on validation score
# detokenize the reference and hypothesis
# use sacre_bleu.pl

if [ $# -ne 5 ]; then
    echo "- usage: $0 <ref_file> <ref_lang> <hyp_file> <hyp_lang> <out_results_file>"
    exit;
fi

ref_file=$1
ref_lang=$2

hyp_file=$3
hyp_lang=$4

res_file=$5

tools/mosesdecoder/scripts/tokenizer/detokenizer.perl -l ${ref_lang} -q < ${ref_file} > ${ref_file}.detok
tools/mosesdecoder/scripts/tokenizer/detokenizer.perl -l ${hyp_lang} -q < ${hyp_file} > ${hyp_file}.detok

sacrebleu \
    ${ref_file}.detok \
    -i ${hyp_file}.detok \
    -m bleu chrf ter \
    >> ${res_file}
