sacrebleu.sh 486 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. if [ $# -ne 4 ]; then
  3. echo "usage: $0 TESTSET SRCLANG TGTLANG GEN"
  4. exit 1
  5. fi
  6. TESTSET=$1
  7. SRCLANG=$2
  8. TGTLANG=$3
  9. GEN=$4
  10. if ! command -v sacremoses &> /dev/null
  11. then
  12. echo "sacremoses could not be found, please install with: pip install sacremoses"
  13. exit
  14. fi
  15. grep ^H $GEN \
  16. | sed 's/^H\-//' \
  17. | sort -n -k 1 \
  18. | cut -f 3 \
  19. | sacremoses detokenize \
  20. > $GEN.sorted.detok
  21. sacrebleu --test-set $TESTSET --language-pair "${SRCLANG}-${TGTLANG}" < $GEN.sorted.detok