s416178-mlworkshops/shell_script.sh
2020-04-03 14:06:51 +02:00

24 lines
830 B
Bash

#!/bin/bash
wc -l $1 > result.log
cut -f 2 $1 > hypothesis.txt
cut -f 3 $1 > reference.txt
mv wer.txt wer1.txt
mv srr.txt srr1.txt
cat wer1.txt | tail -n 499 > wer.txt
cat srr1.txt | tail -n 499 > srr.txt
awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' < hypothesis.txt > hypothesis.trn
awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' < reference.txt > reference.trn
sclite -f 0 -r reference.trn trn -h hypothesis.trn trn -e utf-8 -i rm -o all stdout | grep Scores > scores
awk 'BEGIN{OFS="\t"}{print $6, $7, $8, $9}' < scores | awk '{ print ($2 + $3 + $4)/($2 + $3 + $1) }' > wer.tsv
paste $1 wer.tsv > wikiniews_results_wer.tsv
awk 'BEGIN{FS=OFS="\t"}{ bad = bad + $1; all++ }END{ print bad/all }' < wer.tsv >> wer.txt
awk 'BEGIN{FS=OFS="\t"}{ if ( $1 == 0 ) good++; all++ }END{ print good/all }' < wer.tsv >> srr.txt