s452111-mlworkshops/metrics_service.sh

14 lines
590 B
Bash

#!/bin/bash
# Prepare hypothesis file based on column 2
cut -f2 'wikiniews_results.tsv' > hypothesis.txt
# Prepare reference file based on column 3
cut -f3 'wikiniews_results.tsv' > reference.txt
# awk transfer txt to .trn
awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' < reference.txt > reference.trn
awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' < hypothesis.txt > hypothesis.trn
# use sclite to calculate WER, actually we need only lines starting with 'Scores'
sclite -f 0 -r reference.trn trn -h hypothesis.trn trn -e utf-8 -i rm -o all stdout | grep "Scores:" > wer_results.txt