annotate tests/test-summaries.sh @ 116:1c0799754670

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