annotate tests/test-summaries/test-summaries.sh @ 154:6ff4da31db8b labfile

Implement .lab file writer
author Chris Cannam
date Tue, 14 Oct 2014 17:30:44 +0100
parents 7a31201dc42d
children 11a9ce2fa331
rev   line source
Chris@0 1 #!/bin/bash
Chris@0 2
Chris@119 3 . ../include.sh
Chris@0 4
Chris@119 5 infile=$audiopath/3clicks8.wav
Chris@119 6 infile2=$audiopath/6clicks8.wav
Chris@0 7 tmpfile=$mypath/tmp_1_$$
Chris@0 8 tmpcanonical=$mypath/tmp_2_$$
Chris@59 9 expcanonical=$mypath/tmp_exp_2_$$
Chris@16 10 tmpcmp1=$mypath/tmp_3_$$
Chris@16 11 tmpcmp2=$mypath/tmp_4_$$
Chris@0 12
Chris@59 13 trap "rm -f $tmpfile $tmpcanonical $expcanonical $tmpcmp1 $tmpcmp2" 0
Chris@0 14
Chris@16 15 compare() {
Chris@16 16 a=$1
Chris@16 17 b=$2
Chris@16 18 sort $a > $tmpcmp1
Chris@16 19 sort $b > $tmpcmp2
Chris@28 20 csvcompare $tmpcmp1 $tmpcmp2
Chris@16 21 }
Chris@16 22
Chris@0 23 # transform to which we have to add summarisation on command line
Chris@119 24 transform=$mypath/transforms/detectionfunction-nosummaries.n3
Chris@119 25 expected=$mypath/expected/summaries
Chris@0 26
Chris@119 27 stransform=$mypath/transforms/detectionfunction.n3
Chris@119 28 sexpected=$mypath/expected/summaries-from-rdf
Chris@0 29
Chris@0 30 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 31 fail "Fails to run transform $transform"
Chris@0 32
Chris@16 33 compare $tmpfile ${expected}.csv || \
Chris@28 34 faildiff "Output mismatch for transform $transform" $tmpfile ${expected}.csv
Chris@0 35
Chris@0 36 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \
Chris@0 37 fail "Fails to run transform $transform with summary type mean"
Chris@0 38
Chris@16 39 compare $tmpfile ${expected}-with-mean.csv || \
Chris@28 40 faildiff "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv
Chris@0 41
Chris@0 42 $r -t $transform -w csv --csv-stdout -S min -S max -S mean -S median -S mode -S sum -S variance -S sd -S count --summary-only $infile > $tmpfile 2>/dev/null || \
Chris@0 43 fail "Fails to run transform $transform with all summary types and summary-only"
Chris@0 44
Chris@16 45 compare $tmpfile ${expected}-all-summaries-only.csv || \
Chris@28 46 faildiff "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv
Chris@0 47
Chris@0 48 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 49 fail "Fails to run transform $stransform with CSV output"
Chris@0 50
Chris@16 51 compare $tmpfile ${sexpected}.csv || \
Chris@28 52 faildiff "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv
Chris@0 53
Chris@102 54 $r -t $stransform -w csv --csv-stdout --summary-only $infile > $tmpfile 2>/dev/null || \
Chris@102 55 fail "Fails to run transform $stransform with CSV output and summary-only"
Chris@102 56
Chris@102 57 compare $tmpfile ${expected}-from-rdf-summaries-only.csv || \
Chris@102 58 faildiff "Output mismatch for transform $stransform with summary-only" $tmpfile ${expected}-from-rdf-summaries-only.csv
Chris@102 59
Chris@105 60 $r -t $transform -w csv --csv-stdout --summary-only -S median --segments 0,9.9 $infile2 > $tmpfile 2>/dev/null || \
Chris@105 61 fail "Fails to run transform $stransform with CSV output and segments"
Chris@105 62
Chris@105 63 compare $tmpfile ${expected}-segments.csv || \
Chris@105 64 faildiff "Output mismatch for transform $stransform with segments" $tmpfile ${expected}-segments.csv
Chris@105 65
Chris@0 66 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 67 fail "Fails to run transform $stransform with RDF output"
Chris@0 68
Chris@3 69 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical ||
Chris@0 70 fail "Fails to produce parseable RDF/TTL for transform $stransform"
Chris@0 71
Chris@59 72 rapper -i turtle ${sexpected}.n3 -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $expcanonical ||
Chris@59 73 fail "Internal error: Failed to canonicalise expected output file $expected.n3"
Chris@59 74
Chris@59 75 compare $tmpcanonical $expcanonical || \
Chris@59 76 faildiff "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical $expcanonical
Chris@0 77
Chris@0 78 exit 0
Chris@0 79