summaryrefslogtreecommitdiff
path: root/pggraph.sh
blob: 11eb143b32971054998c344ddc99701d6e176d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
usage="$0 hocr|prob graph.png"

test $# -ne 2 && echo "$usage" && exit 1

t=`mktemp`

# TODO: the line_1_ part is changes formatting from hocr line naming to 
#       line numbers. make it work for .prob stuff too.
avg-lines -nosort "$1" | awk -F ':' '{printf("%s\t%s\n", $1, $2)}' | sed 's/%//g' | sed 's/[^ ]* line_1_//g' > "$t"

gp=`mktemp`
printf 'set style data lines\n' >> "$gp"
printf 'set title "Line confidences for %s"\n' "$1" >> "$gp"
printf 'set xlabel "Line Number"\n' >> "$gp"
printf 'set ylabel "Average confidence"\n' >> "$gp"
printf 'unset key\n' >> "$gp"
printf 'set terminal png truecolor size 1920,1080\n' >> "$gp"
printf 'set output "%s"\n' "$2" >> "$gp"
printf 'plot "%s"\n' "$t" >> "$gp"
printf 'quit\n' >> "$gp"
gnuplot "$gp"

rm -f "$t" "$gp"