contingency-size.sh 1.79 KB
Newer Older
1 2 3 4 5 6
#!/bin/bash
# compute contingency table of benchmark results
# with rows = `accepted by at least one full fragment'
# and  cols = `query size'
# using list of files provided on command-line

7
MAX=`grep 'MAX_AST_SIZE =' ../../src/main/java/fr/lsv/xpparser/XPathEntry.java| sed -e 's/[^0-9]*\([0-9]*\).*/\1/'`
8
fragments=( `grep 'file=' ../../relaxng/fragments-full.xml | sed 's/.*file=\"\([\.a-zA-Z0-9\-]*.rnc\).*/\1/g'` )
9 10
step=4
cutoff=48
11

12
full="(@schema=\"${fragments[0]}\")"
13 14
for ((f = 1; f < ${#fragments[@]}; ++f))
do
15
    full="$full or (@schema=\"${fragments[f]}\")"
16 17 18
done

# first row: accepted
19
for ((i = 1; i < $cutoff; i+=$step))
20
do
21 22 23 24 25 26
    value=0
    for file in $@
    do
        count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[(ast[@size >= $i and @size < ($i+$step)]) and (schemas/validation[($full) and @valid=\"yes\"])])" $file`
        value=$((count + value))
    done
27 28
    printf "$value\t"
done
29 30 31 32 33 34 35
value=0
for file in $@
do
    count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[(ast[@size >= $cutoff]) and (schemas/validation[($full) and @valid=\"yes\"])])" $file`
    value=$((count + value))
done
printf "$value\t"
36 37
echo
# second row: not accepted
38
for ((i = 1; i < $cutoff; i+=$step))
39
do
40 41 42 43 44 45
    value=0
    for file in $@
    do
        count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[(ast[@size >= $i and @size < ($i+$step)]) and not(schemas/validation[($full) and @valid=\"yes\"])])" $file`
        value=$((count + value))
    done
46 47
    printf "$value\t"
done
48 49 50 51 52 53 54
value=0
for file in $@
do
    count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[(ast[@size >= $cutoff]) and not(schemas/validation[($full) and @valid=\"yes\"])])" $file`
    value=$((count + value))
done
printf "$value\t"
55
echo