s426086-mlworkshops/countlines-metrics.sh

29 lines
1.0 KiB
Bash
Raw Normal View History

2020-04-18 18:26:02 +02:00
#!/bin/sh
2020-04-22 23:30:43 +02:00
#zad 1 - liczenie lini
wc -l wikiniews_results.tsv > countlines_result.txt
2020-04-18 18:26:02 +02:00
2020-04-22 23:30:43 +02:00
#zad 3
#dane do txt
cut --fields=2 wikiniews_results.tsv > hypothesis.txt
cut --fields=3 wikiniews_results.tsv > reference.txt
#do trn
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 sluzy do obliczenia WER
2020-04-22 23:43:41 +02:00
sclite -f 0 -r reference.trn trn -h hypothesis.trn trn -e utf-8 -i rm -o all stdout | grep Score > results
2020-04-22 23:30:43 +02:00
2020-04-22 23:43:41 +02:00
#pobranie #C #S #D #I do obliczenia WER i oblicznie
awk 'BEGIN{OFS="\t"}{print $6, $7, $8, $9}' < results | awk '{ print ($2 + $3 + $4)/($2 + $3 + $1) }' > wer.tsv
2020-04-22 23:30:43 +02:00
2020-04-22 23:43:41 +02:00
paste wikiniews_results.tsv wer.tsv > wikiniews_results.tsv
2020-04-22 23:47:48 +02:00
2020-04-22 23:43:41 +02:00
awk 'BEGIN{FS=OFS="\t"}{ bad = bad + $1; all++ }END{ print bad/all }' < wer.tsv >> wer.txt
2020-04-23 08:30:07 +02:00
awk 'BEGIN{FS=OFS="\t"}{ if ( $1 == 0 ) good++; all++ }END{ print good/all }' < wer.tsv >> srr.txt
2020-04-23 08:33:53 +02:00
tail -n 50 wer.txt > wer1.txt
tail -n 50 srr.txt > srr1.txt
rm wer.txt
rm srr.txt
mv wer1.txt wer.txt
mv srr1.txt srr.txt