Ex.3 counting metrics

This commit is contained in:
Artur Nowakowski 2020-04-03 12:47:35 +02:00
parent ae19ff12e3
commit acdf9255bd
4 changed files with 35 additions and 3 deletions

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM ubuntu:latest
RUN apt-get update -y \
&& apt-get install -y make git gcc build-essential \
&& gcc --version \
&& git clone https://github.com/usnistgov/SCTK.git
WORKDIR SCTK
RUN make config && make all && make check && make install && make doc
ENV PATH=$PATH:/SCTK/bin

12
Jenkinsfile vendored
View File

@ -1,5 +1,5 @@
pipeline {
agent any
agent { dockerfile true }
stages {
//Niepotrzebne jezeli Jenkinsfile jest pobierany z repo.
stage('Checkout') {
@ -14,7 +14,15 @@ pipeline {
}
stage('Count lines'){
steps{
sh label: '', script: './count_lines.sh'
sh label: '', script: './count_lines.sh wikiniews_results.tsv'
}
}
stage('Count metrics'){
steps{
sh label: '', script: './count_metrics.s h wikiniews_results.tsv'
archiveArtifacts 'srr.txt'
archiveArtifacts 'wer.txt'
archiveArtifacts 'wikiniews_results_with_wer.txt'
}
}
stage('Archive results'){

View File

@ -1,3 +1,3 @@
#!/bin/bash
wc -l wikiniews_results.tsv > counted_lines.txt
wc -l $1 > counted_lines.txt

13
count_metrics.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
# create trn
cut -f2 $1| awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' > hypothesis.trn
cut -f3 $1 | awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' > reference.trn
#wer for each line
sclite -f 0 -r reference.trn trn -h hypothesis.trn trn -e utf-8 -i rm -o all stdout | grep Scores | awk -v OFS='\t' '{print $6, $7, $8, $9}' | awk '{print ($2 + $3 + $4)/($2 + $3 + $1) }' > wer_per_line.tsv
paste $1 wer_per_line.tsv > wikiniews_results_with_wer.tsv
#average wer and srr
awk -F'\t' '{ total += $5; count++ } END { print total/count }' wikiniews_results_with_wer.tsv > wer.txt
awk -F'\t' '{ if ( $5 == 0 ) good++; count++ } END { print good/count }' wikiniews_results_with_wer.tsv > srr.txt