Add metrics stage

This commit is contained in:
Dawid Jurkiewicz 2020-04-03 13:22:58 +02:00
parent 3814bb388b
commit e4ddae9c0a
2 changed files with 19 additions and 0 deletions

8
Jenkinsfile vendored
View File

@ -13,5 +13,13 @@ pipeline {
archiveArtifacts 'line_count.txt' archiveArtifacts 'line_count.txt'
} }
} }
stage('Calc metrics') {
steps {
sh label: '', script: './calc_metrics.sh'
archiveArtifacts 'wer.txt'
archiveArtifacts 'srr.txt'
archiveArtifacts 'wikinews_results.tsv'
}
}
} }
} }

11
calc_metrics.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
cut -f2 wikiniews_results.tsv | awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' > hyp.trn
cut -f3 wikiniews_results.tsv | awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' > ref.trn
sclite -f 0 -r ref.trn trn -h hyp.trn trn -e utf-8 -i rm -o sum stdout | grep "Sum/Avg" | python3 -c "import sys; import re; print('\t'.join(re.findall(r'(\d+\.\d+)', sys.stdin.read())[-2:]))" > wer_srr.txt
cut -f1 wer_srr.txt > wer_total.txt
cut -f2 wer_srr.txt > srr.txt
sclite -f 0 -r ref.trn trn -h hyp.trn trn -e utf-8 -i rm -o pra stdout | grep "Scores:" | sed 's/Scores: (#C #S #D #I) // ' | awk '{ c=$1; s=$2; d=$3; i=$4; print ($s+$d+$i)/($s+$d+$c)}' > wer_all.txt
awk '{ sum += $1; n++ } END { print sum / n; }' < wer_all.txt > wer.txt
paste wikiniews_results.tsv wer.txt > wikinews_results.txt
rm wikiniews_results.tsv