change jenkinsfile

This commit is contained in:
dylodylo 2020-04-04 15:24:01 +02:00
parent 1f65493332
commit fca03bfe43
3 changed files with 39 additions and 5 deletions

8
Jenkinsfile vendored
View File

@ -23,11 +23,19 @@ pipeline {
}
}
stage("PythonScript")
{
steps{
sh label: '', script: 'python script.py'
}
}
stage("Result")
{
steps{
archiveArtifacts 'srr.txt'
archiveArtifacts 'wer.txt'
archiveArtifacts 'newresults.tsv'
}
}
stage('Hello') {

View File

@ -1,8 +1,7 @@
#!/bin/bash
MYFILE="wikiniews_results.tsv"
COUNT_DIFF=0
COUNT=$(wc -l < "$MYFILE")
COUNT=$(wc -l "$MYFILE" | awk '{print $1}')
echo $COUNT
# create trn
cut -f2 $MYFILE | awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' > hypothesis.trn
@ -10,7 +9,9 @@ cut -f3 $MYFILE | awk 'BEGIN{FS=OFS="\t"}{print $0,"(sp1_"NR")"}' > reference.tr
#wer for each line
sclite -f 0 -r reference.trn trn -h hypothesis.trn trn -e utf-8 -i rm -o all stdout > wer.txt
diff hypothesis.trn reference.trn | grep "^>" | wc -l > $COUNT_DIFF
COUNT_DIFF=$(diff hypothesis.trn reference.trn | grep "^>" | wc -l)
echo $COUNT_DIFF
RESULT=`expr $COUNT_DIFF / $COUNT * 100`
echo $RESULT > srr.text
let RESULT=$COUNT_DIFF/$COUNT
echo $(echo "$COUNT_DIFF/$COUNT" | bc -l)
echo $(echo "$COUNT_DIFF/$COUNT" | bc -l) > srr.text

25
script.py Normal file
View File

@ -0,0 +1,25 @@
import csv
file = open("results.txt", "r")
scores = []
for f in file:
if "Scores" in f:
score = (f[22:].rstrip("\n").split(" "))
score = (int(score[1])+int(score[2])+int(score[3]))/(int(score[0])+int(score[1])+int(score[2]))
scores.append(round(score,2))
file.close()
with open('wikiniews_results.tsv','r') as f_in:
with open('newresult.tsv', 'w') as f_out:
writer = csv.writer(f_out, delimiter=' ', lineterminator='\n')
reader = csv.reader(f_in, delimiter='\t')
result = []
for row,score in zip(reader, scores):
# add new column values
row.append('\t'+str(score))
result.append(row)
writer.writerows(result)