diff --git a/Jenkinsfile b/Jenkinsfile index 71d7710..d1e9313 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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') { diff --git a/count.sh b/count.sh index ec24464..5dd2e24 100644 --- a/count.sh +++ b/count.sh @@ -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 diff --git a/script.py b/script.py new file mode 100644 index 0000000..98f13b9 --- /dev/null +++ b/script.py @@ -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) \ No newline at end of file